コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log("Plyaer 1 selected " + player1SelectedMove);
        switch (currState)
        {
        case GameState.Player1StartSelect:
            //show UI for selecting move
            showMoves(1);

            //say that the player has not selected yet
            player1SelectedMove = -1;

            //switch states
            currState = GameState.Player1Selecting;
            break;

        case GameState.Player1Selecting:
            //this waits until the button listener SelectMove has set player1SelectedMove to something.
            if (player1SelectedMove != -1)
            {
                //switch states
                currState = GameState.Player2StartSelect;
            }
            break;

        case GameState.Player2StartSelect:
            //show UI for selecting move
            showMoves(2);

            //say that the player has not selected yet
            player2SelectedMove = -1;

            //switch states
            currState = GameState.Player2Selecting;
            break;

        case GameState.Player2Selecting:
            //this waits until the button listener SelectMove has set player2SelectedMove to something.
            if (player2SelectedMove != -1)
            {
                //switch states
                currState = GameState.Player1Move;
                hideMoves();
            }
            break;

        case GameState.Player1Move:
            //animate the attack and the hp decrease
            //we can use unity's animators to do this and just check when the the
            //animator controller's state machine is at resting.
            //This should show message for what move used
            if (ShowText(player1.pokemonName + " used " + player1.moves [player1SelectedMove].GetName() + "!"))
            {
                currState = GameState.Player2HealthChange;
                player1.animateAttack();
                player2.animateRecoil();
            }
            break;

        case GameState.Player2HealthChange:
            //This would change player2's health.
            break;
        }
    }