public static void Load()
        {
            TextParticleSystem.Load();
            if (!Loaded)
            {
                ParticleEffect  = AssetManager.Load <Effect>("Effects/ShipGame/ShipParticles");
                ParticleSystems = new BasicParticleSystem[8];

                ParticleSystems[0] = new ShipParticleSystem(2000, 0.6f, 2, "Smoke", 1, 2f);
                ParticleSystems[1] = new FlareSystem(5000, 20, "Flare");
                ParticleSystems[2] = new ShipParticleSystem(2000, 0.1f, 2, "Smoke", 1, 1f);
                ParticleSystems[3] = new FlamingChunkSystem(100);
                ParticleSystems[4] = new ShipParticleSystem(100, 0.25f, 0, "Ring", 0, 2f);
                ParticleSystems[5] = new ShipParticleSystem(2000, 1f, 0, "Spark", 1, 0);
                ParticleSystems[6] = new ShipParticleSystem(50, 4, 0, "Ring", 0.1f, 2f);
                ParticleSystems[7] = new LineParticleSystem(1000, 10);

                for (int i = 0; i < ParticleSystems.Length; i++)
                {
                    ColorParticleSystem.AddLast(ParticleSystems[i]);
                }

                ringSystem = new RingSystem(250, "Ring");

                Loaded = true;
            }
            else
            {
                foreach (BasicParticleSystem system in ParticleSystems)
                {
                    system.Clear();
                }
            }
        }
Exemplo n.º 2
0
        public override void Destroy()
        {
            QuadGrid quad = Parent2DScene.quadGrids.First.Value;

            foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(GetEngagementDistance() * 2)))
            {
                if (o.GetType().IsSubclassOf(typeof(UnitBasic)))
                {
                    UnitBasic s = (UnitBasic)o;
                    if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < GetEngagementDistance())
                    {
                        s.ShutDownTime = Math.Max(s.ShutDownTime, (int)(1000 * UnitLevel));
                    }
                }
            }

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * GetEngagementDistance() * 2, ParticleColor, 30, 5);
            }

            for (int i = 0; i < 2; i++)
            {
                FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), GetEngagementDistance(), 40, 5, 10);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, GetEngagementDistance() * 4, 5);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, GetEngagementDistance() * 1.33f, 4);
            }

            base.Destroy();
        }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 100 + Rand.F() * 100, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 20 + Rand.F() * 40, 2);

            FlareSystem.AddLightning(Position3, ParticleColor2, 10, 20, 3, 5);
            base.Update(gameTime);
        }
Exemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            int Mult = 4;

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, 60 * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (70 + Rand.F() * 70) * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (10 + Rand.F() * 20) * Mult, 2);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (10 + Rand.F() * 20) * Mult, 0);
            FlareSystem.AddLightning(Position3, ParticleColor2, 4, 20, 4, 10);

            SearchTime += gameTime.ElapsedGameTime.Milliseconds;
            if (SearchTime > MaxSearchTime || (AttackTarget != null && !AttackTarget.CanBeTargeted()))
            {
                SearchTime  -= MaxSearchTime;
                AttackTarget = null;
                float BestDistance = SearchDistance;

                QuadGrid quad = Parent2DScene.quadGrids.First.Value;
                foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(SearchDistance * 2)))
                {
                    if (o.GetType().IsSubclassOf(typeof(UnitTurret)))
                    {
                        UnitBasic s = (UnitBasic)o;

                        if (s.CanBeTargeted() && !s.IsAlly(ParentUnit))
                        {
                            float d = Vector2.Distance(Position.get(), o.Position.get());

                            if (d < BestDistance && !o.GetType().Equals(typeof(CrystalWall)))
                            {
                                BestDistance = d;
                                AttackTarget = s;
                            }
                        }
                    }
                }
            }

            if (AttackTarget != null)
            {
                Speed = Logic.ToVector2(Logic.Clerp(Logic.ToAngle(Speed), Logic.ToAngle(AttackTarget.Position.get() - Position.get()),
                                                    TurnSpeed * gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f)) * SpeedL;
            }

            base.Update(gameTime);
        }
