Пример #1
0
        public static void NewWaveEvent(SceneObject Scene)
        {
            foreach (GameObject o in Scene.Children)
            {
                if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                {
                    BasicShipGameObject s = (BasicShipGameObject)o;
                    s.NewWaveEvent();
                }
            }

            LastTimedTeam = WaveManager.ActiveTeam;

            foreach (Faction f in Factions)
            {
                if (f.Team == WaveManager.ActiveTeam)
                {
                    f.SurvivedMilliSeconds = 0;
                    f.SurvivedMinutes      = 0;
                    f.SurvivedSeconds      = 0;

                    f.BestSurvivedWave       = WaveManager.CurrentWave;
                    f.MiningPlatformCounter += WaveManager.GameSpeed;
                    if (f.MiningPlatformCounter >= f.MaxMiningPlatformCounter)
                    {
                        f.AddEvent("Mining Ring Ready!", new Color(0.5f, 0.5f, 1), FactionEvent.ReadyTexture);
                    }
                }
            }
        }
        protected override void AISearch(GameTime gameTime)
        {
            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
            {
                if (o != this)
                {
                    float d = Vector2.Distance(getPosition(), o.getPosition());
                    if (d < BestDistance && o.GetType().IsSubclassOf(typeof(BasicShipGameObject)) && !o.GetType().Equals(typeof(PlayerShip)))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)o;
                        if (s.GetTeam() == WaveManager.ActiveTeam && !s.Dead && !s.IsAlly(this) && s.CanBeTargeted())
                        {
                            if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.Melee && attackType != AttackType.Explosion)
            {
                if (attackType != AttackType.Red)
                {
                    damage -= 0.5f;
                }
                else
                {
                    damage -= 0.1f;
                }

                if (attackType != AttackType.White)
                {
                    damage /= 3;
                }

                if (attackType == AttackType.Green)
                {
                    damage -= 0.5f * UnitLevel;
                    damage /= 20;
                }
                if (attackType == AttackType.Blue)
                {
                    damage /= 2;
                }

                base.Damage(damage, pushTime, Vector2.Zero, Damager, attackType);
            }
            else
            {
                base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
            }
        }
Пример #4
0
 public override void Collide(BasicShipGameObject s)
 {
     if (!s.GetType().Equals(typeof(PlayerShip)) && !s.GetType().Equals(typeof(CrystalWall)))
     {
         base.Collide(s);
     }
 }
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     if (ShieldDamage < ShieldToughness)
     {
         if (TimesEMPED == 0)
         {
             FreezeTime = 1600 - 400 * UnitLevel + 1000 * Level;
             StunState  = AttackType.Blue;
             TimesEMPED++;
             LastDamager = Damager;
         }
     }
     else
     {
         if (Level > 0)
         {
             if (TimesEMPED == 0)
             {
                 FreezeTime = 1600 - 400 * UnitLevel;
                 StunState  = AttackType.Blue;
                 TimesEMPED++;
                 LastDamager = Damager;
             }
         }
         else
         {
             ShieldFlash(1);
         }
     }
 }
