Example #1
0
 void Update()
 {
     if (gameState == GameState.Playing)
     {
         float lastPlayingTime = playingTime;
         playingTime -= Time.deltaTime;
         if (playingTime < 10f)
         {
             if (Mathf.CeilToInt(lastPlayingTime) != Mathf.CeilToInt(playingTime))
             {
                 SoundController.Instance.play_count_down();
             }
         }
         if (playingTime < 0)
         {
             if (ScoreLeft != ScoreRight)
             {
                 StartCoroutine(GameOver());
             }
             else
             {
                 TexGoldenGoal.Hide(false);
             }
             playingTime = 0;
         }
         timeText.Text = playingTime.ToString("F0");
     }
 }
Example #2
0
    IEnumerator GameOver()
    {
        gameState = GameState.GameOver;
        TexGoldenGoal.Hide(true);
        SoundController.Instance.play_beep_end();
        yield return(new WaitForSeconds(1.1f));

        Time.timeScale = 0.0f; //Pause the game

        if ((myPlayer == players[0]) ^ (ScoreLeft > ScoreRight))
        {
            LoseGame();
        }
        else
        {
            WinGame();
        }
    }