public override void Update(GameTime gameTime)
        {
            SoundInstance = SoundManager.PlayLoopingSound(SoundInstance, "MiningRingHum",
                                                          new Vector3(Position.X(), Y, Position.Y()), 0.05f, 400, 2);

            RotationOffsetSpeed = new Vector3(0.001f, 0.005f, 0.0025f);
            //RotationOffset += gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * 0.1f;
            Size.set(new Vector2(110));
            ShutDownTime = 0;
            DrawRotation = Logic.Clerp(DrawRotation, TargetDrawRotation, 0.1f * gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f);

            DamageTime           -= gameTime.ElapsedGameTime.Milliseconds;
            SizeMult             += SizeMultAcceleration * gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f / 6;
            SizeMultAcceleration -= SizeMultGravity * gameTime.ElapsedGameTime.Milliseconds * 60 / 1000f * 3;

            if (SizeMult < MinSizeMult)
            {
                SizeMult = MinSizeMult;
                if (DamageTime > 0)
                {
                    SizeMultAcceleration = SizeMultBounce;
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
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.º 3
0
 public override void Update(GameTime gameTime)
 {
     if (Shots > 0)
     {
         PauseTime += gameTime.ElapsedGameTime.Milliseconds;
         if (PauseTime > MaxPauseTime)
         {
             if (MissileAttackTarget == null || !MissileAttackTarget.CanBeTargeted())
             {
                 float BestDistance = 100000;
                 foreach (BasicShipGameObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
                 {
                     if (o.GetType().IsSubclassOf(typeof(UnitTurret)))
                     {
                         float d = Vector2.Distance(Position.get(), o.Position.get());
                         if (d < BestDistance)
                         {
                             BestDistance        = d;
                             MissileAttackTarget = (UnitTurret)o;
                         }
                     }
                 }
             }
             else
             {
                 float TargetRotation = Logic.ToAngle(MissileAttackTarget.Position.get() - Position.get());
                 Rotation.set(MathHelper.ToDegrees(Logic.Clerp(Rotation.getAsRadians(), TargetRotation, RotationSpeed * gameTime.ElapsedGameTime.Milliseconds * 60.0f / 1000.0f)));
                 RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
                 if (Math.Abs(Rotation.getAsRadians() - TargetRotation) < 0.1f)
                 {
                     PauseTime = 0;
                     Shots     = 1;
                     EmpFireMode.SetParent(this);
                     EmpFireMode.Fire(TargetRotation);
                 }
             }
         }
     }
     base.Update(gameTime);
 }
        private void AIGuns(GameTime gameTime)
        {
            if (!WaveStepState.WeaponsFree || Guns == null)
            {
                return;
            }

            if (VirusTime < 1)
            {
                if (CurrentAttackTarget == null)
                {
                    return;
                }

                Vector2 CurrentAttackTargetPosition = CurrentAttackTarget.getPosition();

                float TargetRotation = Logic.ToAngle(CurrentAttackTargetPosition - getPosition());
                if (Rotation.get() != TargetRotation)
                {
                    Rotation.set(MathHelper.ToDegrees(Logic.Clerp(Rotation.getAsRadians(), TargetRotation, MathHelper.ToRadians(RotationSpeed) * gameTime.ElapsedGameTime.Milliseconds / 1000 * 60)));
                    RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
                }
            }
            else
            {
                Rotation.set(Rotation.get() + MathHelper.ToRadians(gameTime.ElapsedGameTime.Milliseconds * 20));
                RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
            }

            foreach (GunBasic g in Guns)
            {
                g.SetRotation(Rotation.getAsRadians());
            }

            AutoFire(gameTime);
        }
Exemplo n.º 5
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);
        }
 public void Accelerate(GameTime gameTime, Vector2 Amount)
 {
     Rotation.set(MathHelper.ToDegrees(Logic.Clerp(Rotation.getAsRadians(), Logic.ToAngle(Amount), RotationSpeed * gameTime.ElapsedGameTime.Milliseconds * 60.0f / 1000.0f)));
     SetSpeed(Logic.ToVector2(Rotation.getAsRadians()) * Acceleration * 5 * (FieldStateTime > 0 ? fieldState == FieldState.SpeedBoost ? 1.25f : 0.33f : 1));
     RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
 }
        private void AIMove(GameTime gameTime)
        {
            MoveChangeTime += gameTime.ElapsedGameTime.Milliseconds;
            if (MoveChangeTime > MaxMoveChangeTime)
            {
                MoveChangeTime -= MaxMoveChangeTime;

                TargetPosition = Position.get();

                if (!DodgesBullets || BulletToDodge == null || BulletToDodge.TimeAlive > BulletToDodge.LifeTime)
                {
                    if (BulletToDodge != null)
                    {
                        BulletToDodge = null;
                    }

                    if (CurrentAttackTarget != null)
                    {
                        float d = Vector2.Distance(CurrentAttackTarget.getPosition(), getPosition());

                        if (!RunningAway)
                        {
                            if (d > MinEngagementDistance)
                            {
                                TargetPosition = CurrentAttackTarget.getPosition();
                            }
                            else if (d < MinEngagementDistance)
                            {
                                TargetPosition = Position.get();
                            }
                        }
                        else
                        {
                            TargetPosition = Position.get() + (Position.get() - CurrentAttackTarget.getPosition());
                        }

                        DisplacedFromPath = true;
                    }
                    else
                    {
                        if (TargetNode == null)
                        {
                            TargetNode        = PathFindingNode.GetBestNode(Position.get());
                            DisplacedFromPath = false;
                        }
                        else
                        {
                            DisplaceTime += gameTime.ElapsedGameTime.Milliseconds;
                            if (DisplaceTime > MaxDisplaceTime)
                            {
                                DisplaceTime     -= MaxDisplaceTime;
                                DisplacedFromPath = true;
                            }

                            if (DisplacedFromPath)
                            {
                                if (PathFindingManager.CollisionLine(Position.get(), TargetNode.Position.get()))
                                {
                                    TargetNode = PathFindingNode.GetBestNode(Position.get());
                                }
                                DisplacedFromPath = false;
                            }
                        }

                        TargetPosition = TargetNode.Position.get();

                        if (TargetNode.GetNext() != null && !PathFindingManager.CollisionLine(Position.get(), TargetNode.GetNext().Position.get()) ||
                            (Vector2.Distance(getPosition(), TargetPosition) < 16))
                        {
                            TargetNode = TargetNode.GetNext();
                        }
                    }
                }
                else
                {
                    Vector2 bPos = BulletToDodge.getPosition();
                    bPos += BulletToDodge.Speed / BulletToDodge.Speed.Length() * Vector2.Distance(bPos, Position.get());

                    TargetPosition = (Position.get() - (bPos - Position.get()));

                    BulletDodgeTime -= gameTime.ElapsedGameTime.Milliseconds;

                    if (BulletDodgeTime < 0)
                    {
                        TargetPosition = CurrentMoveTarget == null ? TargetPosition : CurrentMoveTarget.getPosition();
                        BulletToDodge  = null;
                    }

                    DisplacedFromPath = true;
                }
            }

            if (Vector2.Distance(getPosition(), TargetPosition) > 16)
            {
                Accelerate(gameTime, TargetPosition - getPosition());
            }
            else 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);
            }
        }