public Thruster(Ship ship, bool reverseThruster, string soundFilename, float thrusterPower, int engineLength, int exhaustConeDeg, Color exhaustColorMin, Color exhaustColorMax) { this.owner = ship; this.reverseThruster = reverseThruster; this.power = thrusterPower; this.engineLength = engineLength; this.exhaustConeDegRange = exhaustConeDeg; this.particlePixelEmitter = new ParticlePixelEmitter(exhaustColorMin, exhaustColorMax); this.particlePixelEmitter.Emitting = false; this.particlePixelEmitter.Life = -1; // -1 means infinite life. // Particles per 1000 updates... this.particlePixelEmitter.Frequency = Configuration.Ships.Thrusters.Frequency; this.particlePixelEmitter.LifeMin = Configuration.Ships.Thrusters.LifeMin; this.particlePixelEmitter.LifeMax = Configuration.Ships.Thrusters.LifeMax; this.particlePixelEmitter.SpeedMin = Configuration.Ships.Thrusters.SpeedMin; this.particlePixelEmitter.SpeedMax = Configuration.Ships.Thrusters.SpeedMax; this.Add(this.particlePixelEmitter); this.thrusterSound = new Sound(soundFilename); this.thrusterSound.Volume = Configuration.SoundVolume; }
public Cannon(Ship owner, int barrelLength, Surface bulletSurface, float power, TimeSpan cooldown, float muzzleSpeed, int bulletLife) { this.owner = owner; this.bulletSurface = bulletSurface; this.power = power; this.cooldown = cooldown; this.muzzleSpeed = muzzleSpeed; this.bulletLife = bulletLife; this.barrelLength = barrelLength; this.lastFiredTime = DateTime.MinValue; this.bulletCollection = new ParticleCollection(); this.fireSound = new Sound(Configuration.Ships.Cannon.FiringSoundFilename); this.fireSound.Volume = Configuration.SoundVolume; this.dryFireSound = new Sound(Configuration.Ships.Cannon.DryFireSoundFilename); this.dryFireSound.Volume = Configuration.SoundVolume; }
public Player(int number) { this.number = number; // These need to be set later. this.ship = null; this.scoreCard = null; this.leftKey = Key.Unknown; this.rightKey = Key.Unknown; this.upKey = Key.Unknown; this.downKey = Key.Unknown; this.fireKey = Key.Unknown; this.leftKeyIsDown = false; this.rightKeyIsDown = false; this.upKeyIsDown = false; this.downKeyIsDown = false; this.fireKeyWasPressed = false; this.creationEffect = new ShipCreationEffect(); this.explosionEffect = new ShipExplosionEffect(); }
private void Impact(Ship ship1, Ship ship2) { Vector oldShip1Velocity = ship1.Velocity; Vector oldShip2Velocity = ship2.Velocity; Vector newVelocity1 = (oldShip1Velocity * -0.5f) + (oldShip2Velocity * 0.5f); Vector newVelocity2 = (oldShip2Velocity * -0.5f) + (oldShip1Velocity * 0.5f); ship1.Velocity = newVelocity1; ship2.Velocity = newVelocity2; DamageShip(ship1, Configuration.Ships.ShipShipCollisionDamage); DamageShip(ship2, Configuration.Ships.ShipShipCollisionDamage); try { this.shipShipImpactSound.Play(); } catch { // Must be out of sound channels. } }
private void Impact(Ship ship, Planet planet) { Player player = (ship.Player.Number == 1) ? this.player1 : this.player2; this.particleSystem.Particles.Add(player.ExplosionEffect.Explode(ship.Center)); ship.Die(); player.ScoreCard.Suicides++; }
private void Impact(Ship ship, Bullet bullet) { if (bullet.Owner == ship.Player) { // I own this particle, thus it won't hurt me. // Make it bounce. bullet.Velocity *= -1; try { this.bulletShipImpactBounceSound.Play(); } catch { // Must be out of sound channels. } } else { bullet.Life = 0; try { this.bulletShipImpactSound.Play(); } catch { // Must be out of sound channels. } DamageShip(ship, bullet.Power); } }
private Point GetSafeSpawnPosition(Ship ship) { // Choose the corner furthest from the other ship. if (this.player1.Ship == null) return Configuration.Ships.Player1StartingScreenPosition; else if (this.player2.Ship == null) return Configuration.Ships.Player2StartingScreenPosition; Ship otherShip = (ship.Player.Number == 1) ? this.player2.Ship : this.player1.Ship; // Determine spawn point based on current enemy location. double otherShipDistanceFromStartPosition1 = Distance(otherShip.Center, Configuration.Ships.Player1StartingScreenPosition); double otherShipDistanceFromStartPosition2 = Distance(otherShip.Center, Configuration.Ships.Player2StartingScreenPosition); Point startPos = (otherShipDistanceFromStartPosition1 < otherShipDistanceFromStartPosition2) ? Configuration.Ships.Player2StartingScreenPosition : Configuration.Ships.Player1StartingScreenPosition; return startPos; }
private void DamageShip(Ship ship, float points) { ship.Shields -= points; if (ship.Shields <= 0) { ship.Die(); if (ship.Player.Number == 1) { this.player1.ScoreCard.Defeats++; this.player2.ScoreCard.Kills++; this.particleSystem.Particles.Add(this.player1.ExplosionEffect.Explode(this.player1.Ship.Center)); } else { this.player2.ScoreCard.Defeats++; this.player1.ScoreCard.Kills++; this.particleSystem.Particles.Add(this.player2.ExplosionEffect.Explode(this.player2.Ship.Center)); } } }