private void Shoot() { if (reloadTime > SHOOT_DELAY) { BulletEntity bullet = new BulletEntity(Assets.GetRegion("BoulderEntity"), position.X, position.Y, velocity.X + direction.X * SHOOT_SPEED, 0); bullet.Owner = this; Level.AddEntity(bullet); reloadTime = 0; } }
public void ShootCircle() { if (Reloading) return; for (int i = 0; i < 17; i++) { float offset = MathUtils.random(0, .5f); Vector2 direction = new Vector2((float)Math.Cos(i + offset), (float)Math.Sin(i + offset)); direction.Normalize(); BulletEntity bullet = new BulletEntity(Assets.GetRegion("BoulderEntity"), position.X, position.Y, direction.X * SHOOT_SPEED, direction.Y * SHOOT_SPEED); bullet.Owner = this; Level.AddEntity(bullet); } Reloading = true; }
public void ShootAtPlayer() { if (Reloading) return; Vector2 direction = new Vector2(); Vector2 playerPos = Level.GetPlayer().GetPosition(); Vector2.Subtract(ref playerPos, ref position, out direction); direction.Normalize(); float angle = (float)Math.Atan2(direction.Y, direction.X); // Add aim error angle = MathHelper.WrapAngle(angle - (MathUtils.random() % 0.1f)/1f + 0.1f); direction = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)); BulletEntity bullet = new BulletEntity(Assets.GetRegion("BoulderEntity"), position.X, position.Y, direction.X * SHOOT_SPEED * 1.1f, direction.Y * SHOOT_SPEED * 1.1f); bullet.Owner = this; Level.AddEntity(bullet); Reloading = true; }
public void ShootSpray() { if (Reloading) return; for (int i = 0; i < 12; i++) { Vector2 direction = new Vector2((float)Math.Cos(i), (float)Math.Sin(i)); direction.Normalize(); BulletEntity bullet = new BulletEntity(Assets.GetRegion("BoulderEntity"), position.X, position.Y, velocity.X + direction.X * SHOOT_SPEED, direction.Y * SHOOT_SPEED); bullet.Owner = this; Level.AddEntity(bullet); } Reloading = true; }