public void RenderState() { GameRunning.GetInstance().RenderState(); foreach (var button in menuButtons) { button.RenderText(); } }
public void SwitchState(GameStateType stateType) { switch (stateType) { case GameStateType.GameRunning: ActiveState = GameRunning.GetInstance(); break; case GameStateType.GamePaused: ActiveState = GamePaused.GetInstance(); break; case GameStateType.MainMenu: ActiveState = MainMenu.GetInstance(); break; case GameStateType.ChooseLevel: ActiveState = ChooseLevel.GetInstance(); break; } }
/// <summary> /// checks for all Collisions that can occur /// and handles the appropriately /// </summary> public void GameCollisions() { Collision.ObstacleCollision(player, levelCreator.Obstacles); if (Collision.ExitCollision(player, levelCreator.Exits)) { if (GameRunning.map == "short-n-sweet.txt") { GameRunning.NewInstance("the-beach.txt"); InitializeGameState(); } else { GameRunning.NewInstance("short-n-sweet.txt"); InitializeGameState(); } } var platcol = Collision.PlatformCollision(player, levelCreator.Platforms); if (platcol.Item1) { var v = platcol.Item2; player.PlatformTouch = true; DropCustomerOff(CustomersPickedUp, v); } foreach (Customer customer in CustomerList) { if (Collision.CustomerCollision(player, customer)) { customer.IsRendered = false; CustomersPickedUp.Add(customer); } } }
public void HandleKeyEvent(string keyValue, string keyAction) { switch (keyAction) { case "KEY_PRESS": switch (keyValue) { case "KEY_UP": if (activeMenuButton > 0) { menuButtons[activeMenuButton].SetColor(Color.DarkGray); activeMenuButton--; menuButtons[activeMenuButton].SetColor(Color.White); } else if (activeMenuButton == 0) { menuButtons[activeMenuButton].SetColor(Color.DarkGray); activeMenuButton = 2; menuButtons[activeMenuButton].SetColor(Color.White); } break; case "KEY_DOWN": if (activeMenuButton < MainMenu.maxMenuButtons - 1) { menuButtons[activeMenuButton].SetColor(Color.DarkGray); activeMenuButton++; menuButtons[activeMenuButton].SetColor(Color.White); } else if (activeMenuButton == MainMenu.maxMenuButtons - 1) { menuButtons[activeMenuButton].SetColor(Color.DarkGray); activeMenuButton = 0; menuButtons[activeMenuButton].SetColor(Color.White); } break; case "KEY_ENTER": if (activeMenuButton == 0) { GameRunning.NewInstance("short-n-sweet.txt"); EventBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); } else if (activeMenuButton == 1) { EventBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "CHOOSE_LEVEL", "")); } else if (activeMenuButton == 2) { EventBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", "")); } break; } break; } }
public static GameRunning NewInstance(string map) { GameRunning.map = map; return(GameRunning.instance = new GameRunning()); }
public static GameRunning GetInstance() { return(GameRunning.instance ?? (GameRunning.instance = new GameRunning())); }
public static GameRunning NewGame() { GameRunning.gameRunning = new GameRunning(); return(GameRunning.gameRunning); }