/// <summary> /// Cretes a new projectile /// </summary> /// <param name="game">Instance of the game</param> /// <param name="player">Which player it came from</param> /// <param name="position">The start position</param> /// <param name="velocity">The start velocity</param> /// <param name="angle">The direction its facing</param> /// <param name="time">The time the projectile was fired</param> public Projectile(Game game, PlayerIndex player, Vector3 position, Vector3 velocity, float angle, TimeSpan time, Particles particles) : base(game) { this.player = player; this.velocity = velocity; this.position = position; projectileCount[(int)player]++; if (SpacewarGame.GameState == GameState.PlayEvolved) { projectileType = (int)SpacewarGame.Players[(int)player].ProjectileType; this.particles = particles; endTime = time.TotalSeconds + SpacewarGame.Settings.Weapons[projectileType].Lifetime; thrust = Vector3.Multiply(Vector3.Normalize(velocity), SpacewarGame.Settings.Weapons[projectileType].Acceleration); radius = 2; damage = SpacewarGame.Settings.Weapons[projectileType].Damage; if (SpacewarGame.GameState == GameState.PlayEvolved) { shape = new BasicEffectShape(GameInstance, BasicEffectShapes.Projectile, projectileType, LightingType.InGame); //Evolved needs scaling scale.X = scale.Y = scale.Z = SpacewarGame.Settings.BulletScale; rotation.X = MathHelper.ToRadians(90); rotation.Y = 0; rotation.Z = (float)angle; } } else { //Build up a retro weapon damage = 5; //One shot kill projectileType = (int)ProjectileType.Peashooter; radius = 1; endTime = time.TotalSeconds + 2.0; acceleration = Vector3.Zero; } //Play 'shoot' sound switch (projectileType) { case (int)ProjectileType.Peashooter: Sound.PlayCue(Sounds.PeashooterFire); break; case (int)ProjectileType.MachineGun: Sound.PlayCue(Sounds.MachineGunFire); break; case (int)ProjectileType.DoubleMachineGun: Sound.PlayCue(Sounds.DoubleMachineGunFire); break; case (int)ProjectileType.Rocket: Sound.PlayCue(Sounds.RocketExplode); break; case (int)ProjectileType.BFG: Sound.PlayCue(Sounds.BFGFire); break; } }
public override Shape Copy() { BasicEffectShape retn = new BasicEffectShape(this.GameInstance, this.shape, this.shapeNumber, LightingType.InGame); retn.position = new Vector3(this.position.X, this.position.Y, this.position.Z); retn.model = this.model; retn.material = this.material; retn.buffer = this.buffer; retn.deviceCreated = this.deviceCreated; retn.modelNames = this.modelNames; retn.player = this.player; retn.scene = this.scene; retn.texture = this.texture; retn.textureNames = this.textureNames; retn.vertexDecl = this.vertexDecl; retn.world = this.world; return retn; }