public override void Destroy()
        {
#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            InstanceManager.RemoveChild(this);
            base.Destroy();
        }
        public override void Destroy()
        {
            DeathParticles();

            if (InstancerCommit())
            {
                InstanceManager.RemoveChild(this);
                ShieldInstancer.Remove(this);
            }
            if (UnitAdded)
            {
                FactionManager.RemoveUnit(this);
                UnitAdded = false;
            }

            base.Destroy();
        }
 public override void Destroy()
 {
     InstanceManager.RemoveChild(frame);
     base.Destroy();
 }
 public void Deactivate()
 {
     particleAlpha = 0;
     InstanceManager.RemoveChild(this);
     RemoveTag(GameObjectTag.Update);
 }
 public void Eliminate()
 {
     DeathParticles();
     InstanceManager.RemoveChild(this);
     Destroy();
 }
        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;
            }
        }