public override void Update(GameTime gameTime)
        {
            SearchTime += gameTime.ElapsedGameTime.Milliseconds;
            if (SearchTime > MaxSearchTime)
            {
                SearchTime -= MaxSearchTime;

                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.ShieldDamage < s.ShieldToughness)
                        {
                            s.ShieldFlash(1);
                        }

                        s.ShieldDamage += 10000;
                    }
                }
            }

            base.Update(gameTime);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            float PreviousShieldDamage = Math.Min(ShieldDamage, ShieldToughness);
            float PreviousHullDamage   = Math.Min(HullDamage, HullToughness);

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);

            float DamageAmount = (Math.Min(ShieldDamage, ShieldToughness) - PreviousShieldDamage) + (Math.Min(HullDamage, HullToughness) - PreviousHullDamage);

            if (DamageAmount > 0)
            {
                if (DamageAmount > 0.25f)
                {
                    TextParticleSystem.AddParticle(new Vector3(Position.X(), Y, Position.Y()), ((int)(DamageAmount * 4)).ToString(), (byte)Damager.GetTeam());
                }

                if (Damager.GetType().IsSubclassOf(typeof(UnitShip)))
                {
                    UnitShip s = (UnitShip)Damager;
                    //if (s.IsGhostMode)
                    //  return;
                }

                if (Damager.GetTeam() == NeutralManager.NeutralTeam)
                {
                    FactionManager.AddDamage(DamageAmount * 4);
                }
                else
                {
                    FactionManager.AddDamage(Damager.GetTeam(), DamageAmount * 4);
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (!Dead)
            {
                SearchTime += gameTime.ElapsedGameTime.Milliseconds;
                if (SearchTime > MaxSearchTime)
                {
                    SearchTime -= MaxSearchTime;
                    QuadGrid quad      = Parent2DScene.quadGrids.First.Value;
                    int      UnitCount = 0;

                    foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitShip)) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance)
                        {
                            UnitShip s = (UnitShip)o;

                            if (s.CanBeTargeted() && s.FreezeTime < 1)
                            {
                                UnitCount++;
                            }
                        }
                    }

                    if (UnitCount >= MaxUnitCount)
                    {
                        BlowUp();
                    }
                }
            }
            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            frame.WorldMatrix = WorldMatrix;
            if (UnitCount > 0 && !Dead && WaveFSM.WaveStepState.WeaponsFree)
            {
                UnitDelay += gameTime.ElapsedGameTime.Milliseconds;
                if (UnitDelay > MaxUnitDelay)
                {
                    UnitCount--;
                    UnitDelay -= MaxUnitDelay;

                    UnitShip s = (UnitShip)SpawnCard.GetUnit(FactionNumber);
                    ParentLevel.AddObject(s);
                    s.SetLevel((IsUpdgraded ? 3 : 2) * WaveManager.DifficultyMult, 1);

                    if (GetTeam() == WaveManager.ActiveTeam)
                    {
                        float   Theta     = 0;
                        float   Offset    = 0;
                        Vector3 Position3 = new Vector3(Position.X(), Y, Position.Y());

                        while (!TestFree(Position.get(), Theta, Offset, Size.X()))
                        {
                            Theta += (float)Math.PI / 10f;
                            if (Theta > Math.PI * 2)
                            {
                                Theta  -= (float)Math.PI * 2;
                                Offset += Size.X() / 2;
                            }
                        }

                        Vector2 BestPosition = Position.get() + Logic.ToVector2(Theta) * Offset;

                        s.Position.set(BestPosition);

                        Position3 = new Vector3(BestPosition.X, 0, BestPosition.Y);
                        for (int j = 0; j < 30; j++)
                        {
                            ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
                        }

                        Position3 = new Vector3(Position.X(), 0, Position.Y());
                        ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 5, 4);
                        for (int i = 0; i < 30; i++)
                        {
                            ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
                        }
                    }
                    else
                    {
                        s.Position.set(NeutralManager.GetSpawnPosition());
                    }
                }
            }

            base.Update(gameTime);
        }
