public void HandleCollision(VoidShip voidShip, Particles particles) { Vector2 dist; Bullet bullet; float distSquared, hitDistSquared = (float)Math.Pow(voidShip.Radius + radius, 2); for (int i = 0; i < Count; i++) { bullet = array[(start + i) & 0x3FF]; if (!bullet.Enabled) { continue; } dist = voidShip.Position - bullet.Position; distSquared = (dist.X * dist.X) + (dist.Y * dist.Y); if (distSquared < hitDistSquared) { bullet.Visible = bullet.Enabled = false; if (voidShip is VoidShipPC) { Sound.Fuzz((voidShip.Shield.Power * 2) - 1f); } if (voidShip.Shield.Power <= bullet.Power) { voidShip.Visible = voidShip.Enabled = false; voidShip.Dead = true; particles.Add(voidShip.Position); } else { voidShip.Shield.Power -= bullet.Power; } } } }
public void Add(VoidShip voidShip) { array[(start + Count) & 0x3FF].Init(voidShip); if (voidShip is VoidShipPC) { Sound.Impulse44((voidShip.Shield.Power * 2) - 1f); } Count++; }
public void Init(VoidShip voidShip) { Power = (voidShip.Weapons.Quality * 0.7f) + 0.3f; position = voidShip.Position; position += voidShip.Weapons.ShotVector * (voidShip.Radius + Radius + 3); velocity = voidShip.Velocity; velocity += voidShip.Weapons.ShotVector * voidShip.Weapons.ShotSpeed; decay = 0.5f * Power * voidShip.Weapons.ShotSpeed / voidShip.Weapons.Range; // half life at range visible = enabled = true; }
public override void Update(GameTime gameTime, Bullets bullets, VoidShip target, Vector2 average, float maxDistanceSquared) { if (target != null) { Weapons.targetRelativePosition = target.Position - position; Weapons.targetRelativePositionSquared = Weapons.targetRelativePosition.LengthSquared(); Weapons.targetRelativeVelocity = target.Velocity - velocity; } else { Weapons.targetRelativePosition = Vector2.Zero; Weapons.targetRelativePositionSquared = 0; Weapons.targetRelativeVelocity = Vector2.Zero; } Thruster.ControlPC(velocity); base.Update(gameTime, bullets); Sound.Thrust = Thruster.Thrust; PositionMatrix = Matrix.CreateTranslation(new Vector3(-Position, 0.0f)); ViewMatrix = PositionMatrix * ScaleOriginMatrix; }