/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: { MenuController.Instance.DrawMainMenu(); break; } case GameState.ViewingGameMenu: { MenuController.Instance.DrawGameMenu(); break; } case GameState.AlteringSettings: { MenuController.Instance.DrawSettings(); break; } case GameState.Deploying: { DeploymentController.Instance.DrawDeployment(); break; } case GameState.Discovering: { DiscoveryController.DrawDiscovery(); break; } case GameState.EndingGame: { EndingGameController.DrawEndOfGame(); break; } case GameState.ViewingHighScores: { HighScoreController.Instance.DrawHighScores(); break; } } UtilityFunctions.Instance.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <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 void AttackCompleted(object sender, AttackResult result) { bool isHuman; isHuman = _theGame.Player == HumanPlayer; if (isHuman) { if (result.Value == ResultOfAttack.Destroyed) { UtilityFunctions.MESSAGE_COLOR = Color.Green; UtilityFunctions.Instance.Message = "You " + result.ToString(); } else { UtilityFunctions.MESSAGE_COLOR = Color.White; } UtilityFunctions.Instance.Message = "You " + result.ToString(); } else { if (result.Value == ResultOfAttack.Destroyed) { UtilityFunctions.MESSAGE_COLOR = Color.Red; } else { UtilityFunctions.MESSAGE_COLOR = Color.Blue; } UtilityFunctions.Instance.Message = "The AI " + result.ToString(); } switch (result.Value) { case ResultOfAttack.Destroyed: { PlayHitSequence(result.Row, result.Column, isHuman); Color flashColor; if (isHuman) { flashColor = SwinGame.RGBAColor(0, 255, 0, 127); } else { flashColor = SwinGame.RGBAColor(255, 0, 0, 127); }; Audio.PlaySoundEffect(GameResources.Instance.GameSound("Sink")); SwinGame.FillRectangle(flashColor, 0, 0, 800, 600); SwinGame.RefreshScreen(); SwinGame.Delay(150); UtilityFunctions.DrawBackground(); DiscoveryController.DrawDiscovery(); SwinGame.RefreshScreen(); SwinGame.Delay(100); SwinGame.FillRectangle(flashColor, 0, 0, 800, 600); SwinGame.RefreshScreen(); SwinGame.Delay(150); break; } case ResultOfAttack.GameOver: { PlayHitSequence(result.Row, result.Column, isHuman); Audio.PlaySoundEffect(GameResources.Instance.GameSound("Sink")); while (Audio.SoundEffectPlaying(GameResources.Instance.GameSound("Sink"))) { //SwinGame.Delay(10); SwinGame.RefreshScreen(); } if (HumanPlayer.IsDestroyed) { Audio.PlaySoundEffect(GameResources.Instance.GameSound("Lose")); } else { Audio.PlaySoundEffect(GameResources.Instance.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.Instance.GameSound("Error")); break; } } }