// '' <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(); 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.Deploying: DeploymentController.HandleDeploymentInput(); break; case GameState.Discovering: DiscoveryController.HandleDiscoveryInput(); break; case GameState.EndingGame: EndingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HighScoreController.HandleHighScoreInput(); break; } UtilityFunctions.UpdateAnimations(); }
// '' <summary> // '' Handles user input for the Deployment phase of the game. // '' </summary> // '' <remarks> // '' Involves selecting the ships, deloying ships, changing the direction // '' of the ships to add, randomising deployment, end then ending // '' deployment // '' </remarks> public static void HandleDeploymentInput() { if (SwinGame.KeyTyped(KeyCode.EscapeKey)) { GameController.AddNewState(GameState.ViewingGameMenu); } if ((SwinGame.KeyTyped(KeyCode.UpKey) || SwinGame.KeyTyped(KeyCode.DownKey))) { _currentDirection = Direction.UpDown; } if ((SwinGame.KeyTyped(KeyCode.LeftKey) || SwinGame.KeyTyped(KeyCode.RightKey))) { _currentDirection = Direction.LeftRight; } if (SwinGame.KeyTyped(KeyCode.RKey)) { GameController.HumanPlayer.RandomizeDeployment(); } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { ShipName selected; selected = DeploymentController.GetShipMouseIsOver(); if ((selected != ShipName.None)) { _selectedShip = selected; } else { DeploymentController.DoDeployClick(); } if ((GameController.HumanPlayer.ReadyToDeploy && SwinGame.PointInRect(SwinGame.MousePosition(), PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP, PLAY_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT))) { GameController.EndDeployment(); } else if (SwinGame.PointInRect(SwinGame.MousePosition(), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP, DIR_BUTTONS_WIDTH, TOP_BUTTONS_HEIGHT)) { _currentDirection = Direction.UpDown; } else if (SwinGame.PointInRect(SwinGame.MousePosition(), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP, DIR_BUTTONS_WIDTH, TOP_BUTTONS_HEIGHT)) { _currentDirection = Direction.LeftRight; } else if (SwinGame.PointInRect(SwinGame.MousePosition(), RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP, RANDOM_BUTTON_WIDTH, TOP_BUTTONS_HEIGHT)) { GameController.HumanPlayer.RandomizeDeployment(); } } }
/// <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 var @case when @case == GameState.ViewingMainMenu: { MenuController.DrawMainMenu(); break; } case var case1 when case1 == GameState.ViewingGameMenu: { MenuController.DrawGameMenu(); break; } case var case2 when case2 == GameState.AlteringSettings: { MenuController.DrawSettings(); break; } case var case3 when case3 == GameState.Deploying: { DeploymentController.DrawDeployment(); break; } case var case4 when case4 == GameState.Discovering: { DiscoveryController.DrawDiscovery(); break; } case var case5 when case5 == GameState.EndingGame: { EndingGameController.DrawEndOfGame(); break; } case var case6 when case6 == GameState.ViewingHighScores: { HighScoreController.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 var @case when @case == GameState.ViewingMainMenu: { MenuController.HandleMainMenuInput(); break; } case var case1 when case1 == GameState.ViewingGameMenu: { MenuController.HandleGameMenuInput(); break; } case var case2 when case2 == GameState.AlteringSettings: { MenuController.HandleSetupMenuInput(); break; } case var case3 when case3 == GameState.Deploying: { DeploymentController.HandleDeploymentInput(); break; } case var case4 when case4 == GameState.Discovering: { DiscoveryController.HandleDiscoveryInput(); break; } case var case5 when case5 == GameState.EndingGame: { EndingGameController.HandleEndOfGameInput(); break; } case var case6 when case6 == 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(); 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(); }