Пример #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();
            }
            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;
            }
        }
Пример #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 = object.ReferenceEquals(_theGame.Player, HumanPlayer);

            Console.WriteLine(result.ToString());
            if (isHuman)
            {
                if (result.ToString().Contains("destroyed"))
                {
                    Message = "You destroyed the enemies" + result.ToString().Replace("destroyed", "");
                }
                else
                {
                    Message = "You " + result.ToString();
                }
            }
            else
            {
                if (result.ToString().Contains("destroyed"))
                {
                    Message = "The enemy destroyed your" + result.ToString().Replace("destroyed", "");
                }
                else
                {
                    Message = "The AI " + result.ToString();
                }
            }

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

                break;

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

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

            case ResultOfAttack.ShotAlready:
                Audio.PlaySoundEffect(GameSound("Error"));
                break;
            }
        }
Пример #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 = false;
			isHuman = object.ReferenceEquals(_theGame.Player, HumanPlayer);

			Console.WriteLine (result.ToString ());
			if (isHuman) 
			{
				if (result.ToString ().Contains ("destroyed") )
					Message = "You destroyed the enemies" + result.ToString().Replace ("destroyed", "");
				else
					Message = "You " + result.ToString();
			} else {
				if (result.ToString ().Contains ("destroyed") )
					Message = "The enemy destroyed your"  + result.ToString().Replace ("destroyed", "");
				else
					Message = "The AI " + result.ToString ();
			}

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

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