コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        switch (gameMode)
        {
        case GameMode.MainMenu:     UpdateMainMenu(); break;

        case GameMode.HighScores:   UpdateHighScores(); break;

        case GameMode.InGame:       UpdateMainGame(); break;

        case GameMode.LevelWon:     UpdateWinMenu(); break;
        }

        if ((playerObject.PelletsEaten() == pellets.Length * level) && !won)
        {
            levelCompleteSound.Play();
            won = true;
            ghost1.GetComponent <NavMeshAgent>().speed = 0;
            ghost2.GetComponent <NavMeshAgent>().speed = 0;
            ghost3.GetComponent <NavMeshAgent>().speed = 0;
            ghost4.GetComponent <NavMeshAgent>().speed = 0;
            LevelComplete();
        }
        else if (playerObject.lives == 0 && !died)
        {
            GlobalVariables.score = playerObject.score;
            SceneManager.LoadScene("Cutscene1");
            playerObject.SetPelletsEaten(0);
            ghost1.GetComponent <NavMeshAgent>().speed = 0;
            ghost2.GetComponent <NavMeshAgent>().speed = 0;
            ghost3.GetComponent <NavMeshAgent>().speed = 0;
            ghost4.GetComponent <NavMeshAgent>().speed = 0;
            AddHighScore();
            StartMainMenu();
            died = true;
        }
    }