Esempio n. 1
0
        // Checks for when an attack has been completed. If so, it displays
        // a message, plays a sound and redraws the screen.
        private static void AttackCompleted(object sender, AttackResult result)
        {
            bool isHuman;

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

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

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

                if (HumanPlayer.IsDestroyed)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
                }
                else
                {
                    Audio.PlaySoundEffect(GameResources.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(GameResources.GameSound("Error"));
                break;
            }
        }