public void HandlePlayerInput(InputManager input) { if (input.IsKeyDownOnce(Keys.C)) PerformPlayerCollision = !PerformPlayerCollision; if (input.IsKeyDownOnce(Keys.E)) { List<AABB> interactables = Interactables.GetInteractablesInRange(this); foreach (AABB aabb in interactables) { if (aabb is IInteractableObject) { IInteractableObject obj = (IInteractableObject)aabb; obj.Use(this); } } } }
public void UpdateMenu(InputManager input) { if(input.IsKeyDownOnce(MenuKeys[MenuActions.NEXT_ENTRY])) { ++currentSelectionIndex; if (menuType == GameStates.MainMenu) { if (currentSelectionIndex >= MainMenuEntries.Count) currentSelectionIndex = 0; MainMenuEntries.ElementAt(currentSelectionIndex).Key.SetSelected(); MainMenuEntries.ElementAt(prevSelectionIndex).Key.SetUnselected(); } else if (menuType == GameStates.PAUSE) { if (currentSelectionIndex >= PauseMenuEntries.Count) currentSelectionIndex = 0; PauseMenuEntries.ElementAt(currentSelectionIndex).Key.SetSelected(); PauseMenuEntries.ElementAt(prevSelectionIndex).Key.SetUnselected(); } prevSelectionIndex = currentSelectionIndex; } if(input.IsKeyDownOnce(MenuKeys[MenuActions.PREV_ENTRY])) { --currentSelectionIndex; if (menuType == GameStates.MainMenu) { if (currentSelectionIndex < 0) currentSelectionIndex = MainMenuEntries.Count - 1; MainMenuEntries.ElementAt(currentSelectionIndex).Key.SetSelected(); MainMenuEntries.ElementAt(prevSelectionIndex).Key.SetUnselected(); } else if (menuType == GameStates.PAUSE) { if (currentSelectionIndex < 0) currentSelectionIndex = PauseMenuEntries.Count-1; PauseMenuEntries.ElementAt(currentSelectionIndex).Key.SetSelected(); PauseMenuEntries.ElementAt(prevSelectionIndex).Key.SetUnselected(); } prevSelectionIndex = currentSelectionIndex; } if(input.IsKeyDownOnce(MenuKeys[MenuActions.SELECT_ENTRY])) { if (menuType == GameStates.MainMenu) MainMenuEntries.ElementAt(currentSelectionIndex).Key.OnEntrySelected(); else if (menuType == GameStates.PAUSE) PauseMenuEntries.ElementAt(currentSelectionIndex).Key.OnEntrySelected(); } if(input.IsKeyDownOnce(MenuKeys[MenuActions.BACK])) { if (previousGameState == GameStates.MainMenu) { Game.quitGame = true; } else if (previousGameState == GameStates.GAME) { Game.currentGameState = GameStates.GAME; } else if (previousGameState == GameStates.PAUSE) { //it cant really be, can it %)) throw new Exception("Ok, what the f**k happened now, time to get some sleep?"); } } }