Beispiel #1
0
    /// <summary>
    /// Checks the results of the attack and switches to
    /// Ending the Game if the result was game over.
    /// </summary>
    /// <param name="result">the result of the last
    /// attack</param>
    /// <remarks>Gets the AI to attack if the result switched
    /// to the AI player.</remarks>
    private static void CheckAttackResult(AttackResult result)
    {
        switch (result.Value)
        {
        case ResultOfAttack.Miss:
            if (object.ReferenceEquals(_theGame.Player, ComputerPlayer) && _theGame.getPlayerIndex() == 1)     // when human miss
            {
                _theGame.setPlayerIndex(1);
                AIAttack();
            }
            else
            {
                _theGame.setPlayerIndex(0);
            }
            break;

        case ResultOfAttack.GameOver:
            SwitchState(GameState.EndingGame);
            break;
        }
    }