// Game private IEnumerator Game_Enter() { Debug.Log("[Game] Enter"); // Open panels. SwitchPanels(UIGroup.Group6, m_CountdownPanel); // Register on match controller events. if (m_MatchController != null) { m_MatchController.endGameRequestedEvent += OnEndGameRequested; m_MatchController.finishGameEvent += OnFinishGame; m_MatchController.matchPausedEvent += OnMatchPaused; m_MatchController.matchUnpausedEvent += OnMatchUnpaused; } // Define countdown completed callback. bool countdownCompleted = false; Action countdownCompletedCallback = () => { countdownCompleted = true; }; // Start countdown and register on panel events. if (m_CountdownPanel != null) { m_CountdownPanel.countdownCompletedEvent += countdownCompletedCallback; m_CountdownPanel.StartCountdown(); } else { countdownCompletedCallback(); } // Wait for countdown. yield return(new WaitUntil(() => (countdownCompleted == true))); // Unregister from panel events. if (m_CountdownPanel != null) { m_CountdownPanel.countdownCompletedEvent -= countdownCompletedCallback; } // Start music. MusicPlayer.PlayMain(); // Start game on match controller. if (m_MatchController != null) { m_MatchController.OnStartGame(); } }
// Game private void Game_Enter() { Debug.Log("[Game] Enter"); // Start game on match controller. if (m_MatchController != null) { m_MatchController.OnStartGame(); } // Notify external FSMs. PlayMakerFSM.BroadcastEvent("GAME / START"); }