public override void Update(GameTime gameTime)
        {
            float   Mult      = 0.1f + TimeAlive / (float)LifeTime;
            float   Offset    = 200 * Mult;
            Vector3 Position3 = new Vector3(0, ParentUnit.Y, 0);

            float Theta       = -Logic.ToAngle(Speed) - (float)Math.PI * 1f;
            float TargetTheta = Theta + (float)(Math.PI * 1.05);
            float Alpha       = 1 - (float)LifeTime / TimeAlive;

            for (; Theta < TargetTheta; Theta += (float)Math.PI / 20)
            {
                Position3.X = Position.X() + (float)Math.Cos(Theta) * Offset;
                Position3.Z = Position.Y() + (float)Math.Sin(Theta) * Offset;
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor * Alpha, Offset * 4, 1);
                //ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, Offset, 0);
            }

            Position3.X = Position.X();
            Position3.Z = Position.Y();

            if (!Flashed)
            {
                Mult *= 2;
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80 * Mult, 0);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80 * Mult, 4);
                Flashed = true;
            }


            QuadGrid quad = Parent2DScene.quadGrids.First.Value;

            foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(Offset * 2)))
            {
                if (o.GetType().IsSubclassOf(typeof(UnitTurret)) && o != FirstHitTurret &&
                    Vector2.Distance(o.Position.get(), Position.get()) < Offset)
                {
                    UnitTurret u = (UnitTurret)o;
                    if (u.CanBeTargeted())
                    {
                        if (FirstHitTurret == null)
                        {
                            FirstHitTurret = u;
                        }
                        else
                        {
                            u.ShutDownTime = (int)(1000 * Level);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
        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);
                        }
                    }
                }
            }
        }
Beispiel #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);
 }