|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package mock.model;
|
|
|
|
|
|
|
|
|
|
import javafx.animation.AnimationTimer;
|
|
|
|
|
import mock.model.collider.Collision;
|
|
|
|
|
import mock.model.commandFactory.Command;
|
|
|
|
|
import mock.model.commandFactory.CompositeCommand;
|
|
|
|
|
import mock.model.commandFactory.CommandFactory;
|
|
|
|
|
import network.Messages.Enums.BoatActionEnum;
|
|
|
|
|
@ -9,8 +11,11 @@ import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
|
import network.Messages.LatestMessages;
|
|
|
|
|
import shared.model.RunnableWithFramePeriod;
|
|
|
|
|
|
|
|
|
|
import java.util.Observable;
|
|
|
|
|
import java.util.Observer;
|
|
|
|
|
|
|
|
|
|
public class RaceLogic implements RunnableWithFramePeriod {
|
|
|
|
|
|
|
|
|
|
public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
|
|
|
|
/**
|
|
|
|
|
* State of current race modified by this object
|
|
|
|
|
*/
|
|
|
|
|
@ -32,6 +37,8 @@ public class RaceLogic implements RunnableWithFramePeriod {
|
|
|
|
|
this.race = race;
|
|
|
|
|
this.server = new RaceServer(race, messages);
|
|
|
|
|
this.commands = compositeCommand;
|
|
|
|
|
|
|
|
|
|
race.getColliderRegistry().addObserver(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -168,4 +175,14 @@ public class RaceLogic implements RunnableWithFramePeriod {
|
|
|
|
|
public MockRace getRace() {
|
|
|
|
|
return race;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void update(Observable o, Object arg) {
|
|
|
|
|
Collision e = (Collision)arg;
|
|
|
|
|
|
|
|
|
|
if(e.getBearing().degrees() == 0) System.out.println("Ahead");
|
|
|
|
|
else if(e.getBearing().degrees() < 90) System.out.println("Starboard");
|
|
|
|
|
else if(e.getBearing().degrees() > 270) System.out.println("Port");
|
|
|
|
|
else System.out.println("Behind");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|