//Game Logic Stuff public void Update(float deltaTime) { velZeroSystem.Update(deltaTime); timerSystem.Update(deltaTime); moveSystem.Update(deltaTime); bkgPosSystem.Update(deltaTime); pushSystem.Update(deltaTime); movPlatSystem.Update(deltaTime); scrEdgeSystem.Update(deltaTime); playerSystem.Update(deltaTime); visSystem.Update(deltaTime); grapSystem.Update(deltaTime); timedShooterSystem.Update(deltaTime); spSystem.Update(deltaTime); weapSystem.Update(deltaTime); colSystem.Update(deltaTime); gravSystem.Update(deltaTime); drawSystem.Update(deltaTime); healthSystem.Update(deltaTime); animSystem.Update(deltaTime); squishSystem.Update(deltaTime); slSystem.Update(deltaTime); switchSystem.Update(deltaTime); simpEnemySystem.Update(deltaTime); smushSystem.Update(deltaTime); signSystem.Update(deltaTime); debugSystem.Update(deltaTime); inputSystem.Update(deltaTime); }
//ecs void UpdateLogic(float deltaTime) { //按时间间隔改变数据的系统需要放在创建entity的系统的前面,因为entity被创建出来的 // 这一帧并没有“经过一段时间”,不需要改变数据 //_pathFindingSystem.Update(deltaTime); _movementSystem.Update(deltaTime); }
//Game Logic Stuff public void Update(float deltaTime) { moveSystem.Update(deltaTime); colSystem.Update(deltaTime); drawSystem.Update(deltaTime); inputManSystem.Update(deltaTime); inputSystem.Update(deltaTime); protEntSystem.Update(deltaTime); }
public void UpdateMovesPlayerToNextFloorIfPlayerStandsAboveStairsDownAndShiftDotKeysAreDown(Keys shiftKey) { // Arrange const int StairsX = 3; const int StairsY = 3; var player = new Entity(); player.Set(new MoveToKeyboardComponent(player)); var system = new MovementSystem(player); var map = new ArrayMap <AbstractMapTile>(5, 5); for (var y = 0; y < map.Height; y++) { for (var x = 0; x < map.Width; x++) { map[x, y] = new FloorTile(); } } map[StairsX, StairsY] = new StairsDownTile(); EventBus.Instance.Broadcast("Map changed", map); player.Position.X = StairsX; player.Position.Y = StairsY; SadConsole.Global.KeyboardState.KeysDown.Add(AsciiKey.Get(shiftKey)); SadConsole.Global.KeyboardState.KeysDown.Add(AsciiKey.Get(Keys.OemPeriod)); bool usedStairs = false; EventBus.Instance.Register <string>("Player used stairs", (floorNumber) => usedStairs = true); // Act system.Update(0); // Assert Assert.That(usedStairs, Is.True); }
public void UpdateChangesPlayerPositionIfNewPositionIsWalkable(bool isDestinationWalkable) { // Arrange var player = new Entity(); var system = new MovementSystem(player); player.Set(new MoveToKeyboardComponent(player)); player.Position.X = 3; system.Add(player); player.Position.Y = 3; var playerMoved = false; var map = new ArrayMap <AbstractMapTile>(5, 5); for (var y = 0; y < map.Height; y++) { for (var x = 0; x < map.Width; x++) { map[x, y] = new FloorTile(); } } map[player.Position.X - 1, player.Position.Y].IsWalkable = isDestinationWalkable; SadConsole.Global.KeyboardState.KeysPressed.Add(AsciiKey.Get(Keys.Left)); // Update the map in the movement system EventBus.Instance.Broadcast("Map changed", map); EventBus.Instance.Register <Player>("Player moved", (data) => playerMoved = true); var expectedX = isDestinationWalkable ? player.Position.X - 1 : player.Position.X; // Act system.Update(0); // Assert Assert.That(player.Position.X, Is.EqualTo(expectedX)); // Position changed Assert.That(playerMoved, Is.EqualTo(isDestinationWalkable)); // Event fired (or not) }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (InputHelper.GetInput(PlayerIndex.One).IsPressed(Keys.Escape, Buttons.Back)) { this.Exit(); } float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; switch (GameState) { case GameState.SplashScreen: SplashSystem.Update(elapsedTime); break; case GameState.SignIn: // Requires at least one player to sign in if (Gamer.SignedInGamers.Count == 0) { if (IsActive) { Guide.ShowSignIn(4, false); InputHelper.DisableAll(); } } else { GameState = GameState.SplashScreen; SplashSystem.Load(SplashSystem.SplashType.GameStart); InputHelper.EnableAll(); if (!ContinueNewGameScreen.isConnected) { ContinueNewGameScreen.LoadContent(); ContinueNewGameScreen.isConnected = true; ContinueNewGameScreen.loadGameSaves(); } } break; case GameState.CharacterSelection: // TODO: Update character selection screen SpriteAnimationSystem.Update(elapsedTime); ContinueNewGameScreen.Update(gameTime); break; case GameState.NetworkSetup: NetworkSystem.Update(elapsedTime); break; case GameState.GameMenu: // TODO: Update game menu screen // Game Menu does not pause game! // Update game systems NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); break; case GameState.Gameplay: // Update game systems #if DEBUG if (InputHelper.GetInput(PlayerIndex.One).IsPressed(Keys.OemTilde)) { GameState = DungeonCrawler.GameState.SplashScreen; SplashSystem.Load(Systems.SplashSystem.SplashType.Credits); return; } #endif InputSystem.Update(elapsedTime); NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); WeaponSystem.Update(elapsedTime); SkillSystem.Update(elapsedTime); LevelManager.Update(elapsedTime); CollisionSystem.Update(elapsedTime); HUDSystem.Update(elapsedTime); QuestLogSystem.Update(elapsedTime); SpriteAnimationSystem.Update(elapsedTime); NpcAISystem.Update(elapsedTime); EnemyAISystem.Update(elapsedTime); TextSystem.Update(elapsedTime); EngineeringOffenseSystem.Update(elapsedTime); GarbagemanSystem.Update(elapsedTime); /* * if (pI.Health <= 0) * { * GameState = DungeonCrawler.GameState.SplashScreen; * SplashSystem.Load(Systems.SplashSystem.SplashType.GameOver); * return; * }*/ break; case GameState.Credits: // TODO: Update credits break; case GameState.RoomChange: NetworkSystem.Update(elapsedTime); RoomChangingSystem.Update(elapsedTime); break; } base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (GameState == DungeonCrawler.GameState.SignIn) { // Requires at least one player to sign in if (Gamer.SignedInGamers.Count == 0) { if (IsActive) { Guide.ShowSignIn(4, false); } } else { GameState = GameState.NetworkSetup; } } float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; switch (GameState) { case GameState.SplashScreen: // TODO: Update splash screens break; case GameState.SignIn: // Requires at least one player to sign in if (Gamer.SignedInGamers.Count == 0) { if (IsActive) { Guide.ShowSignIn(4, false); } } else { GameState = GameState.NetworkSetup; } break; case GameState.CharacterSelection: // TODO: Update character selection screen break; case GameState.NetworkSetup: NetworkSystem.Update(elapsedTime); break; case GameState.GameMenu: // TODO: Update game menu screen // Game Menu does not pause game! // Update game systems NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); break; case GameState.Gameplay: // Update game systems InputSystem.Update(elapsedTime); NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); break; case GameState.Credits: // TODO: Update credits break; } base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (GameState == DungeonCrawler.GameState.SignIn) { // Requires at least one player to sign in if (Gamer.SignedInGamers.Count == 0) { if (IsActive) { Guide.ShowSignIn(4, false); } } else { GameState = GameState.CharacterSelection; if (!ContinueNewGameScreen.isConnected) { ContinueNewGameScreen.LoadContent(); ContinueNewGameScreen.isConnected = true; ContinueNewGameScreen.loadGameSaves(); } } } float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; switch (GameState) { case GameState.SplashScreen: // TODO: Update splash screens break; case GameState.SignIn: // Requires at least one player to sign in if (Gamer.SignedInGamers.Count == 0) { if (IsActive) { Guide.ShowSignIn(4, false); } } else { GameState = GameState.CharacterSelection; if (!ContinueNewGameScreen.isConnected) { ContinueNewGameScreen.LoadContent(); ContinueNewGameScreen.isConnected = true; ContinueNewGameScreen.loadGameSaves(); } } break; case GameState.CharacterSelection: // TODO: Update character selection screen SpriteAnimationSystem.Update(elapsedTime); ContinueNewGameScreen.Update(gameTime); break; case GameState.NetworkSetup: NetworkSystem.Update(elapsedTime); break; case GameState.GameMenu: // TODO: Update game menu screen // Game Menu does not pause game! // Update game systems NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); break; case GameState.Gameplay: // Update game systems InputSystem.Update(elapsedTime); NetworkSystem.Update(elapsedTime); MovementSystem.Update(elapsedTime); WeaponSystem.Update(elapsedTime); SkillSystem.Update(elapsedTime); LevelManager.Update(elapsedTime); CollisionSystem.Update(elapsedTime); QuestLogSystem.Update(elapsedTime); SpriteAnimationSystem.Update(elapsedTime); NpcAISystem.Update(elapsedTime); EnemyAISystem.Update(elapsedTime); TextSystem.Update(elapsedTime); GarbagemanSystem.Update(elapsedTime); break; case GameState.Credits: // TODO: Update credits break; case GameState.RoomChange: NetworkSystem.Update(elapsedTime); RoomChangingSystem.Update(elapsedTime); break; } base.Update(gameTime); }