Example #1
0
 public override void Collide(BasicShipGameObject s)
 {
     if (!s.GetType().Equals(typeof(PlayerShip)) && !s.GetType().Equals(typeof(CrystalWall)))
     {
         base.Collide(s);
     }
 }
        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);
                }
            }
        }
Example #3
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);
        }
Example #4
0
        public virtual void Collide(BasicShipGameObject s)
        {
            if (!s.IsAlly(ParentUnit))
            {
                if (!BulletCanBounce || !s.BulletBounces(this))
                {
                    float Damage = getDamage(s, 1);
                    Damage *= ParentUnit.GetDamageMult();
                    s.Damage(Damage, PushTime * Damage, Speed * PushVelocityMult, ParentUnit, attackType);
                }
                else
                {
                    BulletHasBounced = true;

                    if (!BounceSound)
                    {
                        SoundManager.Play3DSound("ShieldBounce", new Vector3(Position.X(), Y, Position.Y()),
                                                 0.35f, 500, 1);
                        BounceSound = true;
                    }

                    if (s.GetType().IsSubclassOf(typeof(UnitBasic)))
                    {
                        UnitBasic b = (UnitBasic)s;
                        b.ShieldFlash(1);
                    }
                    Speed = Vector2.Reflect(Speed, Vector2.Normalize(s.Position.get() - PreviousPosition));
                    Position.set(PreviousPosition);
                    return;
                }
            }

            if (TargetHitCount < MaxHits)
            {
                if (TargetsHit == null)
                {
                    TargetsHit = new BasicShipGameObject[MaxHits];
                    TargetsHit[TargetHitCount++] = s;
                }
                else if (!TargetsHit.Contains(s))
                {
                    TargetsHit[TargetHitCount++] = s;
                }
                else
                {
                    return;
                }
            }
            else
            {
                Destroy();
            }
        }
        public override void Collide(BasicShipGameObject s)
        {
            if (!s.IsAlly(ParentUnit) && s.GetType().IsSubclassOf(typeof(UnitBasic)))
            {
                AttachedUnit   = (UnitBasic)s;
                AttachedOffset = Vector2.Normalize(s.Position.get() - Position.get()) * s.Size.X() / 2;

                if (TimeAlive < MinCollideTimeAlive)
                {
                    TimeAlive = MinCollideTimeAlive;
                }
            }
        }
Example #6
0
        public override void Collide(GameTime gameTime, BasicShipGameObject Other)
        {
            if (Other != null && Other.GetType().Equals(typeof(PlayerShip)) && Other.GetTeam() == WaveManager.ActiveTeam && Other.CanBeTargeted())
            {
                for (int i = 0; i < 2; i++)
                {
                    Damage(100, 100, Vector2.Zero, Other, AttackType.Melee);
                    Other.Damage(100, 100, Vector2.Zero, this, AttackType.Melee);
                }
            }

            base.Collide(gameTime, Other);
        }
Example #7
0
        public override void Collide(GameTime gameTime, BasicShipGameObject Other)
        {
            if (Other != null && !Other.Dead && Other.GetType().IsSubclassOf(typeof(UnitTurret)) && Other.GetTeam() == WaveManager.ActiveTeam)
            {
                for (int i = 0; i < 2; i++)
                {
                    Damage(1000, 0, Vector2.Zero, Other, AttackType.Explosion);
                    Other.Damage(1000, 0, Vector2.Zero, this, AttackType.Explosion);
                }
            }

            base.Collide(gameTime, Other);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if (attackType != AttackType.Explosion)
            {
                if (Damager.GetType().IsSubclassOf(typeof(UnitTurret)) && !Damagers.Contains((UnitTurret)Damager))
                {
                    Damagers.AddLast((UnitTurret)Damager);
                }

                if (damage > 0.5f && ShieldDamage < ShieldToughness)
                {
                    damage = 0.5f;
                    ShieldFlash(1);
                }
            }

            base.Damage(damage, pushTime, pushSpeed, Damager, attackType);
        }
