protected override void Update(GameTime gameTime) { GameTime = gameTime; Input.Update(); // Allows the game to exit if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } LoadContent(); EntityManager.Update(); EnemySpawner.Update(); //Background scrolling if (rectangle1.X + background.Width <= 0) { rectangle1.X = rectangle2.X + background.Width; } if (rectangle2.X + background.Width <= 0) { rectangle2.X = rectangle1.X + background.Width; } if (gameState == GameState.MainMenu) { rectangle1.X -= 5; rectangle2.X -= 5; } if (gameState == GameState.LevelOne) { rectangle1.X -= 5; rectangle2.X -= 5; } if (gameState == GameState.LevelTwo) { rectangle1.X -= 10; rectangle2.X -= 10; } // Mouse State with Buttons mouseState = Mouse.GetState(); if (previousMouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == ButtonState.Released) { MouseClicked(mouseState.X, mouseState.Y); } previousMouseState = mouseState; base.Update(gameTime); }
//function for main menu public void UpdateMainMenu(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { _state = GameState.LevelOne; } base.Update(gameTime); EntityManager.Update(); EnemySpawner.Update(); Input.Update(); }
public void Kill() { framesUntilRespawn = 60; // remove a life from the player PlayerStatus.RemoveLife(); // turn on the game over state if the player has 0 lives // reset the enemy spawner EnemySpawner.Reset(); }
void UpdateLevelOne(GameTime deltaTime) { // Respond to user actions in the game . if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } if (ScoreAndLives.Score > 100) { _state = GameState.LevelOneComp; } EntityManager.Update(); EnemySpawner.Update(); }
void UpdateLevelThreeComp(GameTime deltaTime) { if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } if (ScoreAndLives.Score > 1000) { _state = GameState.EndOfGame; } EntityManager.Update(); EnemySpawner.Reset(); WandererSpawn.Reset(); }
protected override void Update(GameTime gameTime) { GameTime = gameTime; Input.Update(); // Allows the game to exit if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } EntityManager.Update(); EnemySpawner.Update(); base.Update(gameTime); }
void UpdateLevelOneComp(GameTime deltaTime) { // Respond to user actions in the game . if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { _state = GameState.LevelTwo; } EntityManager.Update(); EnemySpawner.Update(); }
//function for completed game void UpdateGameCompl(GameTime gameTime) { if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.Space)) { _state = GameState.MainMenu; PlayerStatus.Reset(); } base.Update(gameTime); EntityManager.Update(); EnemySpawner.Update(); Input.Update(); }
//function for level 2 void UpdateLevelTwo(GameTime gameTime) { if (PlayerStatus.Score > 250) { _state = GameState.FinalLevel; } if (PlayerStatus.Lives <= 0) { _state = GameState.EndGame; PlayerStatus.Reset(); } Input.Update(); EntityManager.Update(); EnemySpawner.Update2(); base.Update(gameTime); }
//function for level 1 public void UpdateLevelOne(GameTime gameTime) { if (PlayerStatus.Score > 75) { _state = GameState.LevelTwo; } if (PlayerStatus.Lives <= 0) { _state = GameState.EndGame; PlayerStatus.Reset(); } Input.Update(); EntityManager.Update(); EnemySpawner.Update(); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { GameTime = gameTime; Input.Update(); // Allows the game to exit if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } if (GameSessionStats.NumberOfLives == 0) { GameRoot.ResetGameSession(); } EntityManager.Update(); EnemySpawner.Update(); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { GameTime = gameTime; Input.Update(); // Allows the game to exit if (Input.WasButtonPressed(Buttons.Back) || Input.WasKeyPressed(Keys.Escape)) { this.Exit(); } EntityManager.Update(); EnemySpawner.Update(); powerUpBar.Update(); float timeElapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; dungeonBackG.Update(timeElapsed * 200); base.Update(gameTime); }
public void Kill() { Lives--; if (Lives == 0) { IsOver = true; } Health = HealthMax; EntityManager.enemies.ForEach(x => x.IsExpired = true); EntityManager.enemybullets.ForEach(x => x.IsExpired = true); EntityManager.enemymissiles.ForEach(x => x.IsExpired = true); EntityManager.playerbullets.ForEach(x => x.IsExpired = true); EntityManager.bossentities.ForEach(x => x.IsExpired = true); EntityManager.pickups.ForEach(x => x.IsExpired = true); EnemySpawner.Reset(); framesUntilRespawn = 60; Position = new Vector2(GameRoot.ScreenSize.X / 2, GameRoot.ScreenSize.Y / 2); Exp = 0; }
static void HandleCollisions() { // handle collisions between enemies for (int i = 0; i < enemies.Count; i++) { for (int j = i + 1; j < enemies.Count; j++) { if (IsColliding(enemies[i], enemies[j])) { enemies[i].HandleCollision(enemies[j]); enemies[j].HandleCollision(enemies[i]); } } } // handle collisions between bullets and enemies for (int i = 0; i < enemies.Count; i++) { for (int j = 0; j < bullets.Count; j++) { if (IsColliding(enemies[i], bullets[j])) { enemies[i].WasShot(); bullets[j].IsExpired = true; } } } // handle collisions between the player and enemies for (int i = 0; i < enemies.Count; i++) { if (enemies[i].IsActive && IsColliding(PlayerShip.Instance, enemies[i]) && PlayerShip.Instance.invincibility == false) { PlayerShip.Instance.Kill(); enemies.ForEach(x => x.WasCrashedInto()); EnemySpawner.Reset(); break; } } }
void UpdateLevelTwo(GameTime gameTime) { EntityManager.Update(); EnemySpawner.Update(2); if (PlayerShip.Instance.IsOver == true) { _state = GameState.GameOver; } if (PlayerShip.Level == 10) { EntityManager.enemies.ForEach(x => x.IsExpired = true); EntityManager.enemybullets.ForEach(x => x.IsExpired = true); EntityManager.playerbullets.ForEach(x => x.IsExpired = true); EntityManager.bossentities.ForEach(x => x.IsExpired = true); EntityManager.pickups.ForEach(x => x.IsExpired = true); EnemySpawner.Reset(); titleisdone = false; title_screen_length = 50; PlayerShip.Health = PlayerShip.HealthMax; _state = GameState.BossLevel; } }
void UpdateBossLevel(GameTime gameTime) { EntityManager.Update(); EnemySpawner.Update(3); if (start == false) { start = true; PlayerShip.Instance.Position = new Vector2(100, ScreenSize.Y / 2); } if (PlayerShip.Instance.IsOver == true) { EntityManager.enemybullets.ForEach(x => x.IsExpired = true); EntityManager.playerbullets.ForEach(x => x.IsExpired = true); EntityManager.bossentities.ForEach(x => x.IsExpired = true); start = false; _state = GameState.GameOver; } checkyet--; if (checkyet <= 0) { if (EntityManager.bossentities.Count == 1) { EntityManager.enemybullets.ForEach(x => x.IsExpired = true); EntityManager.playerbullets.ForEach(x => x.IsExpired = true); EntityManager.bossentities.ForEach(x => x.IsExpired = true); start = false; checkyet = 50; _state = GameState.GameComplete; } } if (PlayerShip.Instance.IsDead) { PlayerShip.Instance.Position = new Vector2(100, ScreenSize.Y / 2); } }
static void HandleCollisions() { // handle collisions between enemies if (GameRoot.gameState != GameRoot.GameState.LevelThree) { for (int i = 0; i < enemies.Count; i++) { for (int j = i + 1; j < enemies.Count; j++) { if (IsColliding(enemies[i], enemies[j])) { enemies[i].HandleCollision(enemies[j]); enemies[j].HandleCollision(enemies[i]); } } } } // handle collisions between bullets and enemies for (int i = 0; i < enemies.Count; i++) { for (int j = 0; j < bullets.Count; j++) { if (IsColliding(enemies[i], bullets[j])) { enemies[i].WasShot(); bullets[j].IsExpired = true; Score = Score + 100; } } } for (int i = 0; i < bullets.Count; i++) { if (IsColliding(PlayerShip.Instance, bullets[i])) { PlayerShip.Instance.Kill(); } } for (int i = 0; i < boss.Count; i++) { for (int j = 0; j < bullets.Count; j++) { if (IsColliding(enemies[i], bullets[j])) { enemies[i].WasShot(); bullets[j].IsExpired = true; Score = Score + 100; } } } // handle collisions between the player and enemies for (int i = 0; i < enemies.Count; i++) { if (enemies[i].IsActive && IsColliding(PlayerShip.Instance, enemies[i])) { if (GameRoot.gameState == GameRoot.GameState.LevelOne || GameRoot.gameState == GameRoot.GameState.LevelTwo) { PlayerShip.Instance.Kill(); enemies.ForEach(x => x.WasShot()); EnemySpawner.Reset(); break; } else if (GameRoot.gameState == GameRoot.GameState.LevelThree) { PlayerShip.Instance.Kill(); enemies.ForEach(x => x.WasShot()); break; } } } }
static void HandleCollisions() { for (int i = 0; i < bosses.Count; i++) { if (IsColliding(PlayerShip.Instance, bosses[i])) { PlayerShip.Instance.Kill(); EnemySpawner.Reset(); break; } } // handle collisions between bullets and enemies for (int i = 0; i < bosses.Count; i++) { for (int j = 0; j < bullets.Count; j++) { if (IsColliding(bosses[i], bullets[j])) { bosses[i].WasHit(); bullets[j].IsExpired = true; } } } // handle collisions between enemies for (int i = 0; i < enemies.Count; i++) { for (int j = i + 1; j < enemies.Count; j++) { if (IsColliding(enemies[i], enemies[j])) { enemies[i].HandleCollision(enemies[j]); enemies[j].HandleCollision(enemies[i]); } } } // handle collisions between bullets and enemies for (int i = 0; i < enemies.Count; i++) { for (int j = 0; j < bullets.Count; j++) { if (IsColliding(enemies[i], bullets[j])) { enemies[i].WasShot(); bullets[j].IsExpired = true; } } } for (int i = 0; i < ammo.Count; i++) { if (IsColliding(PlayerShip.Instance, ammo[i])) { PlayerShip.ammoCounter += 20; ammo.Remove(ammo[i]); } } for (int i = 0; i < speed.Count; i++) { if (IsColliding(PlayerShip.Instance, speed[i])) { Speed.speedup = true; speed.Remove(speed[i]); } } // handle collisions between the player and enemies for (int i = 0; i < enemies.Count; i++) { if (enemies[i].IsActive && IsColliding(PlayerShip.Instance, enemies[i])) { PlayerShip.Instance.Kill(); enemies.ForEach(x => x.WasRemoved()); EnemySpawner.Reset(); break; } } }