public void Collision(Player player) { Rectangle bulletCollisionBox; Santa attacker = player as Santa; if (attacker == null) { return; } if (player.CollisionBox.TouchAnywhere(this.CollisionBox)) { player.Health -= 1; } for (int i = 0; i < attacker.BulletFactory.GeneratedBullets.Count; i++) { bulletCollisionBox = new Rectangle(attacker.BulletFactory.GeneratedBullets[i].PositionX, attacker.BulletFactory.GeneratedBullets[i].PositionY, attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Width, attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Height); if (bulletCollisionBox.TouchAnywhere(this.CollisionBox)) { this.Health -= (int)player.Damage; attacker.BulletFactory.GeneratedBullets.Remove(attacker.BulletFactory.GeneratedBullets[i]); } } }
public void PlayerMovement(Player player) { if (Keyboard.GetState().IsKeyDown(Keys.Up)) { player.IsMovingUp = true; } if (Keyboard.GetState().IsKeyDown(Keys.Down)) { player.IsMovingDown = true; } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { player.IsMovingLeft = true; } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { player.IsMovingRight = true; } if (Keyboard.GetState().IsKeyDown(Keys.E)) { player.IsShtrak = true; } if (Keyboard.GetState().IsKeyDown(Keys.Space) && !player.IsAttacking) { player.IsAttacking = true; } }