public void RenderState() { GameRunning.GetInstance().RenderState(); foreach (Text but in menuButtons) { but.RenderText(); } }
private void KeyRelease(string key) { if (key.Equals("KEY_A") || key.Equals("KEY_D")) { GalagaBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForSpecificProcessor( GameEventType.PlayerEvent, this, GameRunning.GetInstance(this).player, "stop move", "", "")); } }
private void KeyPress(string key) { switch (key) { case "KEY_SPACE": GameRunning.GetInstance(this).player.CreateShot(); break; } }
public void CustomerTimeOut() { ChoseLevel.GetInstance().filename = "short-n-sweet.txt"; GameRunning.instance = null; GameOver.instance = null; GameRunning.GetInstance(game, null); // GameRunning.instance.player.thrust = new Vec2F(-0.00001f, 0f); //sets a convenient start position for player GameRunning.instance.player.Entity.Shape.SetPosition(new Vec2F(0.3f , 0.25f)); GameRunning.instance.gravity = new Vec2F(0f, -0.0000003f); SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); SpaceTaxiBus.GetBus().ProcessEventsSequentially(); while (GameOver.instance == null) { game.gameTimer.MeasureTime(); while (game.gameTimer.ShouldUpdate()) { SpaceTaxiBus.GetBus().ProcessEvents(); game.win.PollEvents(); game.eventBus.ProcessEvents(); game.stateMachine.ActiveState.UpdateGameLogic(); } if (game.gameTimer.ShouldRender()) { game.win.Clear(); game.backGroundImage.RenderEntity(); game.stateMachine.ActiveState.RenderState(); game.win.SwapBuffers(); } if (game.gameTimer.ShouldReset()) { // 1 second has passed - display last captured ups and fps from the timer // win.Title = "Space Taxi | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + // gameTimer.CapturedFrames; } } Assert.That(game.stateMachine.ActiveState, Is.InstanceOf <GameOver>()); }
private 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; } }
private void SwitchState(GameStateType stateType) { switch (stateType) { case GameStateType.MainMenu: GameRunning.GetInstance().InitializeGameState(); ActiveState = MainMenu.GetInstance(); break; case GameStateType.GamePaused: ActiveState = GamePaused.GetInstance(); break; case GameStateType.GameRunning: ActiveState = GameRunning.GetInstance(); break; } }
public void SwitchingState() { stateMachine.SwitchState(GameStateType.GamePaused); Assert.True(stateMachine.ActiveState == GamePaused.GetInstance()); stateMachine.SwitchState(GameStateType.ChooseLevel); Assert.True(stateMachine.ActiveState == ChooseLevel.GetInstance()); stateMachine.SwitchState(GameStateType.MainMenu); Assert.True(stateMachine.ActiveState == MainMenu.GetInstance()); GameRunning.NewInstance("the-beach.txt"); stateMachine.SwitchState(GameStateType.GameRunning); Assert.True(stateMachine.ActiveState == GameRunning.GetInstance()); stateMachine.SwitchState(GameStateType.MainMenu); Assert.True(stateMachine.ActiveState == MainMenu.GetInstance()); GameRunning.NewInstance("short-n-sweet.txt"); stateMachine.SwitchState(GameStateType.GameRunning); Assert.True(stateMachine.ActiveState == GameRunning.GetInstance()); }
public void IterateShots() { foreach (var shot in playerShots) { shot.Shape.Move(); if (shot.Shape.Position.Y > 1.0f) { shot.DeleteEntity(); } foreach (var enemyIter in GameRunning.GetInstance(this).enemies) { var collisionData = CollisionDetection.Aabb(shot.shape.AsDynamicShape(), enemyIter.shape); if (collisionData.Collision) { shot.DeleteEntity(); enemyIter.DeleteEntity(); GameRunning.GetInstance(this).AddExplosion(enemyIter.shape.Position.X, enemyIter.shape.Position.Y, shot.shape.Extent.X + 0.1f, shot.shape.Extent.Y + 0.1f); GameRunning.GetInstance(this).score.AddPoint(); } } } foreach (Enemy enem in GameRunning.GetInstance(this).enemies) { if (!enem.IsDeleted()) { GameRunning.GetInstance(this).newEnemies.Add(enem); } } foreach (PlayerShot elem in playerShots) { if (!elem.IsDeleted()) { newPlayerShots.Add(elem); } } }
public void CustomerCollision() { GameRunning.instance = null; GameRunning.GetInstance(game, null); // GameRunning.instance.player.thrust = new Vec2F(-0.00001f, 0f); //sets a convenient start position for player GameRunning.instance.player.Entity.Shape.SetPosition(new Vec2F(0.3f , GameRunning.instance.player.Entity.Shape.Position.Y - 0.1f)); // // changes currentVelocity to "move" player GameRunning.instance.currentVelocity = new Vec2F(0f, -0.002f); // mock game loop while (!GameRunning.instance.currentLevel.cusList[0].entity.IsDeleted()) { GameRunning.instance.UpdateGameLogic(); GameRunning.instance.RenderState(); } Assert.IsTrue(GameRunning.instance.currentLevel.cusList[0].entity.IsDeleted()); }
public void InitiateGame() { game = new Game(); gameR = GameRunning.GetInstance(game, null); stateMachine = new StateMachine(game); }
public void CustomerDropOff() { GameRunning.instance = null; GameRunning.GetInstance(game, null); // GameRunning.instance.player.thrust.Y = 0f; //sets a convenient start position for player GameRunning.instance.player.Entity.Shape.SetPosition(new Vec2F(0.3f , 0.25f)); GameRunning.instance.gravity = new Vec2F(0f, -0.0000003f); SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); // game.GameLoop(); while (SingletonScore.Instance.score == 0) { if (GameRunning.instance != null) { if (GameRunning.instance.player.shape.Position.Y < 0.1) { GameRunning.instance.player.SetPosition(0.5f, 0.7f); GameRunning.instance.player.thrust.Y = 0.00001f; } } if (GameRunning.instance != null) { if (GameRunning.instance.currentLevel.levelName.Equals("the-beach.txt") && GameRunning.instance.player.shape.Position.Y < 0.8f) { GameRunning.instance.player.SetPosition(0.1f, 0.84f); GameRunning.instance.player.thrust.Y = 0.000001f; } } game.gameTimer.MeasureTime(); while (game.gameTimer.ShouldUpdate()) { SpaceTaxiBus.GetBus().ProcessEvents(); game.win.PollEvents(); game.eventBus.ProcessEvents(); game.stateMachine.ActiveState.UpdateGameLogic(); } if (game.gameTimer.ShouldRender()) { game.win.Clear(); game.backGroundImage.RenderEntity(); game.stateMachine.ActiveState.RenderState(); game.win.SwapBuffers(); } if (game.gameTimer.ShouldReset()) { // 1 second has passed - display last captured ups and fps from the timer // win.Title = "Space Taxi | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + // gameTimer.CapturedFrames; } } Assert.AreEqual(100, SingletonScore.Instance.score); }
public void Initialize() { game = new Game(); GameRunning.GetInstance(game, null); }