示例#5
0
        public virtual void Trigger(PlayerShip p)
        {
            SoundManager.PlaySound("BigBombExplode2", 1, 0, 0);
            SoundManager.DeafTone();

            p.ShakeScreen(2500);
            LinkedListNode <GameObject> CurrentNode = p.ParentScene.Children.First;

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

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

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 4000, 5);

            for (int i = 0; i < 20; i++)
            {
                FlamingChunkSystem.AddParticle(Position3, Rand.V3() * 10, new Vector3(0, -0.25f, 0),
                                               Rand.V3(), Rand.V3() / 10, 40, 30, new Vector3(1, 0.5f, 0.2f), new Vector3(1, 0.1f, 0.2f), 0, 3);
            }

            for (int i = 0; i < 50; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 15, new Color(1, 0.75f, 0.5f), 200, 5);
            }

            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 2000, 4);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 3000, 4);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 4000, 4);

            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 500, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 1000, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 2000, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 3000, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), 4000, 5);

            //ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 500, 7);
            //ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 750, 7);
            //ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 1000, 7);

            while (CurrentNode != null)
            {
                GameObject g = CurrentNode.Value;
                if (g.GetType().IsSubclassOf(typeof(UnitShip)))
                {
                    UnitShip u = (UnitShip)g;
                    u.Damage(100000, 0, Vector2.One, p, AttackType.Explosion);
                    u.Damage(100000, 0, Vector2.One, p, AttackType.Explosion);
                    WaveManager.EndWave();
                }

                CurrentNode = CurrentNode.Next;
            }
        }
        private void SpawnUnit(UnitShip s)
        {
            ParentLevel.AddObject(s);
            s.SetLevel(1, 1);

            PlaceRotationMult += PlaceRotationMultChange;
            if (PlaceRotationMult > 1)
            {
                PlaceRotationMult -= 1;
            }

            s.Position.set(Position.get() + Logic.ToVector2(PlaceRotationMult * PlaceRotation) * (Size.X() + s.Size.X()) / 1.95f);
        }
        private void SummonUnits()
        {
            if (!CanSummon)
            {
                return;
            }

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

            CanSummon   = false;
            HasSummoned = true;

            float Theta  = 0;
            float Offset = Size.X() * 2;

            for (int i = 0; i < SummonCard.GhostCount; i++)
            {
                UnitShip u = (UnitShip)SummonCard.GetUnit(FactionNumber);
                ParentLevel.AddObject(u);

                while (!TestFree(Position.get(), Theta, Offset, Size.X()))
                {
                    Theta += (float)Math.PI / 10f;
                    if (Theta > Math.PI * 2)
                    {
                        Theta  -= (float)Math.PI * 2;
                        Offset += Size.X();
                    }
                }
                Vector2 BestPosition = Logic.ToVector2(Theta) * Offset + Position.get();

                u.SetForGhost();
                u.SetLevel(UnitLevel, 1);
                u.Position.set(BestPosition);

                Position3 = new Vector3(BestPosition.X, 0, BestPosition.Y);
                for (int j = 0; j < 30; j++)
                {
                    ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
                }
            }


            Position3 = new Vector3(Position.X(), 0, Position.Y());
            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 5, 4);
            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
            }
        }
示例#8
0
        private void Activate()
        {
            if (!WaveStepState.WeaponsFree)
            {
                return;
            }

            FactionManager.AddEnergy(ParentShip.FactionNumber, -150);

            Vector3 Position3 = new Vector3(ParentShip.Position.X(), 0, ParentShip.Position.Y());
            float   Theta     = 0;
            float   Offset    = ParentShip.Size.X() * 2;

            FactionManager.Factions[ParentShip.FactionNumber].roundReport.UnitsSpawned += MyCard.GhostCount;

            for (int i = 0; i < MyCard.GhostCount; i++)
            {
                UnitShip u = (UnitShip)MyCard.GetUnit(ParentShip.FactionNumber);
                ParentShip.ParentLevel.AddObject(u);

                while (!ParentShip.TestFree(ParentShip.Position.get(), Theta, Offset, ParentShip.Size.X()))
                {
                    Theta += (float)Math.PI / 10f;
                    if (Theta > Math.PI * 2)
                    {
                        Theta  -= (float)Math.PI * 2;
                        Offset += ParentShip.Size.X();
                    }
                }
                Vector2 BestPosition = Logic.ToVector2(Theta) * Offset + ParentShip.Position.get();

                u.SetForGhost();
                u.Position.set(BestPosition);
                u.SetLevel(WaveManager.CurrentWave / 5f * WaveCard.LevelMult, 1);

                Position3 = new Vector3(BestPosition.X, 0, BestPosition.Y);
                for (int j = 0; j < 30; j++)
                {
                    ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
                }
            }


            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), ParentShip.Size.X() * 5, 4);
            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(1, 0.75f, 0.5f), 20, 5);
            }
        }
