public void Update(GameTime gameTime, Player player) { //spikes killing player if they interact foreach (var spike in m_Spikes) { if (player.BoundingBox.Intersects(spike.BoundingBox)) { player.position = spawnLocation; } } //loading next room if (player.BoundingBox.Intersects(m_Button.BoundingBox)) { if (LoadNextRoom != null) { LoadNextRoom(new Testing_room5(m_content, m_windowwidth, m_windowheight, player)); } } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(3); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); }
public void Update(GameTime gameTime, Player player) { //updates arrows foreach (var arrow in m_Arrows) { //move the arrows arrow.Move(gameTime); //killing player when they interact if (player.BoundingBox.Intersects(arrow.BoundingBox)) { player.position = player.GenericSPWN; } } //loading next room if (player.BoundingBox.Intersects(m_Button.BoundingBox)) { if (LoadNextRoom != null) { LoadNextRoom(new Testing_room6(m_content, m_windowwidth, m_windowheight, player)); } } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(4); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); }
public void Update(GameTime gameTime, Player player) { //spawing the explosions elapsedSpawnDelayMilliseconds += gameTime.ElapsedGameTime.Milliseconds; if (elapsedSpawnDelayMilliseconds >= TOTAL_SPAWN_DELAY_MILLISECONDS) { // If we do not reset the timer more than one explosion // will spawn at once elapsedSpawnDelayMilliseconds = 0; // add another explosion to the list now m_Explosions.Add(GetRandomExplosion()); // updates the explosions foreach (var explosion in m_Explosions) { //updates the explosion explosion.Update(gameTime); //gives the explosions a textures explosion.Texture = m_sprite; //killing player if they intersect if (player.BoundingBox.Intersects(explosion.BoundingBox)) { player.position = player.GenericSPWN; } } } //loading next room if (player.BoundingBox.Intersects(m_Button.BoundingBox)) { if (LoadNextRoom != null) { LoadNextRoom(new Testing_room8(m_content, m_windowwidth, m_windowheight, player)); } } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(5); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); for (int i = m_Explosions.Count() - 1; i >= 0; i--) { if (m_Explosions[i].Active != true) { m_Explosions.RemoveAt(i); } } }
public void Update(GameTime gameTime, Player player) { //LOADING NEXT ROOM if (m_Bullet.BoundingBox.Intersects(m_Button.BoundingBox)) { if (m_loadNextRoom != null) { m_Button.PlaySound(); m_loadNextRoom(new Testing_room3 (m_content, m_windowwidth, m_windowheight, player)); } } //Gun tracks players position m_Gun.position = new Vector2 (player.position.X + m_Gun.Texture.Width, player.position.Y - m_Gun.Texture.Height / 3); //shooting the bullet if (Keyboard.GetState().IsKeyDown(Keys.Enter) && player.BoundingBox.Intersects(m_Gun.BoundingBox) && !m_Bullet.ToggleBulletMove) { m_Bullet.ShootBullet(m_Gun); } //allows the bullet to move if (m_Bullet.ToggleBulletMove) { m_Bullet.Move(gameTime); } //allows the gun firing sound to play again without looping if (Keyboard.GetState().IsKeyUp(Keys.Enter) && m_Bullet.ToggleBulletMove) { m_Bullet.PlayAgain(); } //moving the button m_Button.Move(gameTime); //stops the player cheating the level if (player.position.Y <= 100) { player.ResetPos(); } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(1); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); m_Bullet.Update(gameTime); }
public void Update(GameTime gameTime, Player player) { //stops the player moving through the textures foreach (var textbox in m_textBoxes) { if (player.BoundingBox.Intersects(textbox.BoundingBox)) { textbox.OnCollision(); player.ResetPos(); } } //Loading player into the next room if they get the answer right if (CorrectAnswer) { if (LoadNextRoom != null) { LoadNextRoom(new Testing_room7(m_content, m_windowwidth, m_windowheight, player)); } } //Moves player two levels back if they get the answer wrong if (WrongAnswer) { if (LoadNextRoom != null) { LoadNextRoom(new Testing_room4(m_content, m_windowwidth, m_windowheight, player)); } } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(5); } //updates the classes m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); }
public void Update(GameTime gameTime, Player player) { //if players bullet interacts with enemy if (m_Bullet.BoundingBox.Intersects(m_Enemy.BoundingBox)) { //enemy takes damage m_Enemy.TakeDMG(); //reset bullet to be fired from gun again m_Bullet.KillBullet(); } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(7); } //enemy tracks players position m_Enemy.Target = player; //allows enemy to move m_Enemy.Move(gameTime); //Gun tracks players position m_Gun.position = new Vector2 (player.position.X + m_Gun.Texture.Width, player.position.Y - m_Gun.Texture.Height / 3); //shooting the bullet if (Keyboard.GetState().IsKeyDown(Keys.Enter) && player.BoundingBox.Intersects(m_Gun.BoundingBox) && !m_Bullet.ToggleBulletMove) { m_Bullet.ShootBullet(m_Gun); } //enemy shooting player if player is under enemy if (player.position.X > m_Enemy.position.X && player.position.X < m_Enemy.position.X + m_Enemy.Texture.Width && !m_EnemyBullet.ToggleBulletMove) { m_EnemyBullet.ShootBullet(m_Enemy); } //allows the gun firing sound to play again without looping if (Keyboard.GetState().IsKeyUp(Keys.Enter) && m_Bullet.ToggleBulletMove) { m_Bullet.PlayAgain(); } //whether or not the bullet is moving on screen if (m_Bullet.ToggleBulletMove) { m_Bullet.Move(gameTime); } //whether or not the enemy bullet is moving if (m_EnemyBullet.ToggleBulletMove) { m_EnemyBullet.Move(gameTime); } //"killing" player if interacts with enemy if (player.BoundingBox.Intersects(m_Enemy.BoundingBox)) { player.position = player.GenericSPWN; } //bullet interacting with player if (m_EnemyBullet.BoundingBox.Intersects(player.BoundingBox)) { //reseting the players position player.position = player.GenericSPWN; //reseting bullet to be shot again m_EnemyBullet.KillBullet(); } //if player interacts with the button, play ending animation if (m_Bullet.BoundingBox.Intersects(m_Button.BoundingBox) && m_Enemy.Health <= 0) { if (LoadNextRoom != null) { LoadNextRoom(new Final_Room(m_content, m_windowwidth, m_windowheight, m_Graphics)); } } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(5); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); m_Bullet.Update(gameTime); m_EnemyBullet.Update(gameTime); m_Enemy.anim_Explode.Update(gameTime); m_Enemy.Update(gameTime); }
public void Update(GameTime gameTime, Player player) { //detects what side the player is coming from and moves box accordingly if (player.BoundingBox.Intersects(m_Box.BoundingBox) && m_Box.velocity == Vector2.Zero) { if (player.velocity.X > 0) { m_Box.velocity.X = 10; } if (player.velocity.X < 0) { m_Box.velocity.X = -10; } if (player.velocity.Y > 0) { m_Box.velocity.Y = 10; } if (player.velocity.Y < 0) { m_Box.velocity.Y = -10; } //stops the player moving player.ResetPos(); } //allows the box to move m_Box.Move(gameTime); //gives the pressure plate a temp bounding box Rectangle plateBox = m_Box.BoundingBox; //expands size of pressure plate to allow for boxes velocity plateBox.Inflate(10, 10); //loading next room if (plateBox.Contains(m_PressurePlate.BoundingBox)) { if (LoadNextRoom != null) { m_Box.velocity = Vector2.Zero; LoadNextRoom(new Testing_room4(m_content, m_windowwidth, m_windowheight, player)); } } //what happens for each rock in the list foreach (var rock in m_Rocks) { //stops the box from moving if (m_Box.BoundingBox.Intersects(rock.BoundingBox)) { m_Box.position -= m_Box.velocity; m_Box.velocity = Vector2.Zero; } //stops the player from moving if (player.BoundingBox.Intersects(rock.BoundingBox)) { player.ResetPos(); } } //player interacting with pressure plate if (player.BoundingBox.Intersects(m_PressurePlate.BoundingBox)) { PlayerTooHeavy = true; } else { PlayerTooHeavy = false; } //Player picking up the newspaper if (player.BoundingBox.Intersects(m_Newspaper.BoundingBox)) { m_Newspaper.PickUpPaper(2); } //updates the newspaper and speech m_Newspaper.Update(gameTime); m_Speech.Update(gameTime); }