protected override void Update(GameTime gameTime) { //Console.Log(IsLoaded); if (!GameContent.IsLoaded) { //Console.Log("loading"); base.Update(gameTime); return; } //Update KeyboardController for Commands keyboard.Update(); Input.GetState(); // Game implemented using Entity-Component-System, // Systems store instances of certain types of Components TransformSystem.Update(gameTime); BehaviorScriptSystem.Update(gameTime); ColliderSystem.Update(gameTime); ColliderSystem.Check(); SpriteSystem.Update(gameTime); TextSystem.Update(gameTime); //Sound.Update(gameTime); 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 (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.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); }