Пример #6
0
        public override void Destroy()
        {
            SoundManager.Play3DSound("MineImpact",
                                     new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2f);

            QuadGrid grid = Parent2DScene.quadGrids.First.Value;
            float    BulletExplosionDistance = 200;

            for (int i = 0; i < 2; i++)
            {
                foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance)))
                {
                    if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)o;
                        float dist            = Vector2.Distance(s.Position.get(), Position.get()) - o.Size.X() / 2;

                        if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam())
                        {
                            float DistMult = 1;
                            if (dist > 0)
                            {
                                DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                            }
                            s.Damage(DistMult * 4, DistMult, Vector2.Normalize(s.Position.get() - Position.get()) * 1 * DistMult, this, AttackType.Green);
                        }
                    }
                }
            }

            base.Destroy();
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.Melee && attackType != AttackType.Green && attackType != AttackType.White)
            {
                damage -= 0.1f * UnitLevel;
                if (attackType == AttackType.Red)
                {
                    damage -= 0.1f * UnitLevel;
                }
            }
            if (attackType != AttackType.Explosion && attackType != AttackType.Melee)
            {
                damage /= 6;
                if (attackType != AttackType.White)
                {
                    damage /= 2;
                }
                if (attackType == Resistence)
                {
                    return;
                }

                base.Damage(damage, pushTime, Vector2.Zero, Damager, attackType);
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
        private void AISearch(GameTime gameTime)
        {
            CurrentAttackTarget = null;

            QuadGrid grid = Parent2DScene.quadGrids.First.Value;

            float BestDistance = MaxEngagementDistance;

            foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
            {
                if (o.GetType().IsSubclassOf(typeof(UnitBasic)) && !o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                {
                    BasicShipGameObject s = (BasicShipGameObject)o;
                    if (!s.IsAlly(this) && s.CanBeTargeted())
                    {
                        float d = Vector2.Distance(Position.get(), o.Position.get()) - o.Size.X() / 2;

                        if (d / s.ThreatLevel < BestDistance)
                        {
                            BestDistance        = d / s.ThreatLevel;
                            CurrentAttackTarget = s;
                        }
                    }
                }
            }
        }
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     Bounces     = 0;
     EMPPosition = Position.get();
     CanCloak    = false;
     base.EMP(Damager, Level);
 }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            float PreviousShieldDamage = Math.Min(ShieldDamage, ShieldToughness);
            float PreviousHullDamage   = Math.Min(HullDamage, HullToughness);

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);

            float DamageAmount = (Math.Min(ShieldDamage, ShieldToughness) - PreviousShieldDamage) + (Math.Min(HullDamage, HullToughness) - PreviousHullDamage);

            if (DamageAmount > 0)
            {
                if (DamageAmount > 0.25f)
                {
                    TextParticleSystem.AddParticle(new Vector3(Position.X(), Y, Position.Y()), ((int)(DamageAmount * 4)).ToString(), (byte)Damager.GetTeam());
                }

                if (Damager.GetType().IsSubclassOf(typeof(UnitShip)))
                {
                    UnitShip s = (UnitShip)Damager;
                    //if (s.IsGhostMode)
                    //  return;
                }

                if (Damager.GetTeam() == NeutralManager.NeutralTeam)
                {
                    FactionManager.AddDamage(DamageAmount * 4);
                }
                else
                {
                    FactionManager.AddDamage(Damager.GetTeam(), DamageAmount * 4);
                }
            }
        }
Пример #11
0
        public static void AddBasicChild(BasicShipGameObject Object)
        {
            if (DrawItems.Count > Object.GetIntType())
            {
                if (DrawItems[Object.GetIntType()] != null)
                {
                    SortedChildren[Object.GetIntType()].AddLast(Object);
                    if (!DrawIdList.Contains(Object.GetIntType()))
                    {
                        DrawIdList.AddLast(Object.GetIntType());
                    }
                }
                else
                {
                    DrawItems[Object.GetIntType()] = Object.getDrawItem();
                    if (DrawItems[Object.GetIntType()] == null)
                    {
                        DrawItems[Object.GetIntType()] = new DrawShip(InstanceModelList.GetList()[Object.GetIntType()]);
                    }

                    SortedChildren[Object.GetIntType()] = new LinkedList <BasicShipGameObject>();
                    SortedChildren[Object.GetIntType()].AddLast(Object);
                    DrawIdList.AddLast(Object.GetIntType());
                    if (!DrawIdList.Contains(Object.GetIntType()))
                    {
                        DrawIdList.AddLast(Object.GetIntType());
                    }
                }
            }
            else
            {
                int c    = DrawItems.Count;
                int numb = Object.GetIntType() - c + 1;

                for (int i = 0; i < numb; i++)
                {
                    if (i + c != Object.GetIntType())
                    {
                        DrawItems.Add(null);
                        SortedChildren.Add(null);
                    }
                    else
                    {
                        DrawItems.Add(Object.getDrawItem());
                        if (DrawItems[Object.GetIntType()] == null)
                        {
                            DrawItems.Add(new DrawShip(InstanceModelList.GetList()[Object.GetIntType()]));
                        }

                        SortedChildren.Add(new LinkedList <BasicShipGameObject>());
                        SortedChildren[Object.GetIntType()].AddLast(Object);
                        if (!DrawIdList.Contains(Object.GetIntType()))
                        {
                            DrawIdList.AddLast(Object.GetIntType());
                        }
                    }
                }
            }
        }
Пример #12
0
 public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
 {
     if (Damager.TestTag(UnitTag.Player))
     {
         damage /= 2;
     }
     base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
 }
        public virtual void EMP(BasicShipGameObject Damager, int Level)
        {
            SoundManager.Play3DSound("SnapHit", new Vector3(Position.X(), Y, Position.X()), 0.25f, 800, 2);

            FreezeTime  = 5000;
            StunState   = AttackType.Blue;
            LastDamager = Damager;
        }
 public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
 {
     if (attackType == AttackType.Red)
     {
         damage *= 0.25f;
     }
     base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
 }
