/// <summary> /// Completes the deployment phase of the game and /// switches to the battle mode (Discovering state) /// </summary> /// <remarks> /// This adds the players to the game before switching /// state. /// </remarks> public static void EndDeployment() { //deploy the players _theGame.AddDeployedPlayer(_human); _theGame.AddDeployedPlayer(_ai); Audio.PlaySoundEffect(GameResources.GameSound("Siren")); SwitchState(GameState.Discovering); }
private static void PlayMissSequence(int row, int column, bool showAnimation) { if (showAnimation) { UtilityFunctions.AddSplash(row, column); } Audio.PlaySoundEffect(GameResources.GameSound("Miss")); UtilityFunctions.DrawAnimationSequence(); }
private static void PlayHitSequence(int row, int column, bool showAnimation) { if (showAnimation) { UtilityFunctions.AddExplosion(row, column); } Audio.PlaySoundEffect(GameResources.GameSound("Hit")); UtilityFunctions.DrawAnimationSequence(); }
/// <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) { UtilityFunctions.Message = "You " + result.ToString(); } else { UtilityFunctions.Message = "The AI " + result.ToString(); } switch (result.Value) { case ResultOfAttack.Destroyed: { if (isHuman) { PlayHitSequence(result.Row, result.Column, isHuman); _count--; Audio.PlaySoundEffect(GameResources.GameSound("Sink")); } else { 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; } } }