示例#9
0
        public override bool Trigger(PlayerShip p)
        {
            Vector3 Position3 = new Vector3(p.Position.X(), 0, p.Position.Y());

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

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 4000, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 400, 7);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 300, 7);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 500, 7);

            for (int i = 0; i < 2; i++)
            {
                FlamingChunkSystem.AddParticle(Position3, Rand.V3() / 1.5f, new Vector3(0, -0.25f, 0),
                                               Rand.V3(), Rand.V3() / 10, 150, 30, new Vector3(0.2f, 0.5f, 1), new Vector3(0.2f, 0.5f, 1), 0, 3);
            }

            ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(0.5f, 0.75f, 1), p.Size.X() * 50, 4);
            for (int i = 0; i < 30; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, new Color(0.5f, 0.75f, 1), 200, 5);
            }


            float MaxDist = 600;

            foreach (GameObject g in p.Parent2DScene.quadGrids.First.Value.Enumerate(p.Position.get(), new Vector2(MaxDist * 2)))
            {
                if (g.GetType().IsSubclassOf(typeof(UnitShip)))
                {
                    UnitShip s = (UnitShip)g;
                    if (Vector2.Distance(p.Position.get(), s.Position.get()) < MaxDist && s.IsAlly(p))
                    {
                        s.InvTime = Math.Max(s.InvTime, (int)(10000));
                    }
                }
            }

            return(true);
        }
        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();
        }
示例#11
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)
        {
            Vector2 StartPosition = Position.get();
            Vector2 EndPosition   = Position.get() + Vector2.Normalize(Speed) * SpearTurretCard.EngagementDistance;

            ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, ParticleColor, 300, 5);
            ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, ParticleColor, 300, 7);
            ParticleManager.CreateParticle(new Vector3(StartPosition.X, 0, StartPosition.Y), Vector3.Zero, ParticleColor, 300, 4);
            for (int i = 0; i < 100; i++)
            {
                ParticleManager.CreateParticle(
                    new Vector3(StartPosition.X, 0, StartPosition.Y) + (new Vector3(EndPosition.X - StartPosition.X, 0, EndPosition.Y - StartPosition.Y) * i / 100),
                    Vector3.Zero, ParticleColor, 150, 5);
            }

            ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, ParticleColor, 300, 5);
            ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, ParticleColor, 300, 7);
            ParticleManager.CreateParticle(new Vector3(EndPosition.X, 0, EndPosition.Y), Vector3.Zero, ParticleColor, 300, 4);

            QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value;

            Vector2 UpperLeftCorner  = Logic.Min(StartPosition, EndPosition) - new Vector2(200);
            Vector2 LowerRightCorner = Logic.Max(StartPosition, EndPosition) + new Vector2(200);

            QuadGridXMin = (int)((UpperLeftCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X);
            QuadGridXMax = (int)((LowerRightCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X);
            QuadGridYMin = (int)((UpperLeftCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y);
            QuadGridYMax = (int)((LowerRightCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y);

            if (QuadGridXMax > quadGrid.CellsX - 1)
            {
                QuadGridXMax = quadGrid.CellsX - 1;
            }
            if (QuadGridXMin > quadGrid.CellsX - 1)
            {
                QuadGridXMin = quadGrid.CellsX - 1;
            }
            if (QuadGridYMax > quadGrid.CellsY - 1)
            {
                QuadGridYMax = quadGrid.CellsY - 1;
            }
            if (QuadGridYMin > quadGrid.CellsY - 1)
            {
                QuadGridYMin = quadGrid.CellsY - 1;
            }
            if (QuadGridXMax < 0)
            {
                QuadGridXMax = 0;
            }
            if (QuadGridXMin < 0)
            {
                QuadGridXMin = 0;
            }
            if (QuadGridYMax < 0)
            {
                QuadGridYMax = 0;
            }
            if (QuadGridYMin < 0)
            {
                QuadGridYMin = 0;
            }

            foreach (Basic2DObject g in quadGrid.Enumerate(QuadGridXMin, QuadGridYMin, QuadGridXMax, QuadGridYMax))
            {
                if (g.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                {
                    BasicShipGameObject s = (BasicShipGameObject)g;
                    if (!s.IsAlly(ParentUnit) && CheckCircle(s, StartPosition, EndPosition, AttackLineWidth))
                    {
                        s = s.ReturnCollision();
                        if (s != null)
                        {
                            if (s.TestTag(UnitTag.Human))
                            {
                                s.Damage(Damage, 5, EndPosition - StartPosition, ParentUnit, AttackType.Blue);
                            }
                            if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip   ship = (UnitShip)s;
                                UnitTurret t    = (UnitTurret)ParentUnit;
                                ship.EMP(ParentUnit, t.IsUpdgraded ? 1 : 0);
                            }
                        }
                    }
                }
            }

            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);
        }
示例#14
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);
        }
