protected IEnumerator Start() { // If not coming from Lobby if (mode == Modes.UNESPECIFIED) { // Play game music UIMaster.PlayMusic(UIMaster.Musics.Game); // Set correct mode, so testing works string modeName = manager.GetType().Name; mode = (Modes)Enum.Parse(typeof(Modes), modeName); } // Reset game stats for both players Player.Get(1).ranking = new GameStats(); Player.Get(2).ranking = new GameStats(); // Start rounds for (int round = 1; round <= rounds; round++) { stopped = true; // Display round info yield return(RoundDisplay.Show(round, roundWinner)); roundWinner = -1; stopped = false; // Start actual game mode logic var logic = StartCoroutine(Logic()); // Wait until winner is proclaimed while (roundWinner == -1) { yield return(null); } StopCoroutine(logic); } // At the end of the game stopped = true; UIMaster.PlayEffect(UIMaster.SFx.Whistle); yield return(new WaitForSeconds(1f)); StartCoroutine(ResetStage()); UIMaster.ShowRanking(); }
public static IEnumerator Show(int round, int winner) { // Spawn new prefab var prefab = Resources.Load <RoundDisplay> ("Prefabs/UI/Round_Display"); var display = Instantiate(prefab, UIMaster.manager.transform); #region TARGET CONFIGURATION // Configure the display display.roundTitle.text = "Round " + round; if (round != 1) { // Empate! :o if (winner == 0) { display.draw.SetActive(true); display.flags[0].color = Player.Get(1).character.focusColor; display.flags[1].color = Player.Get(2).character.focusColor; } else { display.draw.SetActive(false); display.flags.ForEach(f => f.color = Player.Get(winner).character.focusColor); } // Play round whistle UIMaster.PlayEffect(UIMaster.SFx.Whistle); } else { display.draw.SetActive(false); } display.p1Name.text = Player.Get(1).name; display.p1Score.text = Player.Get(1).ranking.roundsWon.ToString(); display.p1Score.color = Character.Get(Player.Get(1).playingAs).focusColor; display.p2Name.text = Player.Get(2).name; display.p2Score.text = Player.Get(2).ranking.roundsWon.ToString(); display.p2Score.color = Character.Get(Player.Get(2).playingAs).focusColor; #endregion // Fade-in animation var anim = display.GetComponent <Animation> (); yield return(new WaitForSeconds(anim["In"].clip.averageDuration + 1f)); // Start scene reset Coroutine reset = null; if (round != 1) { reset = display.StartCoroutine(Game.manager.ResetStage()); } // Fade-out animation anim.Play("Out"); yield return(new WaitForSeconds(anim["Out"].clip.averageDuration)); // Wait until stage is cleared if (reset != null) { yield return(reset); } // Destroy display after Destroy(display.gameObject); }