/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public static void HandleUserInput() { //Read incoming input events SwinGame.ProcessEvents(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.HandleMainMenuInput(); break; case GameState.ViewingGameMenu: MenuController.HandleGameMenuInput(); break; case GameState.AlteringSettings: MenuController.HandleSetupMenuInput(); break; case GameState.Deploying: DeploymentController.HandleDeploymentInput(); break; case GameState.Discovering: DiscoveryController.HandleDiscoveryInput(); break; case GameState.EndingGame: EndingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HighScoreController.HandleHighScoreInput(); break; case GameState.changebg: MenuController.HandleBGMenuInput(); break; << << << < HEAD case GameState.ViewHowToPlay: MenuController.HandleHowToPlayMenuInput(); break;
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; case GameState.ViewingPlayerScores: PlayerScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public static void HandleUserInput() { // Read incoming input events SwinGame.ProcessEvents(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.HandleMainMenuInput(); break; case GameState.ViewingGameMenu: MenuController.HandleGameMenuInput(); break; case GameState.AlteringSettings: MenuController.HandleSetupMenuInput(); break; case GameState.AlteringAudio: MenuController.HandleAudioMenuInput(); break; case GameState.Deploying: DeploymentController.HandleDeploymentInput(); break; case GameState.Discovering: DiscoveryController.HandleDiscoveryInput(countdown); break; case GameState.EndingGame: EndingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HighScoreController.HandleHighScoreInput(); break; } UtilityFunctions.UpdateAnimations(); }
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); //Lowered to 30 frames per second to see the splash and explosion animations SwinGame.RefreshScreen(60); }
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), HOME_BUTTON_LEFT, TOP_BUTTONS_TOP); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); if (CurrentState == GameState.ViewingMainMenu) { MenuController.DrawMainMenu(); } else if (CurrentState == GameState.ViewingGameMenu) { MenuController.DrawGameMenu(); } else if (CurrentState == GameState.AlteringSettings) { MenuController.DrawSettings(); } else if (CurrentState == GameState.Deploying) { DeploymentController.DrawDeployment(); } else if (CurrentState == GameState.Discovering) { DiscoveryController.DrawDiscovery(); } else if (CurrentState == GameState.EndingGame) { EndingGameController.DrawEndOfGame(); } else if (CurrentState == GameState.ViewingHighScores) { HighScoreController.DrawHighScores(); } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public static void HandleUserInput() { //Read incoming input events SwinGame.ProcessEvents(); if (CurrentState == GameState.ViewingMainMenu) { MenuController.HandleMainMenuInput(); } else if (CurrentState == GameState.ViewingGameMenu) { MenuController.HandleGameMenuInput(); } else if (CurrentState == GameState.AlteringSettings) { MenuController.HandleSetupMenuInput(); } else if (CurrentState == GameState.Deploying) { DeploymentController.HandleDeploymentInput(); } else if (CurrentState == GameState.Discovering) { DiscoveryController.HandleDiscoveryInput(); } else if (CurrentState == GameState.EndingGame) { EndingGameController.HandleEndOfGameInput(); } else if (CurrentState == GameState.ViewingHighScores) { HighScoreController.HandleHighScoreInput(); } UtilityFunctions.UpdateAnimations(); }
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: SwinGame.StopTimer(Timer); MenuController.DrawMainMenu(); break; case GameState.ViewingInstruction: SwinGame.StopTimer(Timer); Rules.DrawInstruction(); break; case GameState.ViewingGameMenu: SwinGame.StopTimer(Timer); MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: SwinGame.StopTimer(Timer); MenuController.DrawSettings(); break; case GameState.Deploying: SwinGame.ResetTimer(Timer); DeploymentController.DrawDeployment(); MenuController.DrawMenuBackButton(); break; case GameState.Discovering: if (SwinGame.TimerTicks(Timer) == 0) { SwinGame.StartTimer(Timer); } DiscoveryController.DrawDiscovery(); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: SwinGame.StopTimer(Timer); HighScoreController.DrawHighScores(); break; case GameState.AlteringOption: SwinGame.StopTimer(Timer); MenuController.DrawOption(); break; case GameState.ChangingMusic: SwinGame.StopTimer(Timer); MenuController.DrawMusicMenu(); break; /*case GameState.changebg: * MenuController.DrawBGOption (); * break;*/ } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <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 static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: { MenuController.DrawMainMenu(); break; } case GameState.ViewingGameMenu: { MenuController.DrawGameMenu(); break; } case GameState.AlteringSettings: { MenuController.DrawSettings(); break; } case GameState.Deploying: { DeploymentController.DrawDeployment(); break; } case GameState.Discovering: { DiscoveryController.DrawDiscovery(); break; } case GameState.EndingGame: { EndingGameController.DrawEndOfGame(); break; } case GameState.ViewingHighScores: { HighScoreController.DrawHighScores(); break; } case GameState.ViewingInstruction: { InstructionController.DrawInstruction(); break; } case GameState.Reveal: { RevealController.DrawReveal(); break; } case GameState.ViewingInstructionImg: { InstructionImgController.DrawInstructionImg(); break; } } UtilityFunctions.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 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 var @case when @case == ResultOfAttack.Destroyed: { PlayHitSequence(result.Row, result.Column, isHuman); Audio.PlaySoundEffect(GameResources.GameSound("Sink")); break; } case var case1 when case1 == ResultOfAttack.GameOver: { PlayHitSequence(result.Row, result.Column, isHuman); Audio.PlaySoundEffect(GameResources.GameSound("Sink")); while (Audio.SoundEffectPlaying(GameResources.GameSound("Sink"))) { SwinGame.Delay(3); SwinGame.RefreshScreen(); EndingGameController.DrawEndOfGame(); // fixed the delay issue with the audio sound effect when the game ends } if (HumanPlayer.IsDestroyed) { Audio.PlaySoundEffect(GameResources.GameSound("Lose")); } else { Audio.PlaySoundEffect(GameResources.GameSound("Winner")); } break; } case var case2 when case2 == ResultOfAttack.Hit: { PlayHitSequence(result.Row, result.Column, isHuman); break; } case var case3 when case3 == ResultOfAttack.Miss: { PlayMissSequence(result.Row, result.Column, isHuman); break; } case var case4 when case4 == ResultOfAttack.ShotAlready: { Audio.PlaySoundEffect(GameResources.GameSound("Error")); break; } } }
/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public static void HandleUserInput() { //Read incoming input events SwinGame.ProcessEvents(); if (SwinGame.KeyTyped(KeyCode.vk_F12)) { SwinGame.ToggleFullScreen(); } if (SwinGame.KeyTyped(KeyCode.vk_F2)) { SwinGame.ToggleWindowBorder(); } if (SwinGame.KeyTyped(KeyCode.vk_F3)) { SwinGame.StopMusic(); } if (SwinGame.KeyTyped(KeyCode.vk_F4)) { SwinGame.PauseMusic(); } if (SwinGame.KeyTyped(KeyCode.vk_F5)) { SwinGame.ResumeMusic(); } if (SwinGame.KeyTyped(KeyCode.vk_F1)) { SwinGame.TakeScreenshot("Screenshot"); } switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.HandleMainMenuInput(); break; case GameState.ViewingGameMenu: MenuController.HandleGameMenuInput(); break; case GameState.AlteringSettings: MenuController.HandleSetupMenuInput(); break; case GameState.Deploying: DeploymentController.HandleDeploymentInput(); break; case GameState.Discovering: DiscoveryController.HandleDiscoveryInput(); break; case GameState.EndingGame: EndingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HighScoreController.HandleHighScoreInput(); break; case GameState.AlteringMusic: MenuController.HandleMusicMenuInput(); break; } UtilityFunctions.UpdateAnimations(); }