Exemplo n.º 5
0
        public FlareSystem(int MaxParticles, int MaxPoints, string TexturePath)
        {
            this.MaxPoints = MaxPoints;
            Points         = new LightningPoint[MaxPoints];
            for (int i = 0; i < MaxPoints; i++)
            {
                Points[i] = new LightningPoint();
            }

            self              = this;
            FlareEffect       = AssetManager.LoadEffect("Effects/ShipGame/ShipFlares");
            ParticleHolder    = (Deferred3DEffect) new Deferred3DEffect().Create(FlareEffect);
            FlareTexture      = AssetManager.Load <Texture2D>("Textures/ShipGame/Particles/" + TexturePath + ParticleManager.Quality.ToString());
            this.MaxParticles = MaxParticles;
            CreateArray();
        }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            int Mult = 4;

            SearchTime += gameTime.ElapsedGameTime.Milliseconds;
            if (SearchTime > MaxSearchTime)
            {
                MaxSearchTime -= SearchTime;

                int EnemyCount = 0;

                QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value;

                foreach (GameObject g in quadGrid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance)))
                {
                    if (g.GetType().IsSubclassOf(typeof(UnitBasic)))
                    {
                        UnitBasic s = (UnitBasic)g;
                        if (Vector2.Distance(Position.get(), s.Position.get()) < BulletExplosionDistance / 8 && !s.IsAlly(ParentUnit) && !s.GetType().IsSubclassOf(typeof(UnitBuilding)) && !s.Dead)
                        {
                            EnemyCount += s.GetUnitWeight();
                        }
                    }
                }
                if (BestEnemyCount > 4 && EnemyCount < BestEnemyCount)
                {
                    Destroy();
                }
                else
                {
                    BestEnemyCount = EnemyCount;
                }
            }

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, 60 * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (70 + Rand.F() * 70) * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (10 + Rand.F() * 20) * Mult, 2);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (10 + Rand.F() * 20) * Mult, 0);
            FlareSystem.AddLightning(Position3, ParticleColor2, 30, 20, 4, 10);

            base.Update(gameTime);
        }
        public override void Destroy()
        {
            int Mult = Big ? 2 : 1;

            Vector3 Position3 = new Vector3(Position.X(), Y, Position.Y());

            for (int i = 0; i < 10; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, ParticleColor, 20 * Mult, 5);
            }

            FlareSystem.AddLightingPoint(Position3, new Vector3(1, 0.25f, 0.25f), new Vector3(0.5f, 0, 0.25f), 5 * Mult, 20 * Mult, 3, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 400 * Mult, 5);
            for (int i = 0; i < 3; i++)
            {
                FlamingChunkSystem.AddParticle(Position3, Rand.V3() / 4, Vector3.Zero, Rand.V3() * Mult, Vector3.Zero, 20 * Mult, 10, ParticleColor.ToVector3(), ParticleColor.ToVector3(), 0, 2);
            }

            base.Destroy();
        }
        public override void BlowUp()
        {
            if (!Dead)
            {
                QuadGrid quad = Parent2DScene.quadGrids.First.Value;
                foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(EffectDistance * 2)))
                {
                    if (o.GetType().IsSubclassOf(typeof(UnitShip)) && Vector2.Distance(Position.get(), o.Position.get()) < EffectDistance)
                    {
                        UnitShip s = (UnitShip)o;
                        if (s.CanBeTargeted())
                        {
                            s.CanDeathSound = false;
                            s.CanCloak      = false;
                            s.Damage(4, 0, Vector2.Zero, this, AttackType.Blue);
                            s.LastDamager   = this;
                            s.StunState     = AttackType.Blue;
                            s.FreezeTime    = StasisTime;
                            s.CanDeathSound = true;
                        }
                    }
                }

                Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());
                for (int i = 0; i < 30; i++)
                {
                    ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance * 3, ParticleColor, 40, 5);
                }

                for (int i = 0; i < 2; i++)
                {
                    FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), MaxEngagementDistance / 10, 40, 5, 10);
                    ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 6, 5);
                    ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 3, 4);
                }
            }
            base.BlowUp();
        }
