Example #1
0
        // '' <summary>
        // '' Listens for attacks to be completed.
        // '' </summary>
        // '' <param name="sender">the game</param>
        // '' <param name="result">the result of the attack</param>
        // '' <remarks>
        // '' Displays a message, plays sound and redraws the screen
        // '' </remarks>
        private static void AttackCompleted(object sender, AttackResult result)
        {
            bool isHuman;

            isHuman = (_theGame.Player == HumanPlayer);
            if (isHuman)
            {
                Message = ("You " + result.ToString());
            }
            else
            {
                Message = ("The AI " + result.ToString());
            }

            switch (result.Value)
            {
            case ResultOfAttack.Destroyed:
                GameController.PlayHitSequence(result.Row, result.Column, isHuman);
                Audio.PlaySoundEffect(GameSound("Sink"));
                break;

            case ResultOfAttack.GameOver:
                GameController.PlayHitSequence(result.Row, result.Column, isHuman);
                Audio.PlaySoundEffect(GameSound("Sink"));
                while (Audio.SoundEffectPlaying(GameSound("Sink")))
                {
                    SwinGame.Delay(10);
                    SwinGame.RefreshScreen();
                }

                if (HumanPlayer.IsDestroyed)
                {
                    Audio.PlaySoundEffect(GameSound("Lose"));
                }
                else
                {
                    Audio.PlaySoundEffect(GameSound("Winner"));
                }

                break;

            case ResultOfAttack.Hit:
                GameController.PlayHitSequence(result.Row, result.Column, isHuman);
                break;

            case ResultOfAttack.Miss:
                GameController.PlayMissSequence(result.Row, result.Column, isHuman);
                break;

            case ResultOfAttack.ShotAlready:
                Audio.PlaySoundEffect(GameSound("Error"));
                break;
            }
        }