示例#15
0
        private void TestCollisions()
        {
            QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value;

            Vector2 UpperLeftCorner  = Vector2.Zero;
            Vector2 LowerRightCorner = Vector2.Zero;

            if (SearchTime < MaxSearchTime)
            {
                UpperLeftCorner  = Logic.Min(PreviousPosition, getPosition());
                LowerRightCorner = Logic.Max(PreviousPosition, getPosition());
            }
            else
            {
                SearchTime       = 0;
                UpperLeftCorner  = Logic.Min(PreviousPosition, getPosition() - BulletDodgeDistance);
                LowerRightCorner = Logic.Max(PreviousPosition, getPosition() + BulletDodgeDistance);
            }

            if (UpperLeftCorner.X < quadGrid.Min.X || UpperLeftCorner.Y < quadGrid.Min.Y ||
                LowerRightCorner.X > quadGrid.Max.X || LowerRightCorner.Y > quadGrid.Max.Y)
            {
                return;
            }

            QuadGridXMin = (int)((UpperLeftCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X);
            QuadGridXMax = (int)((LowerRightCorner.X - quadGrid.Min.X) / quadGrid.CellSize.X);
            QuadGridYMin = (int)((UpperLeftCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y);
            QuadGridYMax = (int)((LowerRightCorner.Y - quadGrid.Min.Y) / quadGrid.CellSize.Y);

            foreach (Basic2DObject g in quadGrid.Enumerate(QuadGridXMin, QuadGridYMin, QuadGridXMax, QuadGridYMax))
            {
                if (g.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                {
                    if (CheckCircle(g))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)g;
                        s = s.ReturnCollision();
                        if (s != null && s.StopsBullet(ParentUnit))
                        {
                            Collide(s);
                            if (Destroyed)
                            {
                                return;
                            }
                        }
                    }
                    else if (g.GetType().IsSubclassOf(typeof(UnitShip)))
                    {
                        float d = Vector2.Distance(getPosition(), g.getPosition());
                        if (d < BulletDodgeDistance.X && d - Speed.Length() / 4 > Vector2.Distance(Position.get() + Speed, g.getPosition()))
                        {
                            UnitShip u = (UnitShip)g;
                            if (u.BulletDodgeDistance > 0 && !u.IsAlly(ParentUnit))
                            {
                                u.SetBulletToDodge(this);
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        public override void BlowUp()
        {
            if (!Dead)
            {
                for (int i = 0; i < 36; i++)
                {
                    Guns[0].FireModes[0].Fire((float)Math.PI * (float)i / 18);
                }

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

                ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 10, 4);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 6, 6);

                float    BulletExplosionDistance = IsUpdgraded ? 300 : 500;
                float    BulletExplosionDamage   = IsUpdgraded ? 0.5f : 1f;
                QuadGrid grid = Parent2DScene.quadGrids.First.Value;

                for (int i = 0; i < 2; i++)
                {
                    bool ActivateDeathSound = true;
                    foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitShip)))
                        {
                            BasicShipGameObject s = (BasicShipGameObject)o;
                            float dist            = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2;

                            if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam())
                            {
                                float DistMult = 1;
                                if (dist > 0)
                                {
                                    DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                                }

                                if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip ship = (UnitShip)s;
                                    ship.CanDeathSound = ActivateDeathSound;
                                }
                                s.Damage(DistMult * BulletExplosionDamage, DistMult,
                                         Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion);

                                if (s.Dead)
                                {
                                    ActivateDeathSound = false;
                                }
                                else if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip ship = (UnitShip)s;
                                    ship.CanDeathSound = true;
                                }
                            }
                        }
                    }
                }
            }

            base.BlowUp();
        }