Example #9
0
        public override void BlowUp()
        {
            if (!Dead)
            {
                for (int i = 0; i < 36; i++)
                {
                    Guns[0].FireModes[0].Fire((float)Math.PI * (float)i / 18);
                }

                Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

                ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 10, 4);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, new Color(1, 0.75f, 0.5f), Size.X() * 6, 6);

                float    BulletExplosionDistance = IsUpdgraded ? 300 : 500;
                float    BulletExplosionDamage   = IsUpdgraded ? 0.5f : 1f;
                QuadGrid grid = Parent2DScene.quadGrids.First.Value;

                for (int i = 0; i < 2; i++)
                {
                    bool ActivateDeathSound = true;
                    foreach (Basic2DObject o in grid.Enumerate(Position.get(), new Vector2(BulletExplosionDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitShip)))
                        {
                            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;
                                }

                                if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip ship = (UnitShip)s;
                                    ship.CanDeathSound = ActivateDeathSound;
                                }
                                s.Damage(DistMult * BulletExplosionDamage, DistMult,
                                         Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion);

                                if (s.Dead)
                                {
                                    ActivateDeathSound = false;
                                }
                                else if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                                {
                                    UnitShip ship = (UnitShip)s;
                                    ship.CanDeathSound = true;
                                }
                            }
                        }
                    }
                }
            }

            base.BlowUp();
        }
        public override void BlowUp()
        {
            if (Dead || Lives < 1)
            {
                return;
            }

            Vector3 P3 = new Vector3(Position.X(), 0, Position.Y());

            for (int i = 0; i < 10; i++)
            {
                LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * MaxEngagementDistance, TeamInfo.GetColor(GetTeam()));
            }

            foreach (Faction f in FactionManager.Factions)
            {
                if (MyCard == null)
                {
                    MyCard = (TurretCard)FactionCard.FactionTurretDeck[0];
                }

                if (f.Team != GetTeam())
                {
                    f.roundReport.TurretsKilled++;
                    f.AddEvent(MyCard.Name + " Destroyed", new Color(1, 0.5f, 0.5f), FactionEvent.KillTexture);
                }
                else
                {
                    f.roundReport.TurretsLost++;
                    f.AddEvent(MyCard.Name + " Lost", new Color(1, 0.5f, 0.5f), FactionEvent.LossTexture);
                }
            }

            if (ShouldDeathSound)
            {
                SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume, 1000, 1);
                ShouldDeathSound = false;
            }


            FreezeMult = 0;
            VirusTime  = 0;
            DeathParticles();
            Lives--;

            Dead = true;
            if (MyBustedTurret == null)
            {
                MyBustedTurret = new BustedTurret(this);
                ParentLevel.AddObject(MyBustedTurret);
                MyBustedTurret.SetPosition(getPosition());
            }

            MyBustedTurret.WorldMatrix = WorldMatrix;
            MyBustedTurret.Activate();
            InstanceManager.RemoveChild(this);
            RemoveTag(GameObjectTag._2DSolid);
            RemoveTag(GameObjectTag._2DForward);

            LinkedList <GameObject> GList = Parent2DScene.GetList(GameObjectTag._2DSolid);

            if (GList.Contains(this))
            {
                GList.Remove(this);
            }

            BuildTimer = 0;

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


            for (int i = 0; i < 2; i++)
            {
                bool ActivateDeathSound = true;

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

                        if (dist < BulletExplosionDistance && GetTeam() != s.GetTeam() && s.CanBeTargeted())
                        {
                            float DistMult = 1;
                            if (dist > 0)
                            {
                                DistMult = (BulletExplosionDistance - dist) / BulletExplosionDistance;
                            }

                            if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = ActivateDeathSound;
                            }
                            s.Damage(DistMult * BulletExplosionDamage, DistMult, Vector2.Normalize(s.Position.get() - Position.get()), this, AttackType.Explosion);

                            if (s.Dead)
                            {
                                ActivateDeathSound = false;
                            }
                            else if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip ship = (UnitShip)s;
                                ship.CanDeathSound = true;
                            }
                        }
                    }
                }
            }

            if (ShieldAlpha > 0)
            {
                ShieldInstancer.Remove(this);
                ShieldAlpha = -1;
            }
        }
        public virtual void Collide(GameTime gameTime, BasicShipGameObject Other)
        {
            if (Other == null)
            {
                return;
            }

            if (!Dead && !Other.Dead && !Other.IsAlly(this) && FreezeTime < 0 && Other.GetType().IsSubclassOf(typeof(UnitBasic)))
            {
                UnitBasic u = (UnitBasic)Other;
                if (u.FreezeTime < 0)
                {
                    Vector3 Position3 = new Vector3((Position.X() + Other.Position.X()) / 2, Y, (Position.Y() + Other.Position.Y()) / 2);
                    if (CollisionSound.Equals("") && u.CollisionSound.Equals(""))
                    {
                        SoundManager.Play3DSound("CollisionImpact", Position3, 0.5f, 300, 2);
                    }
                    else
                    {
                        SoundManager.Play3DSound(CollisionSound.Equals("") ? u.CollisionSound : CollisionSound,
                                                 Position3, 0.5f, 300, 2);
                    }


                    Damage(Other.fieldState != FieldState.SpeedBoost || Other.FieldStateTime < 1 ? Other.CollisionDamage : Other.CollisionDamage * 1.25f
                           , 5, Position.get() - Other.Position.get(), Other, AttackType.Melee);

                    Other.Damage(fieldState != FieldState.SpeedBoost || FieldStateTime < 1 ? CollisionDamage : CollisionDamage * 1.25f
                                 , 5, Other.Position.get() - Position.get(), this, AttackType.Melee);

                    if (!GetType().IsSubclassOf(typeof(UnitBuilding)))
                    {
                        FreezeTime = Math.Max(FreezeTime, Other.CollisionFreezeTime);
                        StunState  = AttackType.Melee;
                    }
                    if (!u.GetType().IsSubclassOf(typeof(UnitBuilding)))
                    {
                        u.FreezeTime = Math.Max(u.FreezeTime, CollisionFreezeTime);
                        u.StunState  = AttackType.Melee;
                    }
                }
            }

            float MoveAmount = (Size.X() + Other.getSize().X) / 2 - Vector2.Distance(Other.Position.get(), Position.get());

            if (Other.Moveable)
            {
                CollisionIteration++;
                if (CollisionIteration > 10000)
                {
                    CollisionIteration = 0;
                }

                UnitBasic u = (UnitBasic)Other;
                if (Vector2.Distance(u.Position.get(), Position.get()) > 0.1f)
                {
                    u.Push(u.Position.get() + Vector2.Normalize(Other.Position.get() - Position.get()) * MoveAmount / 2, 0);
                    Push(Position.get() + Vector2.Normalize(Position.get() - Other.Position.get()) * MoveAmount / 2, 0);
                }
                else
                {
                    u.Push(u.Position.get() + Vector2.One * MoveAmount, 0);
                    Push(Position.get() - Vector2.One * MoveAmount, 0);
                }
            }
            else
            {
                if (Vector2.Distance(Other.Position.get(), Position.get()) > 0.1f)
                {
                    Push(Position.get() + Vector2.Normalize(Position.get() - Other.Position.get()) * MoveAmount, MoveAmount);
                }
                else
                {
                    Push(Position.get() + Vector2.One * MoveAmount * 2, MoveAmount * 2);
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            Vector2 StartPosition = Position.get();
            Vector2 EndPosition   = Position.get() + Vector2.Normalize(Speed) * SpearTurretCard.EngagementDistance;

            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, 7);
            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, 150, 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, 7);
            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)
                        {
                            if (s.TestTag(UnitTag.Human))
                            {
                                s.Damage(Damage, 5, EndPosition - StartPosition, ParentUnit, AttackType.Blue);
                            }
                            if (s.GetType().IsSubclassOf(typeof(UnitShip)))
                            {
                                UnitShip   ship = (UnitShip)s;
                                UnitTurret t    = (UnitTurret)ParentUnit;
                                ship.EMP(ParentUnit, t.IsUpdgraded ? 1 : 0);
                            }
                        }
                    }
                }
            }

            Destroy();
        }