private static void PlayHitSequence(int row, int column, bool showAnimation)
        {
            if (showAnimation)
            {
                UtilityFunctions.AddExplosion(row, column);
            }

            Audio.PlaySoundEffect(GameResources.GameSound("Hit"));

            UtilityFunctions.DrawAnimationSequence();
        }
        private static void PlayMissSequence(int row, int column, bool showAnimation)
        {
            if (showAnimation)
            {
                UtilityFunctions.AddSplash(row, column);
            }

            Audio.PlaySoundEffect(GameResources.GameSound("Miss"));

            UtilityFunctions.DrawAnimationSequence();
        }
Beispiel #3
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 = (_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);
                if (!_mute)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
                }

                break;

            case ResultOfAttack.GameOver:
                //potentially remove this as it gets played twice if the player wins
                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 && !_mute)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
                }
                else
                {
                    if (!_mute)
                    {
                        Audio.PlaySoundEffect(GameResources.GameSound("Winner"));
                    }
                }

                //come back here to add the letter/number coordinates
                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:
                if (!_mute)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Error"));
                }
                break;
            }
        }