protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (this.Explosions != null)
                        this.Explosions.Dispose();
                    if (this.OrbitSL != null)
                        this.OrbitSL.Dispose();
                    if (this.tInfo != null)
                        this.tInfo.Dispose();
                    if (this.hInfo != null)
                        this.hInfo.Dispose();

                }
                this.Explosions = null;
                this.OrbitSL = null;
                this.tInfo = null;
                this.hInfo = null;
                this.disposed = true;
            }
        }
        public CombatScreen(Ship_Game.ScreenManager sm, Planet p)
        {
            this.p = p;
            this.ScreenManager = sm;
            int screenWidth = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth;
            this.GridRect = new Rectangle(screenWidth / 2 - 639, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 490, 1278, 437);
            Rectangle titleRect = new Rectangle(screenWidth / 2 - 250, 44, 500, 80);
            this.TitleBar = new Menu2(this.ScreenManager, titleRect);
            this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString("Ground Combat").X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2));
            this.SelectedItemRect = new Rectangle(screenWidth - 240, 100, 225, 205);
            this.AssetsRect = new Rectangle(10, 48, 225, 200);
            this.HoveredItemRect = new Rectangle(10, 248, 225, 200);
            this.assetsUI = new OrbitalAssetsUIElement(this.AssetsRect, this.ScreenManager, PlanetScreen.screen, p);
            this.tInfo = new TroopInfoUIElement(this.SelectedItemRect, this.ScreenManager, PlanetScreen.screen);
            this.hInfo = new TroopInfoUIElement(this.HoveredItemRect, this.ScreenManager, PlanetScreen.screen);
            Rectangle ColonyGrid = new Rectangle(screenWidth / 2 - screenWidth * 2 / 3 / 2, 130, screenWidth * 2 / 3, screenWidth * 2 / 3 * 5 / 7);
            this.CombatField = new Menu2(sm, ColonyGrid);
            Rectangle OrbitalRect = new Rectangle(5, ColonyGrid.Y, (screenWidth - ColonyGrid.Width) / 2 - 20, ColonyGrid.Height+20);
            this.OrbitalResources = new Menu1(this.ScreenManager, OrbitalRect);
            Rectangle psubRect = new Rectangle(this.AssetsRect.X + 225, this.AssetsRect.Y+23, 185, this.AssetsRect.Height);
            this.orbitalResourcesSub = new Submenu(this.ScreenManager, psubRect);
            this.orbitalResourcesSub.AddTab("In Orbit");
            this.OrbitSL = new ScrollList(this.orbitalResourcesSub);
            universeScreen.ShipsInCombat.Active = false;
            universeScreen.PlanetsInCombat.Active = false;
            this.LandAll = new UIButton()
            {
                Rect = new Rectangle(this.orbitalResourcesSub.Menu.X + 20, this.orbitalResourcesSub.Menu.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height),
                NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"],
                HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"],
                PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"],
                Launches = "Land",
                Text = "Land All"
            };
            this.LaunchAll = new UIButton()
            {
                Rect = new Rectangle(this.orbitalResourcesSub.Menu.X + 20, this.LandAll.Rect.Y -2- this.LandAll.Rect.Height, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height),
                NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"],
                HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"],
                PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"],
                Launches = "LaunchAll",
                Text = "Launch All"
            };
            CombatScreen.universeScreen.MasterShipList.thisLock.EnterReadLock();
            foreach (Ship ship in CombatScreen.universeScreen.MasterShipList)
            {

                if (ship == null)
                    continue;
                if (Vector2.Distance(p.Position, ship.Center) >= 4000f || ship.loyalty != EmpireManager.GetEmpireByName(CombatScreen.universeScreen.PlayerLoyalty))
                {
                    continue;
                }
                if (ship.Role != "troop")
                {
                    if (ship.TroopList.Count <= 0 || (!ship.HasTroopBay && !ship.hasTransporter && !(p.HasShipyard && p.Owner == ship.loyalty)))  //fbedard
                        continue;
                    int LandingLimit = ship.GetHangars().Where(ready => ready.IsTroopBay && ready.hangarTimer <= 0).Count();
                    foreach (ShipModule module in ship.Transporters.Where(module => module.TransporterTimer <= 1))
                        LandingLimit += module.TransporterTroopLanding;
                    if (p.HasShipyard && p.Owner == ship.loyalty) LandingLimit = ship.TroopList.Count;  //fbedard: Allows to unload if shipyard
                    for (int i = 0; i < ship.TroopList.Count() && LandingLimit > 0; i++)
                    {
                        if (ship.TroopList[i] != null && ship.TroopList[i].GetOwner() == ship.loyalty)
                        {
                            this.OrbitSL.AddItem(ship.TroopList[i]);
                            LandingLimit--;
                        }
                    }
                }
                else
                {
                    this.OrbitSL.AddItem(ship);
                }
            }
            CombatScreen.universeScreen.MasterShipList.thisLock.ExitReadLock();
            this.gridPos = new Rectangle(ColonyGrid.X + 20, ColonyGrid.Y + 20, ColonyGrid.Width - 40, ColonyGrid.Height - 40);
            int xsize = this.gridPos.Width / 7;
            int ysize = this.gridPos.Height / 5;
            foreach (PlanetGridSquare pgs in p.TilesList)
            {
                pgs.ClickRect = new Rectangle(this.gridPos.X + pgs.x * xsize, this.gridPos.Y + pgs.y * ysize, xsize, ysize);
            }
            for (int row = 0; row < 6; row++)
            {
                for (int i = 0; i < 7; i++)
                {
                    CombatScreen.PointSet ps = new CombatScreen.PointSet()
                    {
                        point = new Vector2((float)this.GridRect.X + (float)i * this.widthByRow[row] + this.widthByRow[row] / 2f + this.startXByRow[row], (float)(this.GridRect.Y + this.GridRect.Height) - this.distancesByRow[row]),
                        row = row,
                        column = i
                    };
                    this.pointsList.Add(ps);
                }
            }
            foreach (CombatScreen.PointSet ps in this.pointsList)
            {
                foreach (CombatScreen.PointSet toCheck in this.pointsList)
                {
                    if (ps.column != toCheck.column || ps.row != toCheck.row - 1)
                    {
                        continue;
                    }
                    float Distance = Vector2.Distance(ps.point, toCheck.point);
                    Vector2 vtt = toCheck.point - ps.point;
                    vtt = Vector2.Normalize(vtt);
                    Vector2 cPoint = ps.point + ((vtt * Distance) / 2f);
                    CombatScreen.PointSet cp = new CombatScreen.PointSet()
                    {
                        point = cPoint,
                        row = ps.row,
                        column = ps.column
                    };
                    this.CenterPoints.Add(cp);
                }
            }
            foreach (PlanetGridSquare pgs in p.TilesList)
            {
                foreach (CombatScreen.PointSet ps in this.CenterPoints)
                {
                    if (pgs.x != ps.column || pgs.y != ps.row)
                    {
                        continue;
                    }
                    pgs.ClickRect = new Rectangle((int)ps.point.X - 32, (int)ps.point.Y - 32, 64, 64);
                }
            }
            foreach (PlanetGridSquare pgs in p.TilesList)
            {
                this.ReversedList.Add(pgs);
            }
        }