示例#17
0
        public virtual void Fire(GameTime gameTime)
        {
            if (ReloadTime <= 0)
            {
                bool   CreatedMatrix  = false;
                Matrix RotationMatrix = Matrix.Identity;
                ChargeTime += gameTime.ElapsedGameTime.Milliseconds;
                if (ChargeTime > MaxChargeTime)
                {
                    while (ROF >= MaxROF && ClipSize > 0 && BurstSize > 0 && (Ammo > 0 || Ammo == -100))
                    {
                        Vector3 P = Parent != null ?
                                    new Vector3(Parent.getParent().Position.X(), 0, Parent.getParent().Position.Y()) :
                                    new Vector3(ParentUnit.Position.X(), 0, ParentUnit.Position.Y());

                        SoundManager.Play3DSound(FireSound,
                                                 P,
                                                 FireVolume, FireDistance, FireExponent);


                        ChargeTime = 0;
                        if (!CreatedMatrix)
                        {
                            CreatedMatrix = true;
                            if (Parent != null)
                            {
                                RotationMatrix = Matrix.CreateRotationZ(-Parent.getRotation());
                            }
                            else if (ParentUnit.Guns != null)
                            {
                                RotationMatrix = Matrix.CreateRotationZ(-ParentUnit.Guns[0].getRotation());
                            }
                        }

                        ROF      -= MaxROF;
                        BurstTime = 0;
                        ClipSize--;
                        BurstSize--;
                        if (Ammo > 0)
                        {
                            Ammo--;
                        }

                        for (int i = 0; i < BulletCount; i++)
                        {
                            Bullet b = getBullet();
                            if (Parent != null)
                            {
                                if (Parent.getParent().GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip s = (UnitShip)Parent.getParent();
                                    if (s.IsHuge)
                                    {
                                        b.Big = true;
                                    }
                                }
                                Parent.getParent().ParentLevel.AddObject(b);
                                b.SetShipParent(Parent.getParent());

                                ParentUnit = Parent.getParent();
                                Vector3 P3 = InstanceManager.GetWeaponPosition(ParentUnit.GetIntType(), new Vector3(ParentUnit.Position.X(), ParentUnit.Y, ParentUnit.Position.Y()), ref ParentUnit.RotationMatrix, ParentUnit.WeaponIndexID++, ParentUnit.Size.X());

                                Vector2 P2 = getPositionPattern(i);
                                if (P2 != Vector2.Zero)
                                {
                                    P2 = Vector2.Transform(P2, RotationMatrix);
                                }

                                b.SetPosition(new Vector2(P3.X, P3.Z) + P2, false);
                                b.Y = P3.Y;
                                Vector2 v = BulletSpeed * Logic.ToVector2(Parent.getRotation() + Accuracy - Rand.F() * Accuracy * 2 + getDirectionPattern(i));
                                b.SetSpeed(v);
                            }
                            else
                            {
                                ParentUnit.ParentLevel.AddObject(b);
                                if (ParentUnit.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip s = (UnitShip)ParentUnit;
                                    if (s.IsHuge)
                                    {
                                        b.Big = true;
                                    }
                                }
                                b.SetShipParent(ParentUnit);
                                b.SetPosition(ParentUnit.Position.get() + Vector2.Transform(getPositionPattern(i), RotationMatrix), false);
                                b.SetSpeed(BulletSpeed * Logic.ToVector2(ParentUnit.Guns[0].getRotation() + Accuracy - Rand.F() * Accuracy * 2 + getDirectionPattern(i)));
                            }

                            b.SetAttackType(attackType);
                            b.SetStartingPosition(b.getPosition());
                            b.SetDamage(Damage, PushTime, PushVelocityMult);
                            b.SetModifierFactor(ModifierFactor);
                            b.SetLifeTime(LifeTime);
                            b.SetExplosive(BulletExplosionDistance, BulletExplosionDamage);
                            b.AddTime(ROF);
                        }
                    }
                }
                else
                {
                    CreateChargeParticles(ChargeTime / (float)(MaxChargeTime));
                }
                if (ClipSize <= 0)
                {
                    ReloadTime += gameTime.ElapsedGameTime.Milliseconds;
                }
            }
        }
        public override void BlowUp()
        {
            if (Dead || Lives < 1)
            {
                return;
            }

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

            for (int i = 0; i < 10; i++)
            {
                LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * MaxEngagementDistance, TeamInfo.GetColor(GetTeam()));
            }

            foreach (Faction f in FactionManager.Factions)
            {
                if (MyCard == null)
                {
                    MyCard = (TurretCard)FactionCard.FactionTurretDeck[0];
                }

                if (f.Team != GetTeam())
                {
                    f.roundReport.TurretsKilled++;
                    f.AddEvent(MyCard.Name + " Destroyed", new Color(1, 0.5f, 0.5f), FactionEvent.KillTexture);
                }
                else
                {
                    f.roundReport.TurretsLost++;
                    f.AddEvent(MyCard.Name + " Lost", new Color(1, 0.5f, 0.5f), FactionEvent.LossTexture);
                }
            }

            if (ShouldDeathSound)
            {
                SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume, 1000, 1);
                ShouldDeathSound = false;
            }


            FreezeMult = 0;
            VirusTime  = 0;
            DeathParticles();
            Lives--;

            Dead = true;
            if (MyBustedTurret == null)
            {
                MyBustedTurret = new BustedTurret(this);
                ParentLevel.AddObject(MyBustedTurret);
                MyBustedTurret.SetPosition(getPosition());
            }

            MyBustedTurret.WorldMatrix = WorldMatrix;
            MyBustedTurret.Activate();
            InstanceManager.RemoveChild(this);
            RemoveTag(GameObjectTag._2DSolid);
            RemoveTag(GameObjectTag._2DForward);

            LinkedList <GameObject> GList = Parent2DScene.GetList(GameObjectTag._2DSolid);

            if (GList.Contains(this))
            {
                GList.Remove(this);
            }

            BuildTimer = 0;

            float    BulletExplosionDistance = 200;
            float    BulletExplosionDamage   = 1f;
            QuadGrid grid = Parent2DScene.quadGrids.First.Value;


            for (int i = 0; i < 2; i++)
            {
                bool ActivateDeathSound = true;

                foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance * 2)))
                {
                    if (o.GetType().IsSubclassOf(typeof(UnitShip)))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)o;
                        float dist            = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2;

                        if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam() && s.CanBeTargeted())
                        {
                            float DistMult = 1;
                            if (dist > 0)
                            {
                                DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                            }

                            if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = ActivateDeathSound;
                            }
                            s.Damage(DistMult * BulletExplosionDamage, DistMult, Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion);

                            if (s.Dead)
                            {
                                ActivateDeathSound = false;
                            }
                            else if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = true;
                            }
                        }
                    }
                }
            }

            if (ShieldAlpha > 0)
            {
                ShieldInstancer.Remove(this);
                ShieldAlpha = -1;
            }
        }
        public override void Update(GameTime gameTime)
        {
            SoundInstance = SoundManager.PlayLoopingSound(SoundInstance, "SlowFieldHum",
                                                          new Vector3(Position.X(), Y, Position.Y()), 0.03f, MaxEngagementDistance + 200, 2);

            Size.set(new Vector2(SlowFieldCard.STurretSize - 5 + 10 * Rand.F()));

            Vector2 ProjectedPosition = Position.get() + Rand.NV2() * MaxEngagementDistance;
            Vector3 Position3         = new Vector3(ProjectedPosition.X, Y, ProjectedPosition.Y);

            ParticleManager.CreateParticle(Position3, Rand.V3() * Size.X() * 2, ParticleColor, 40, 5);
            if (!Dead)
            {
                SearchTime += gameTime.ElapsedGameTime.Milliseconds;
                if (SearchTime > MaxSearchTime)
                {
                    bool CanEmp = true;
                    SearchTime -= MaxSearchTime;

                    QuadGrid quad = Parent2DScene.quadGrids.First.Value;

                    foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitBasic)))
                        {
                            UnitBasic s = (UnitBasic)o;
                            if (!s.Dead && !s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance - o.Size.X())
                            {
                                if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip s2 = (UnitShip)s;
                                    if (!s2.Slowed)
                                    {
                                        s2.Slowed        = true;
                                        s2.Acceleration /= 2;
                                        if (s.Weakness == AttackType.Blue)
                                        {
                                            s2.Acceleration /= 2;
                                            if (CanEmp)
                                            {
                                                CanEmp = false;
                                                s2.EMP(this, IsUpdgraded ? 1 : 0);

                                                if (s2.TestTag(UnitTag.Monster))
                                                {
                                                    SearchTime -= MaxSearchTime / 5;
                                                }
                                            }
                                        }
                                        s2.MaxEngagementDistance /= 1.5f;
                                        s2.MinEngagementDistance /= 1.5f;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            base.Update(gameTime);
        }