Merge branch 'master' into storyA_sounds
# Conflicts: # racevisionGame/src/main/java/mock/model/RaceServer.java # racevisionGame/src/main/java/visualiser/Controllers/HostController.java # racevisionGame/src/main/java/visualiser/Controllers/MainController.java # racevisionGame/src/main/java/visualiser/Controllers/TitleController.java
This commit is contained in:
@@ -49,6 +49,9 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
prestartCountdown();
|
||||
|
||||
race.initialiseBoats();
|
||||
|
||||
countdown();
|
||||
@@ -61,6 +64,37 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The countdown timer until the prestart period is finished. This timer will stop 3 minutes before the race starts, and players can no longer start participating.
|
||||
*/
|
||||
private void prestartCountdown() {
|
||||
|
||||
long previousFrameTime = System.currentTimeMillis();
|
||||
|
||||
while (((race.getRaceStatusEnum() == RaceStatusEnum.PRESTART)
|
||||
|| (race.getRaceStatusEnum() == RaceStatusEnum.NOT_ACTIVE)
|
||||
|| (race.getRaceStatusEnum() == RaceStatusEnum.WARNING)) && loopBool) {
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
//Update race time.
|
||||
race.updateRaceTime(currentTime);
|
||||
|
||||
//Update the race status based on the current time.
|
||||
race.updateRaceStatusEnum();
|
||||
|
||||
//Provide boat's with an estimated time at next mark until the race starts.
|
||||
race.setBoatsTimeNextMark(race.getRaceClock().getCurrentTime());
|
||||
|
||||
//Parse the race snapshot.
|
||||
server.parseSnapshot();
|
||||
|
||||
|
||||
waitForFramePeriod(previousFrameTime, currentTime, 50);
|
||||
previousFrameTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Countdown timer until race starts.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user