示例#1
0
    // Function to set up animations on state changes
    void HandleStateChangedEvent(GameState state)
    {
        // Starting state of the game
        if (state == GameState.Begin)
        {
            //Debug.Log("If this is displaying why is there no audio???");
            audio.PlayOneShot(music, 0.3f);

            // Activate AI
            Instantiate(aiBots[0].gameObject);

            spawnner.Spawn(batteries); //Randomize battery spawns

            // DisplayGoal(); // Display Objective
        }

        // When Player 2 picks up the first battery
        if (state == GameState.Battery1)
        {
            DisplayGoal();
            Instantiate(aiBots[1].gameObject);
        }

        // When Player 2 picks up the second battery
        if (state == GameState.Battery2)
        {
            DisplayGoal();
            Instantiate(aiBots[2].gameObject);
        }

        // When Player 2 picks up the last battery
        if (state == GameState.Battery3)
        {
            DisplayGoal();
            Instantiate(aiBots[3].gameObject);
        }

        // State for when player 1 wins the game
        if (state == GameState.P1GameWin)
        {
            OnGameOver(1);
            gameObject.GetComponent <InputManager>().GameOver = true;
        }

        // State for when player 2 wins the game
        if (state == GameState.P2GameWin)
        {
            OnGameOver(2);
            gameObject.GetComponent <InputManager>().GameOver = true;
        }
    }