fix: changed a couple of methods

This commit is contained in:
Laureηt 2021-04-13 21:24:36 +02:00
parent 696735af14
commit 6b74d3ad7c
3 changed files with 20 additions and 37 deletions

View file

@ -35,7 +35,7 @@ public class Bow extends Actor {
}
// ---------- METHODs ----------
@Override
public void act(float dt) {
if (playing) {
@ -79,34 +79,25 @@ public class Bow extends Actor {
power = MathUtils.clamp(aim.len(), 0, 1000);
}
/**
/**
* Generates an Arrow according to the Bow's attributes.
*
*
* @return an Arrow.
*/
private Arrow getArrow() {
return new Arrow(angle, power, shooter);
}
/**
* Indiquer que c'est a son tour de jouer.
* Change the active state of the {@link Bow}.
* @param bool true or false
*/
public void startPlaying() {
playing = true;
public void setPlaying(boolean bool) {
playing = bool;
}
/**
* Indique que ce n'est plus son tour de jouer.
*/
public void stopPlaying() {
playing = false;
}
/**
* Savoir si il est entrain de jouer.
* @return the active state of the {@link Bow}.
*/
public boolean isPlaying() {
return playing;

View file

@ -75,23 +75,16 @@ public class Player extends BaseActor {
}
/**
* Indiquer que c'est son tour de jouer.
* Change the active state of the {@link Player}.
* @param bool true or false
*/
public void startPlaying() {
bow.startPlaying();
playing = true;
public void setPlaying(boolean bool) {
bow.setPlaying(bool);
playing = bool;
}
/**
* Indique la fin de son tour de jeu.
*/
public void stopPlaying() {
bow.stopPlaying();
playing = false;
}
/**
* Savoir si il est entrain de jouer.
* @return the active state of the {@link Player}.
*/
public boolean isPlaying() {
return playing;

View file

@ -31,10 +31,10 @@ public class GameScreen extends BaseScreen {
// planets & moons
attractors = new Group();
Planet planet1 = new Planet(new Vector2(400, 400), 1000, 50, Color.BLUE);
attractors.addActor(planet1);
Planet planet2 = new Planet(new Vector2(1400, 700), 1000, 100, Color.ORANGE);
attractors.addActor(planet2);
@ -54,7 +54,7 @@ public class GameScreen extends BaseScreen {
mainStage.addActor(players);
playerTurn = 0;
player1.startPlaying();
player1.setPlaying(true);
// arrows
arrows = new Group();
@ -81,16 +81,15 @@ public class GameScreen extends BaseScreen {
Player actualPlayer = (Player) players.getChild(playerTurn);
if (actualPlayer.isPlaying() && !actualPlayer.getBow().isPlaying()) {
actualPlayer.stopPlaying();
actualPlayer.setPlaying(true);
playerTurn++;
playerTurn %= players.getChildren().size;
actualPlayer = (Player) players.getChild(playerTurn);
actualPlayer.startPlaying();
actualPlayer.setPlaying(false);
}
}
public void removePlayer(Player player) {
int index = players.getChildren().indexOf(player, true);
if (index < playerTurn) {
@ -101,7 +100,7 @@ public class GameScreen extends BaseScreen {
players.removeActor(player);
playerTurn %= players.getChildren().size;
Player actualPlayer = (Player) players.getChild(playerTurn);
actualPlayer.startPlaying();
actualPlayer.setPlaying(true);
} else {
players.removeActor(player);
}