Exemplo n.º 9
0
        public override void Destroy()
        {
            this.Armed = true;

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 600, ParticleColor, 30, 5);
            }

            for (int i = 0; i < 2; i++)
            {
                FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), 25, 40, 5, 10);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 1200, 5);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 400, 4);
            }

            QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value;

            foreach (GameObject g in quadGrid.Enumerate(Position.get(), new Vector2(WinderMisslesAbility.ExplosionDistance)))
            {
                if (g.GetType().IsSubclassOf(typeof(UnitShip)))
                {
                    UnitShip s = (UnitShip)g;
                    if (Vector2.Distance(Position.get(), s.Position.get()) < WinderMisslesAbility.ExplosionDistance / 4)
                    {
                        s.StunState  = AttackType.White;
                        s.FreezeTime = 1000;
                        s.SetSpeed(Vector2.Normalize(s.Position.get() - Position.get()) * 12 / s.Mass);
                    }
                }
            }

            base.Destroy();
        }
        public override void Update(GameTime gameTime)
        {
            if (!Dead)
            {
                if (ShutDownTime > 0 || VirusTime > 0)
                {
                    ShutDownTime = 0;
                    VirusTime    = 0;
                }
                else
                {
                    SearchTime += gameTime.ElapsedGameTime.Milliseconds;

                    if (SearchTime > PulseSearchTime)
                    {
                        SearchTime -= PulseSearchTime;

                        bool     Found = false;
                        QuadGrid quad  = Parent2DScene.quadGrids.First.Value;

                        foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                        {
                            if (o.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip s = (UnitShip)o;
                                if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance)
                                {
                                    if (s.CanBeTargeted() && s.SnapBounce())
                                    {
                                        s.ShieldDamage = s.ShieldToughness + 1;
                                        s.LastDamager  = this;
                                        s.FreezeTime   = 1000;
                                        s.StunState    = AttackType.Melee;
                                        s.SetSpeed(Vector2.Normalize(s.Position.get() - Position.get()) * 16);
                                    }

                                    PulseSearchTime += (int)(StartingMaxSearchTime / 100f * (1.5f + s.UnitLevel));
                                    Found            = true;
                                }
                            }
                        }

                        if (Found)
                        {
                            SoundManager.Play3DSound("PulseTurretFire",
                                                     new Vector3(Position.X(), Y, Position.Y()),
                                                     0.75f, 800, 2);

                            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());
                            for (int i = 0; i < 30; i++)
                            {
                                ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance / 1000f * 3, ParticleColor, 40, 5);
                            }

                            for (int i = 0; i < 2; i++)
                            {
                                FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), MaxEngagementDistance / 10, 40, 5, 10);
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 6, 5);
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 3, 4);
                            }
                        }
                    }
                }
            }
            base.Update(gameTime);
        }
Exemplo n.º 11
0
        protected override void AI(GameTime gameTime)
        {
            float TargetRevolutionSpeed = 0.01f;

            if (CurrentAttackTarget != null && CurrentAttackTarget.CanBeTargeted() &&
                (Vector2.Distance(Position.get(), CurrentAttackTarget.Position.get()) < GetEngagementDistance() || Commited))
            {
                if (ChargeTime > MaxChargeTime / 2)
                {
                    TargetRevolutionSpeed = 0.1f;
                }

                ChargeTime += gameTime.ElapsedGameTime.Milliseconds;
                float Alpha = ChargeTime / (float)MaxChargeTime;

                Vector3 Position3 = new Vector3(Position.X(), Y, Position.Y());
                ParticleManager.CreateParticle(Position3, Vector3.Zero, LaserColor * Alpha, LaserStartSize + LaserEndSize * Alpha * 8, 1);
                FlareSystem.AddLightning(Position3, LaserColor * Alpha, 40, LaserStartSize + LaserEndSize * Alpha / 4, 3, 15);

                if (!Commited && ChargeTime > CommitTime)
                {
                    Commited       = true;
                    AttackPosition = CurrentAttackTarget.Position.get();
                    AttackPosition = Position.get() + Vector2.Normalize(AttackPosition - Position.get()) * GetEngagementDistance();
                }

                if (CurrentAttackTarget != null)
                {
                    Rotation.set(MathHelper.ToDegrees(Logic.Clerp(Rotation.getAsRadians(), Logic.ToAngle(CurrentAttackTarget.Position.get() - Position.get()), RotationSpeed * gameTime.ElapsedGameTime.Milliseconds * 60.0f / 1000.0f)));
                    RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
                }

                if (ChargeTime > MaxChargeTime)
                {
                    if (Vector2.Distance(AttackPosition, Position.get()) > 0)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, LaserColor, LaserStartSize + LaserEndSize, 0);
                        }

                        if (Shots > 1)
                        {
                            FireShot(Position.get(), AttackPosition, AttackLineWidth);
                            ChargeTime = MaxChargeTime - ShotTime;
                            Shots--;
                        }
                        else
                        {
                            FireShot(Position.get(), AttackPosition, AttackLineWidth);
                            ChargeTime = 0;
                            Shots      = MaxShots;
                            FreezeTime = AttackFreezeTime;
                            Commited   = false;
                        }
                    }
                    else
                    {
                        ChargeTime = 0;
                        Shots      = MaxShots;
                    }
                }

                SearchTime += gameTime.ElapsedGameTime.Milliseconds;
                if (SearchTime > MaxSearchTime)
                {
                    SearchTime -= MaxSearchTime;
                    AISearch(gameTime);
                }
            }
            else
            {
                if (ChargeTime > 0)
                {
                    ChargeTime -= gameTime.ElapsedGameTime.Milliseconds;
                    float Alpha = ChargeTime / MaxChargeTime;
                    ParticleManager.CreateParticle(new Vector3(Position.X(), Y, Position.Y()), Vector3.Zero, LaserColor * Alpha, LaserStartSize + LaserEndSize * Alpha, 1);
                    if (ChargeTime < 0)
                    {
                        ChargeTime = 0;
                    }
                }
                base.AI(gameTime);
            }

            RevolutionSpeed    += (TargetRevolutionSpeed - RevolutionSpeed) * gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * 0.1f;
            RotationOffsetSpeed = new Vector3(0, 0, RevolutionSpeed);
        }
