示例#1
0
        private void CheckIfGameOver()
        {
            //Check if food point total is less than or equal to zero.
            if (food <= 0)
            {
                //Call the PlaySingle function of SoundManager and pass it the gameOverSound as the audio clip to play.
                SoundManager.instance.PlaySingle(gameOverSound);

                //Stop the background music.
                SoundManager.instance.musicSource.Stop();

                //Set m_isDead to true so the player can't move
                m_isDead = true;

                //Set player velocity to 0 and play death animation
                banditBody.velocity = Vector2.zero;
                m_animator.SetTrigger("Death");

                //Call the GameOver function of GameManager.
                gameManager.Invoke("GameOver", deathTime);
            }
        }