Esempio n. 1
0
        /// <summary>
        /// Constructs a new projectile.
        /// </summary>
        public Projectile(ParticleSystem explosionParticles,
                          ParticleSystem explosionSmokeParticles,
                          ParticleSystem projectileTrailParticles)
        {
            this.explosionParticles = explosionParticles;
            this.explosionSmokeParticles = explosionSmokeParticles;

            // Start at the origin, firing in a random (but roughly upward) direction.
            position = Vector3.Zero;

            velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;
            velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange;
            velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;

            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(projectileTrailParticles,
                                               trailParticlesPerSecond, position);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new projectile.
        /// </summary>
        public Projectile(ParticleSystem explosionParticles,
                          ParticleSystem explosionSmokeParticles,
                          ParticleSystem projectileTrailParticles,
                          Vector3 startPosition)
        {
            this.explosionParticles = explosionParticles;
            this.explosionSmokeParticles = explosionSmokeParticles;

            // Start at the origin, firing in a random (but roughly upward) direction.
            position = startPosition;//new Vector3((0-startPosition.X/2)/4, ((-startPosition.Y)/2)/4, 0);//Vector3.Zero;
            velocity = new Vector3();
            velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;
            velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange+40;
            velocity.Z = 0;// (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;
            projectileLifespan = (float)random.NextDouble() * (projectileMaxLifespan - projectileMinLifespan) + projectileMinLifespan;
            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(projectileTrailParticles,
                                               trailParticlesPerSecond, position);
            age = 0;
        }
 public void Update(float elapsedTime)
 {
     Bomb position = this;
     position.Position = position.Position + (this.Velocity * elapsedTime);
     this.WorldMatrix = Matrix.CreateTranslation(this.Position) * Matrix.CreateRotationZ(this.facing);
     this.planetRadius = this.TargetPlanet.SO.WorldBoundingSphere.Radius ;
     if (this.TargetPlanet.ShieldStrengthCurrent > 0f)
     {
         if (Vector3.Distance(this.Position, new Vector3(this.TargetPlanet.Position, 2500f )) < this.planetRadius + 100f)
         {
             this.DoImpact();
         }
     }
     else if (Vector3.Distance(this.Position, new Vector3(this.TargetPlanet.Position, 2500f )) < this.planetRadius  + 30f)
     {
         this.DoImpact();
     }
     if (Vector3.Distance(this.Position, new Vector3(this.TargetPlanet.Position, 2500f )) < this.planetRadius + 1000f)
     {
         if (this.trailEmitter == null)
         {
             Bomb velocity = this;
             velocity.Velocity = velocity.Velocity * 0.65f;
             this.trailEmitter = new ParticleEmitter(Bomb.screen.projectileTrailParticles, 500f, this.Position);
             this.firetrailEmitter = new ParticleEmitter(Bomb.screen.fireTrailParticles, 500f, this.Position);
         }
         if (this.trailEmitter != null)
         {
             this.firetrailEmitter.Update(elapsedTime, this.Position);
             this.trailEmitter.Update(elapsedTime, this.Position);
         }
     }
 }
 public void UpdateEveryFrame(float elapsedTime, float cos, float sin, float tan)
 {
     this.Move(elapsedTime, cos, sin, tan);
     if (this.Parent.percent >= 0.5 || base.Health >= 0.25 * this.HealthMax)
     {
         this.reallyFuckedUp = false;
     }
     else
     {
         this.reallyFuckedUp = true;
     }
     if (this.Parent.InFrustum && Ship.universeScreen.viewState <= UniverseScreen.UnivScreenState.SystemView)
     {
         if (this.Active && this.onFire && this.trailEmitter == null && this.firetrailEmitter == null)
         {
             this.trailEmitter = new ParticleEmitter(ShipModule.universeScreen.projectileTrailParticles, 50f, this.Center3D);
             this.firetrailEmitter = new ParticleEmitter(ShipModule.universeScreen.fireTrailParticles, 60f, this.Center3D);
             this.flameEmitter = new ParticleEmitter(ShipModule.universeScreen.flameParticles, 50f, this.Center3D);
         }
         if (this.trailEmitter != null && this.reallyFuckedUp && this.Active)
         {
             this.trailEmitter.Update(elapsedTime, this.Center3D);
             this.flameEmitter.Update(elapsedTime, this.Center3D);
         }
         else if (this.trailEmitter != null && this.onFire && this.Active)
         {
             this.trailEmitter.Update(elapsedTime, this.Center3D);
             this.firetrailEmitter.Update(elapsedTime, this.Center3D);
         }
         else if (!this.Active && this.trailEmitter != null)
         {
             this.trailEmitter = null;
             this.firetrailEmitter = null;
         }
     }
     base.Rotation = this.Parent.Rotation;
 }
 public void Move(float elapsedTime, float cos, float sin, float tan)
 {
     GlobalStats.ModulesMoved = GlobalStats.ModulesMoved + 1;
     Vector2 actualVector = this.XMLPosition;
     actualVector.X = actualVector.X - 256f;
     actualVector.Y = actualVector.Y - 256f;
     this.Center.X = actualVector.X * cos - actualVector.Y * sin;
     this.Center.Y = actualVector.X * sin + actualVector.Y * cos;
     ShipModule center = this;
     center.Center = center.Center + this.Parent.Center;
     float num = 256f - this.XMLPosition.X;
     this.Center3D.X = this.Center.X;
     this.Center3D.Y = this.Center.Y;
     this.Center3D.Z = tan * num;
     if (this.Parent.dying)
     {
         if (this.trailEmitter == null && this.firetrailEmitter == null && this.reallyFuckedUp)
         {
             this.trailEmitter = new ParticleEmitter(ShipModule.universeScreen.projectileTrailParticles, 50f, this.Center3D);
             this.firetrailEmitter = new ParticleEmitter(ShipModule.universeScreen.fireTrailParticles, 60f, this.Center3D);
             this.flameEmitter = new ParticleEmitter(ShipModule.universeScreen.flameParticles, 80f, this.Center3D);
         }
         if (this.trailEmitter != null && this.Active && this.reallyFuckedUp)
         {
             this.trailEmitter.Update(elapsedTime, this.Center3D);
             this.flameEmitter.Update(elapsedTime, this.Center3D);
         }
     }
 }
        public void LoadContent(string texturePath, string modelPath)
        {
            this.texturePath = texturePath;
            this.modelPath = modelPath;
            //if(this.owner.Projectiles.Count <20)
            //if (Ship.universeScreen !=null && HelperFunctions.GetRandomIndex((int)(Ship.universeScreen.Lag *100)) >3 )
            //    return;
            this.ProjSO = new SceneObject(Ship_Game.ResourceManager.ProjectileMeshDict[modelPath])
            {
                Visibility = ObjectVisibility.Rendered,
                ObjectType = ObjectType.Dynamic
            };
            if (Projectile.universeScreen != null && this.ProjSO !=null)
            {
                if (this.weapon.WeaponEffectType == "RocketTrail")
                {
                    this.trailEmitter = new ParticleEmitter(Projectile.universeScreen.projectileTrailParticles, 500f, new Vector3(this.Center, -this.zStart));
                    this.firetrailEmitter = new ParticleEmitter(Projectile.universeScreen.fireTrailParticles, 500f, new Vector3(this.Center, -this.zStart));
                }
                if (this.weapon.WeaponEffectType == "Plasma")
                {
                    this.firetrailEmitter = new ParticleEmitter(Projectile.universeScreen.flameParticles, 500f, new Vector3(this.Center, 0f));
                }
                if (this.weapon.WeaponEffectType == "SmokeTrail")
                {
                    this.trailEmitter = new ParticleEmitter(Projectile.universeScreen.projectileTrailParticles, 500f, new Vector3(this.Center, -this.zStart));
                }
                if (this.weapon.WeaponEffectType == "MuzzleSmoke")
                {
                    this.firetrailEmitter = new ParticleEmitter(Projectile.universeScreen.projectileTrailParticles, 1000f, new Vector3(this.Center, 0f));
                }
                if (this.weapon.WeaponEffectType == "MuzzleSmokeFire")
                {
                    this.firetrailEmitter = new ParticleEmitter(Projectile.universeScreen.projectileTrailParticles, 1000f, new Vector3(this.Center, 0f));
                    this.trailEmitter = new ParticleEmitter(Projectile.universeScreen.fireTrailParticles, 750f, new Vector3(this.Center, -this.zStart));
                }
                if (this.weapon.WeaponEffectType == "FullSmokeMuzzleFire")
                {
                    this.trailEmitter = new ParticleEmitter(Projectile.universeScreen.projectileTrailParticles, 500f, new Vector3(this.Center, -this.zStart));
                    this.firetrailEmitter = new ParticleEmitter(Projectile.universeScreen.fireTrailParticles, 500f, new Vector3(this.Center, -this.zStart));
                }

            }
            if (this.weapon.Animated == 1 && this.ProjSO !=null)
            {
                string remainder = this.AnimationFrame.ToString(this.fmt);
                this.texturePath = string.Concat(this.weapon.AnimationPath, remainder);
            }
        }
 public void LoadContent(ContentManager Content)
 {
     Model junk;
     ModelMesh mesh;
     SpaceJunk spaceJunk;
     this.spinx = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.spiny = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.spinz = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.Xrotate = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.Yrotate = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.Zrotate = RandomMath2.RandomBetween(0.01f, 1.02f);
     this.scale = RandomMath2.RandomBetween(0.5f, 1f);
     int random = (int)RandomMath2.RandomBetween(1f, 13f);
     this.Xvel = RandomMath2.RandomBetween(-2f, 2f);
     this.Yvel = RandomMath2.RandomBetween(-2f, 2f);
     this.Zvel = RandomMath2.RandomBetween(-2f, 2f);
     switch (random)
     {
         case 6:
         {
             this.Xvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.Yvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.spinx = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spiny = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spinz = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.scale = RandomMath2.RandomBetween(0.3f, 0.8f);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 7:
         {
             this.Xvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.Yvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.spinx = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spiny = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spinz = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.scale = RandomMath2.RandomBetween(0.3f, 0.8f);
             this.trailEmitter = new ParticleEmitter(SpaceJunk.universeScreen.fireParticles, 200f, this.Position);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 8:
         {
             this.Xvel = RandomMath2.RandomBetween(-5f, 5f);
             this.Yvel = RandomMath2.RandomBetween(-5f, 5f);
             this.Zvel = RandomMath2.RandomBetween(-5f, 5f);
             this.spinx = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.spiny = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.spinz = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.scale = RandomMath2.RandomBetween(0.7f, 1f);
             this.Duration = 10f;
             this.trailEmitter = new ParticleEmitter(SpaceJunk.universeScreen.projectileTrailParticles, 200f, this.Position);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 9:
         case 10:
         {
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 11:
         {
             this.Xvel = RandomMath2.RandomBetween(-5f, 5f);
             this.Yvel = RandomMath2.RandomBetween(-5f, 5f);
             this.Zvel = RandomMath2.RandomBetween(-5f, 5f);
             this.spinx = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.spiny = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.spinz = RandomMath2.RandomBetween(0.5f, 3.5f);
             this.scale = RandomMath2.RandomBetween(0.3f, 0.8f);
             this.Duration = 10f;
             this.trailEmitter = new ParticleEmitter(SpaceJunk.universeScreen.fireTrailParticles, 200f, this.Position);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 12:
         {
             this.Xvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.Yvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.Zvel = RandomMath2.RandomBetween(-5f, 5f);
             this.spinx = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spiny = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spinz = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.scale = RandomMath2.RandomBetween(0.3f, 0.8f);
             this.trailEmitter = new ParticleEmitter(SpaceJunk.universeScreen.projectileTrailParticles, 200f, this.Position);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         case 13:
         {
             this.Xvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.Yvel = RandomMath2.RandomBetween(-2.5f, 2.5f);
             this.spinx = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spiny = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.spinz = RandomMath2.RandomBetween(0.01f, 0.5f);
             this.scale = RandomMath2.RandomBetween(0.3f, 0.8f);
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
         default:
         {
             spaceJunk = this;
             spaceJunk.scale = spaceJunk.scale * 0.5f;
             junk = Ship_Game.ResourceManager.JunkModels[random];
             mesh = junk.Meshes[0];
             this.JunkSO = new SceneObject(mesh)
             {
                 ObjectType = ObjectType.Dynamic,
                 Visibility = ObjectVisibility.Rendered,
                 World = Matrix.CreateTranslation(-1000000f, -1000000f, 0f)
             };
             return;
         }
     }
 }