Пример #15
0
 public static void RemoveChild(BasicShipGameObject UnitShip)
 {
     SortedChildren[UnitShip.GetIntType()].Remove(UnitShip);
     if (SortedChildren[UnitShip.GetIntType()].Count < 1 && DrawIdList.Contains(UnitShip.GetIntType()))
     {
         DrawIdList.Remove(UnitShip.GetIntType());
     }
 }
        public override float getDamage(BasicShipGameObject s, float Mult)
        {
            if (s.TestTag(UnitTag.Building))
            {
                Mult *= 0.2f;
            }

            return(base.getDamage(s, Mult));
        }
        protected virtual void AISearch(GameTime gameTime)
        {
            AngerTime -= gameTime.ElapsedGameTime.Milliseconds;
            if (AngerTime > 0 && CurrentAttackTarget != null && CurrentAttackTarget.CanBeTargeted())
            {
                return;
            }

            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            StarshipScene scene = (StarshipScene)Parent2DScene;

            if (GetTeam() != WaveManager.ActiveTeam)
            {
                foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
                {
                    if (o != this)
                    {
                        float d = Vector2.Distance(Position.get(), o.getPosition());
                        if (d < BestDistance && o.GetType().IsSubclassOf(typeof(UnitBasic)))
                        {
                            UnitBasic s = (UnitBasic)o;
                            if (s.GetTeam() == WaveManager.ActiveTeam && s.CanBeTargeted())
                            {
                                if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                                {
                                    BestDistance        = d / s.ThreatLevel;
                                    CurrentAttackTarget = s;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Basic2DObject o in Parent2DScene.GetList(GameObjectTag._2DSolid))
                {
                    if (o != this && o.GetType().IsSubclassOf(typeof(UnitBasic)) && !o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                    {
                        float d = Vector2.Distance(Position.get(), o.getPosition());

                        if (d < BestDistance)
                        {
                            UnitBasic s = (UnitBasic)o;
                            if (!IsAlly(s) && s.CanBeTargeted() &&
                                d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
        public override void Collide(GameTime gameTime, BasicShipGameObject Other)
        {
            if (Other != null && !Other.IsAlly(this) && Other.GetType().IsSubclassOf(typeof(UnitTurret)) && !Other.Dead && Other.ShutDownTime < 1)
            {
                BlowUp();
            }

            base.Collide(gameTime, Other);
        }
        public override float getDamage(BasicShipGameObject s, float Mult)
        {
            if (s.TestTag(UnitTag.Player))
            {
                Mult *= PlayerWeapon.GetTurretVsPlayer();
            }

            return(Damage * Mult);
        }
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     if (FreezeTime < 3000)
     {
         FreezeTime  = 3000;
         StunState   = AttackType.Blue;
         LastDamager = Damager;
     }
 }
        public override float getDamage(BasicShipGameObject s, float Mult)
        {
            if (Big)
            {
                Mult *= 3;
            }

            return(base.getDamage(s, Mult));
        }
Пример #22
0
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != Weakness && attackType != AttackType.Explosion && attackType != AttackType.Melee)
            {
                attackType = Resistence;
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType == AttackType.White)
            {
                damage /= UnitLevel * 2;
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
Пример #24
0
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     if (TimesEMPED == 0)
     {
         FreezeTime = 1600 - 400 * UnitLevel + Level * 1000;
         StunState  = AttackType.Blue;
         TimesEMPED++;
         LastDamager = Damager;
     }
 }
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     if (Level > 0 && TimesEMPED == 0)
     {
         FreezeTime  = 1500;
         StunState   = AttackType.Blue;
         LastDamager = Damager;
         TimesEMPED++;
     }
     return;
 }
 public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
 {
     //if (attackType == AttackType.Melee && damage > 0)
     {
         if (damage > 0.5f && CollisionDamage > 0)
         {
             damage = 0.5f;
         }
         base.Damage(damage, pushTime, pushSpeed, Damager, AttackType.Melee);
     }
 }
Пример #27
0
        public override float getDamage(BasicShipGameObject s, float Mult)
        {
            BulletExplosionDistance *= 2;

            if (s.TestTag(UnitTag.Player))
            {
                Mult *= 0.3f * PlayerWeapon.GetTurretVsPlayer();
            }

            return(base.getDamage(s, Mult));
        }
Пример #28
0
 public static void NewWave(SceneObject Scene)
 {
     foreach (GameObject o in Scene.Children)
     {
         if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
         {
             BasicShipGameObject s = (BasicShipGameObject)o;
             s.NewWave();
         }
     }
 }
Пример #29
0
 public override void EMP(BasicShipGameObject Damager, int Level)
 {
     if (TimesEMPED == 0)
     {
         FreezeTime  = 1000 - 250 * UnitLevel + 1000 * Level;
         ChargeTime  = 0;
         StunState   = AttackType.Blue;
         LastDamager = Damager;
         TimesEMPED++;
     }
 }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.White && HasDamageField && BasicField.TestFieldClear(Position.get()))
            {
                HasDamageField = false;
                DamageBoostField c = new DamageBoostField();
                ParentLevel.AddObject(c);
                c.SetPosition(Position.get());
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }