示例#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 = false;

            isHuman = object.ReferenceEquals(_theGame.Player, HumanPlayer);

            if (isHuman)
            {
                UtilityFunctions.Message     = "You " + result.ToString();
                UtilityFunctions.MessageTurn = "Your Turn!";
            }
            else
            {
                UtilityFunctions.Message     = "The AI " + result.ToString();
                UtilityFunctions.MessageTurn = "AI Turn!";
            }

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

                break;

            case ResultOfAttack.GameOver:
                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:
                PlayHitSequence(result.Row, result.Column, isHuman);
                break;

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

            case ResultOfAttack.ShotAlready:
                Audio.PlaySoundEffect(GameResources.GameSound("Error"));
                break;
            }
        }
示例#2
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 = false;

            isHuman = ReferenceEquals(_theGame.Player, HumanPlayer);

            if (isHuman)
            {
                UtilityFunctions.Message = "You " + result.ToString();
            }
            else
            {
                UtilityFunctions.Message = "The AI " + result.ToString();
                UtilityFunctions.Message = UtilityFunctions.Message.Replace("enemy", "player");
            }

            if (result.Value == ResultOfAttack.Destroyed)
            {
                PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
                Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
            }
            else if (result.Value == ResultOfAttack.GameOver)
            {
                PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(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"));
                }
            }
            else if (result.Value == ResultOfAttack.Hit)
            {
                PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
            }
            else if (result.Value == ResultOfAttack.Miss)
            {
                PlayMissSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
            }
            else if (result.Value == ResultOfAttack.ShotAlready)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Error"));
            }
        }
示例#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 = _myGame.Player == HumanPlayer;

            if (isHuman)
            {
                UtilityFunctions.Message = "You " + result.ToString();
            }
            else
            {
                UtilityFunctions.Message = "The _ai " + result.ToString();
            }

            switch (result.Value)
            {
            case ResultOfAttack.Destroyed: {
                PlayHitSequence(result.Row, result.Column, isHuman);
                if (Extentions.MusicPlaying == true)
                {
                    Audio.PlaySoundEffect(GameResources.GetSound("Sink"));
                }
                else if (Extentions.MusicPlaying == false)
                {
                }

                break;
            }

            case ResultOfAttack.GameOver: {
                PlayHitSequence(result.Row, result.Column, isHuman);
                Audio.PlaySoundEffect(GameResources.GetSound("Sink"));
                while (Audio.SoundEffectPlaying(GameResources.GetSound("Sink")))
                {
                    SwinGame.Delay(10);
                    SwinGame.RefreshScreen();
                }
                if (HumanPlayer.IsDestroyed)
                {
                    if (Extentions.MusicPlaying == true)
                    {
                        Audio.PlaySoundEffect(GameResources.GetSound("Lose"));
                    }
                }
                else
                {
                    if (Extentions.MusicPlaying == true)
                    {
                        Audio.PlaySoundEffect(GameResources.GetSound("Winner"));
                    }
                }
                break;
            }

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

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

            case ResultOfAttack.ShotAlready: {
                if (Extentions.MusicPlaying == true)
                {
                    Audio.PlaySoundEffect(GameResources.GetSound("Error"));
                }

                break;
            }
            }
        }
        /// <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 = false;
            isHuman = object.ReferenceEquals(_theGame.Player, HumanPlayer);

            if (isHuman) {

                UtilityFunctions.Message = "You " + result.ToString();
            } else {
                UtilityFunctions.Message = "The AI " + result.ToString();
            }

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

                    break;
                case ResultOfAttack.GameOver:
                    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:
                    PlayHitSequence(result.Row, result.Column, isHuman);
                    break;
                case ResultOfAttack.Miss:
                    PlayMissSequence(result.Row, result.Column, isHuman);
                    break;
                case ResultOfAttack.ShotAlready:
                    Audio.PlaySoundEffect(GameResources.GameSound("Error"));
                    break;
            }
        }