protected void Add(FactionCard card)
        {
            Cards.Add(card);

            if (card.GetType().IsSubclassOf(typeof(TurretCard)))
            {
                TurretCard c = (TurretCard)card;
                c.Reset();
            }
        }
 public void SetValues(Texture2D MyTexture, SpriteFont Font, string Text, Color MyColor,
                       Vector2 Position, Vector2 Size, FactionCard MyCard)
 {
     ParentShip     = (PlayerShip)ParentFrame.Parent;
     this.MyColor   = MyColor;
     this.MyTexture = MyTexture;
     this.Font.set(Font);
     this.Text.set(Text);
     this.Size.set(Size);
     this.Position.set(Position);
     this.MyCard = (TurretCard)MyCard;
 }
        public static void BuildSelectedTurrets(FormFrame frame, int FactionNumber)
        {
            frame.ClearForms();
            frame.Commit("AllTurrets", true);
            for (int x = 0; x < Faction.MaxCards; x++)
            {
                TurretCard c = (TurretCard)FactionManager.Factions[FactionNumber].Cards[x];
                TurretForm t = new TurretForm();
                GameManager.GetLevel().AddObject(t);
                frame.Add(t);

                string s = c.GetUnitImagePath().Equals("") ?
                           "Textures/ShipGame/TurretPictures/" + c.GetImagePath() :
                           "Textures/ShipGame/UnitPictures/" + c.GetUnitImagePath();

                t.SetValues(AssetManager.Load <Texture2D>(s), AssetManager.Load <SpriteFont>("Fonts/ShipGame/EventFont"), c.Name,
                            c.GetColor(), new Vector2(150 * x, 0), new Vector2(125), c);
            }

            frame.Commit("AllTurrets", false);
            frame.DeActivate();
        }
        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;
            }
        }