/* ================= Phase Functions ================= */ /// <summary> /// Called when changing to a new phase to initialise the phase /// </summary> void InitializePhase() { switch (m_currentPhase) { case ExamplePhases.INACTIVE: { break; } case ExamplePhases.SETUP: { //Informs the game of the change of phase EventManager.m_instance.AddEvent(Events.Event.EX_SETUP); SpawnPlayers(); //Setup buffer phase m_currentPhase = ExamplePhases.BUFFER; m_bufferPhase.m_lenght = 5.0f; m_bufferPhase.m_nextPhase = ExamplePhases.PLAY; m_bufferPhase.m_message = "Round " + (m_roundsPlayed + 1) + " Set!"; InitializePhase(); break; } case ExamplePhases.PLAY: { //Informs the game of the change of phase EventManager.m_instance.AddEvent(Events.Event.EX_PLAY); //Starts pre-made timer for play phase m_timers[GetTimer("Play")].StartTimer(); break; } case ExamplePhases.RESET: { //Informs the game of the change of phase EventManager.m_instance.AddEvent(Events.Event.EX_RESET); if (CheckFinished()) { m_currentPhase = ExamplePhases.FINISH; InitializePhase(); } else { ResetRound(); m_currentPhase = ExamplePhases.SETUP; InitializePhase(); } break; } case ExamplePhases.FINISH: { //Informs the game of the change of phase EventManager.m_instance.AddEvent(Events.Event.DS_FINISH); //Call standard function for deactivating game EndGame(); //Setup buffer phase m_currentPhase = ExamplePhases.BUFFER; m_bufferPhase.m_lenght = 5.0f; m_bufferPhase.m_nextPhase = ExamplePhases.INACTIVE; m_bufferPhase.m_message = "Game Over!"; InitializePhase(); break; } case ExamplePhases.BUFFER: { //Informs the game of the change of phase EventManager.m_instance.AddEvent(Events.Event.DS_BUFFER); //Initialise timer for dynamic buffer phase Debug.Log(m_bufferPhase.m_message); m_timers[GetTimer("Buffer")].m_timerLength = m_bufferPhase.m_lenght; m_timers[GetTimer("Buffer")].StartTimer(); break; } default: { break; } } }
/// <summary> /// Phase loops for each individual phase /// </summary> void UpdatePhase() { switch (m_currentPhase) { case ExamplePhases.INACTIVE: { //Checks whether the game has been activated for play if (m_active) { //Initialse when the game is active m_currentPhase = ExamplePhases.SETUP; InitializePhase(); } break; } case ExamplePhases.SETUP: { break; } case ExamplePhases.PLAY: { //Checks whether the play phase has end if (m_timers[GetTimer("Play")].CheckFinished()) { //Increases the number of rounds played m_roundsPlayed++; //Changes phse to reset phase to hand end of round logic m_currentPhase = ExamplePhases.RESET; InitializePhase(); } break; } case ExamplePhases.RESET: { break; } case ExamplePhases.FINISH: { break; } case ExamplePhases.BUFFER: { //Checks whether the buffer phase has end if (m_timers[GetTimer("Buffer")].CheckFinished()) { //Changes to next phase upon buffer phase completion m_currentPhase = m_bufferPhase.m_nextPhase; InitializePhase(); } break; } default: { break; } } }