Exemplo n.º 12
0
        public override void Update(GameTime gameTime)
        {
            if (!Dead)
            {
                if (ShutDownTime > 0 || VirusTime > 0)
                {
                    if (ShutDownTime > 0)
                    {
                        ShutDownTime -= gameTime.ElapsedGameTime.Milliseconds * 3;
                    }
                    else
                    {
                        Rotation.set(Rotation.get() + MathHelper.ToRadians(gameTime.ElapsedGameTime.Milliseconds * 20));
                    }
                }
                else
                {
                    SearchTime += gameTime.ElapsedGameTime.Milliseconds;

                    if (SearchTime > SnapSearchTime)
                    {
                        SearchTime -= SnapSearchTime;

                        bool     Found = false;
                        QuadGrid quad  = Parent2DScene.quadGrids.First.Value;

                        foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                        {
                            if (o.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip s = (UnitShip)o;
                                if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance)
                                {
                                    if (s.CanBeTargeted() && s.SnapBounce())
                                    {
                                        s.EMP(this, IsUpdgraded ? 1 : 0);
                                    }
                                    SnapSearchTime += (int)(StartingMaxSearchTime / 20 * (1.5f + s.UnitLevel) / 2f);
                                    Found           = true;
                                }
                            }
                        }

                        if (Found)
                        {
                            SoundManager.Play3DSound("SnapTurretFire",
                                                     new Vector3(Position.X(), Y, Position.Y()),
                                                     0.75f, 800, 2);

                            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());
                            for (int i = 0; i < 30; i++)
                            {
                                ParticleManager.CreateParticle(Position3, Rand.V3() * MaxEngagementDistance / 1000f * 3, ParticleColor, 40, 5);
                            }

                            for (int i = 0; i < 2; i++)
                            {
                                FlareSystem.AddLightingPoint(Position3, new Vector3(0.3f), new Vector3(0, 0, 1), MaxEngagementDistance / 10, 40, 5, 10);
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 6, 5);
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 3, 4);
                            }
                        }
                    }
                }
            }
            base.Update(gameTime);
        }
Exemplo n.º 13
0
 public void Update(int Timer)
 {
     FlareSystem.AddLightning(Position,
                              new Color(Logic.RLerp(MinColor, MaxColor) * (1 - (Timer - StartTime) / (float)LifeTime)),
                              Size, Spread, Lines, LinePop);
 }
        public override void Update(GameTime gameTime)
        {
            if (!BulletHasBounced)
            {
                if (CurrentAttackTarget != null && CurrentAttackTarget.CanBeTargeted())
                {
                    Speed = Vector2.Normalize(CurrentAttackTarget.Position.get() - Position.get()) * Speed.Length();
                }
                else
                {
                    if (CurrentAttackTarget == null)
                    {
                        SearchTime += gameTime.ElapsedGameTime.Milliseconds;
                    }
                    else
                    {
                        SearchTime = MaxSearchTime + 1;
                    }

                    if (SearchTime > MaxSearchTime)
                    {
                        CurrentAttackTarget = null;
                        SearchTime         -= MaxSearchTime;

                        QuadGrid quad         = Parent2DScene.quadGrids.First.Value;
                        float    BestDistance = SearchDistance;

                        foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(SearchDistance)))
                        {
                            if (o.GetType().IsSubclassOf(typeof(UnitBasic)) && !o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                            {
                                float d = Vector2.Distance(Position.get(), o.Position.get());
                                if (d < BestDistance)
                                {
                                    UnitBasic u = (UnitBasic)o;
                                    if (u.CanBeTargeted() && !ParentUnit.IsAlly(u))
                                    {
                                        CurrentAttackTarget = u;
                                        BestDistance        = d;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            float Mult = (TimeAlive - MinCollideTimeAlive) / (LifeTime - MinCollideTimeAlive) * 8;

            if (Mult < 1)
            {
                Mult = 1;
            }
            Mult *= 3;

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            FlareSystem.AddLightning(Position3, ParticleColor2, 10, 70, 3, 6);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, 60 * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (70 + Rand.F() * 70) * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor2, (10 + Rand.F() * 20) * Mult, 2);
            base.Update(gameTime);
        }