public override void Update(GameTime gameTime)
        {
            float      dist = SplinterTurretCard.EngagementDistance;
            UnitTurret u    = (UnitTurret)ParentUnit;

            if (u.IsUpdgraded)
            {
                dist *= 1.5f;
            }

            Vector2 StartPosition = Position.get();
            Vector2 EndPosition   = Position.get() + Vector2.Normalize(Speed) * dist;

            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, 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, 100, 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, 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)
                        {
                            s.Damage(Damage, 0.75f, EndPosition - StartPosition, ParentUnit, AttackType.Red);
                        }
                    }
                }
            }

            Destroy();
        }
        public override void Update(GameTime gameTime)
        {
            StunDistance = 500;
            if (StunnedUnit == null)
            {
                Power += gameTime.ElapsedGameTime.Milliseconds;
            }

            if (Power > MaxPower)
            {
                Power           = MaxPower;
                StunSearchTime += gameTime.ElapsedGameTime.Milliseconds;
                if (StunSearchTime > MaxStunSearchTime && (StunnedUnit == null || !StunnedUnit.CanBeTargeted()))
                {
                    StunSearchTime -= MaxStunSearchTime;

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

                    foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(StunDistance)))
                    {
                        if (o.GetType().Equals(typeof(PlayerShip)))
                        {
                            float d = Vector2.Distance(Position.get(), o.Position.get());
                            if (d < BestDistance)
                            {
                                PlayerShip u = (PlayerShip)o;

                                if (WaveManager.ActiveTeam == u.GetTeam() && u.CanBeTargeted())
                                {
                                    BestDistance = d;
                                    StunnedUnit  = u;
                                    Alpha        = 0;
                                }
                            }
                        }
                    }
                }
            }

            if (StunnedUnit != null)
            {
                if (Power > 0 && StunnedUnit.CanBeTargeted() && Vector2.Distance(Position.get(), StunnedUnit.Position.get()) < StunDistance)
                {
                    if (Alpha < 1)
                    {
                        Alpha += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * AlphaChange;
                        if (Alpha > 1)
                        {
                            Alpha = 1;
                        }
                    }
                    StunnedUnit.SetSpeed(Vector2.Normalize(StunnedUnit.Position.get() - Position.get()) * 8);
                    StunnedUnit.ShutDownTime = 100;

                    Vector3 ParticlePosition = new Vector3(Position.X(), Y, Position.Y());
                    Vector3 ChangeVector     = (new Vector3(StunnedUnit.Position.X(), Y, StunnedUnit.Position.Y()) - ParticlePosition);
                    ChangeVector.Normalize();
                    ChangeVector *= 10;

                    float StaticDistance  = Vector2.Distance(new Vector2(ParticlePosition.X, ParticlePosition.Z), StunnedUnit.Position.get());
                    float DynamicDistance = StaticDistance;

                    while (DynamicDistance > 10)
                    {
                        ParticleManager.CreateParticle(ParticlePosition, Vector3.Zero, CrystalColor * Alpha, Size.X() + (StunnedUnit.Size.X() - Size.X()) * (1 - DynamicDistance / StaticDistance) * 16, 1);
                        ParticlePosition += ChangeVector;
                        DynamicDistance   = Vector2.Distance(new Vector2(ParticlePosition.X, ParticlePosition.Z), StunnedUnit.Position.get());
                    }
                }
                else
                {
                    StunnedUnit = null;
                }
            }
            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            if (!Dead)
            {
                if (ShutDownTime > 0 || VirusTime > 0)
                {
                    ShutDownTime = 0;
                    VirusTime    = 0;
                }
                else
                {
                    SearchTime += gameTime.ElapsedGameTime.Milliseconds;

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

                        bool     Found            = false;
                        QuadGrid quad             = Parent2DScene.quadGrids.First.Value;
                        float    NewHealingAmount = HealingAmount;
                        NewHealingAmount -= Heal(HealingAmount) / HealingAmount * HealingReduction;

                        foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                        {
                            if (o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                            {
                                UnitBuilding s = (UnitBuilding)o;
                                if (!s.Dead && s.IsAlly(this) && Vector2.Distance(Position.get(), o.Position.get()) < MaxEngagementDistance)
                                {
                                    if (s.CanBeTargeted())
                                    {
                                        NewHealingAmount -= s.Heal(HealingAmount) / HealingAmount * HealingReduction;
                                    }

                                    Found = true;
                                }
                            }
                        }

                        if (Found)
                        {
                            HealingAmount = NewHealingAmount;

                            SoundManager.Play3DSound("Healing",
                                                     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++)
                            {
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 2, 5);
                                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, MaxEngagementDistance * 1, 4);
                            }
                        }
                    }
                }
            }
            base.Update(gameTime);
        }
示例#4
0
        public override void Update(GameTime gameTime, BasicController MyController)
        {
            if (!Dashing)
            {
                RechargeTime += gameTime.ElapsedGameTime.Milliseconds;
                if (MyController.LeftStick().Length() > 0.1f)
                {
                    DashVector = Vector2.Normalize(MyController.LeftStick() * new Vector2(1, -1));
                }
            }
            else
            {
                ParentShip.AddPosition(DashVector * DashSpeed * gameTime.ElapsedGameTime.Milliseconds / 1000f * 60f);
                ParentShip.InvTime = Math.Max(ParentShip.InvTime, 400);
                DashTime          += gameTime.ElapsedGameTime.Milliseconds;

                if (DashTime > MaxDashTime)
                {
                    bool PositionClear = true;
                    foreach (Basic2DObject s in ParentShip.Parent2DScene.quadGrids.First.Value.Enumerate(
                                 ParentShip.Position.get(), new Vector2(ParentShip.PlayerSize)))
                    {
                        if (s != ParentShip)
                        {
                            if (s.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                            {
                                if (Vector2.Distance(ParentShip.getPosition(), s.getPosition()) < (ParentShip.PlayerSize + s.getSize().X) / 2)
                                {
                                    BasicShipGameObject b = (BasicShipGameObject)s;
                                    if (b.Solid)
                                    {
                                        PositionClear = false;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                WallNode n = (WallNode)s;
                                if (n.wallConnector != null)
                                {
                                    float MoveAmount = (ParentShip.PlayerSize + s.getSize().X * 0.75f) / 2 - Logic.DistanceLineSegmentToPoint(n.Position.get(), n.wallConnector.PositionNext, ParentShip.Position.get());

                                    if (MoveAmount > 0)
                                    {
                                        PositionClear = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (PositionClear && Dashing)
                    {
                        SoundManager.Play3DSound("PlayerDashReverse",
                                                 new Vector3(ParentShip.Position.X(), ParentShip.Y, ParentShip.Position.Y()), 0.2f, 300, 2);

                        Dashing = false;
                        Vector3 Position3 = new Vector3(ParentShip.Position.X(), ParentShip.Y, ParentShip.Position.Y());
                        ParticleManager.CreateParticle(Position3, Vector3.Zero, PlayerShip.TeleportColor2, ParentShip.Size.X() * 5, 4);
                        for (int i = 0; i < 30; i++)
                        {
                            ParticleManager.CreateParticle(Position3, Rand.V3() * 200, PlayerShip.TeleportColor2, 20, 5);
                        }
                    }
                }
            }

            base.Update(gameTime, MyController);
        }
 public override void Update(GameTime gameTime)
 {
     ParticleManager.Update(gameTime);
     base.Update(gameTime);
 }
        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);
        }