public override void Update(GameTime gameTime)
        {
            NoShootTime = -1;
            FreezeTime  = -1;

            if (stingRayEmpFireMode.Ammo > 0 && CurrentAttackTarget != null &&
                CurrentAttackTarget.GetType().IsSubclassOf(typeof(UnitTurret)) && !MarkedTurrets.Contains((UnitTurret)CurrentAttackTarget))
            {
                stingRayEmpFireMode.SetLevel(UnitLevel);
                stingRayEmpFireMode.Fire(Logic.ToAngle(CurrentAttackTarget.Position.get() - Position.get()));
                stingRayEmpFireMode.Ammo = 0;
                MarkedTurrets.AddLast((UnitTurret)CurrentAttackTarget);
            }
            base.Update(gameTime);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (CurrentAttackTarget != null)
            {
                if (CurrentAttackTarget.GetType().Equals(typeof(PlayerShip)))
                {
                    MinEngagementDistance = 100;
                }
                else
                {
                    MinEngagementDistance = 300;
                }
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
示例#3
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);
        }