public virtual void Virus(int VirusTime)
        {
            if (this.VirusTime < VirusTime)
            {
                this.VirusTime = VirusTime;

                QuadGrid quad = Parent2DScene.quadGrids.First.Value;

                foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(VirusTime / 50f * 2)))
                {
                    if (o.GetType().IsSubclassOf(typeof(UnitTurret)) && Vector2.Distance(o.Position.get(), Position.get()) < VirusTime / 50f)
                    {
                        UnitTurret u = (UnitTurret)o;
                        if (u.CanBeTargeted() && u.IsAlly(this))
                        {
                            u.Virus(VirusTime);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Destroy()
        {
            this.Armed = false;

            Vector3 Position3 = new Vector3(Position.X(), 0, 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);

            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), 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);
            }

            QuadGrid quadGrid = Parent2DScene.quadGrids.First.Value;

            float MaxDist = 100 * Level;

            foreach (GameObject g in quadGrid.Enumerate(Position.get(), new Vector2(MaxDist * 2)))
            {
                if (g.GetType().IsSubclassOf(typeof(UnitTurret)))
                {
                    UnitTurret s = (UnitTurret)g;
                    if (Vector2.Distance(Position.get(), s.Position.get()) < MaxDist && !s.IsAlly(ParentUnit))
                    {
                        s.Relocate();
                    }
                }
            }

            base.Destroy();
        }
Ejemplo n.º 3
0
        protected override void AISearch(GameTime gameTime)
        {
            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
            {
                if (o != this && o.GetType().IsSubclassOf(typeof(UnitTurret)))
                {
                    float d = Vector2.Distance(getPosition(), o.getPosition());
                    if (d < BestDistance)
                    {
                        UnitTurret s = (UnitTurret)o;
                        if (s.GetTeam() == WaveManager.ActiveTeam && s.ShutDownTime < 1 && !s.Dead && !s.IsAlly(this) && s.Resistence != AttackType.Green)
                        {
                            if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), o.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }