public override void ExitScreen() { if (this.MultiThread) { // this.ShipUpdateThread.Abort(); this.WorkerThread.Abort(); foreach (Thread thread in this.SystemUpdateThreadList) thread.Abort(); } this.EmpireUI.empire = (Empire)null; this.EmpireUI = (EmpireUIOverlay)null; UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableProjectiles.Clear(); UniverseScreen.ShipSpatialManager.CollidableObjects.Clear(); this.ScreenManager.Music.Stop(AudioStopOptions.Immediate); this.NebulousShit.Clear(); this.bloomComponent = (BloomComponent)null; this.bg3d.BGItems.Clear(); this.bg3d = (Background3D)null; this.playerShip = (Ship)null; this.ShipToView = (Ship)null; foreach (Ship ship in (List<Ship>)this.MasterShipList) ship.TotallyRemove(); this.MasterShipList.ApplyPendingRemovals(); this.MasterShipList.Clear(); foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) { solarSystem.spatialManager.CollidableProjectiles.Clear(); solarSystem.spatialManager.CollidableObjects.Clear(); solarSystem.spatialManager.ClearBuckets(); solarSystem.spatialManager.Destroy(); solarSystem.spatialManager = (SpatialManager)null; solarSystem.FiveClosestSystems.Clear(); foreach (Planet planet in solarSystem.PlanetList) { planet.TilesList = new List<PlanetGridSquare>(); if (planet.SO != null) { planet.SO.Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)planet.SO); planet.SO = (SceneObject)null; } } foreach (Asteroid asteroid in (List<Asteroid>)solarSystem.AsteroidsList) { if (asteroid.GetSO() != null) { asteroid.GetSO().Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)asteroid.GetSO()); } } solarSystem.AsteroidsList.Clear(); foreach (Moon moon in solarSystem.MoonList) { if (moon.GetSO() != null) { moon.GetSO().Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)moon.GetSO()); } } solarSystem.MoonList.Clear(); } foreach (Empire empire in EmpireManager.EmpireList) empire.CleanOut(); foreach (SpaceJunk spaceJunk in (List<SpaceJunk>)UniverseScreen.JunkList) { spaceJunk.trailEmitter = (ParticleEmitter)null; spaceJunk.JunkSO.Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)spaceJunk.JunkSO); spaceJunk.JunkSO = (SceneObject)null; } UniverseScreen.JunkList.Clear(); this.SelectedShip = (Ship)null; this.SelectedFleet = (Fleet)null; this.SelectedPlanet = (Planet)null; this.SelectedSystem = (SolarSystem)null; ShieldManager.shieldList.Clear(); ShieldManager.PlanetaryShieldList.Clear(); this.PlanetsDict.Clear(); this.ClickableFleetsList.Clear(); this.ClickableShipsList.Clear(); this.ClickPlanetList.Clear(); this.ClickableSystems.Clear(); UniverseScreen.DeepSpaceManager.ClearBuckets(); UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableProjectiles.Clear(); UniverseScreen.DeepSpaceManager.ClearBuckets(); UniverseScreen.DeepSpaceManager.Destroy(); UniverseScreen.DeepSpaceManager = (SpatialManager)null; UniverseScreen.SolarSystemList.Clear(); this.starfield.UnloadContent(); this.starfield.Dispose(); UniverseScreen.SolarSystemList.Clear(); this.beamflashes.UnloadContent(); this.explosionParticles.UnloadContent(); this.photonExplosionParticles.UnloadContent(); this.explosionSmokeParticles.UnloadContent(); this.projectileTrailParticles.UnloadContent(); this.fireTrailParticles.UnloadContent(); this.smokePlumeParticles.UnloadContent(); this.fireParticles.UnloadContent(); this.engineTrailParticles.UnloadContent(); this.flameParticles.UnloadContent(); this.sparks.UnloadContent(); this.lightning.UnloadContent(); this.flash.UnloadContent(); this.star_particles.UnloadContent(); this.neb_particles.UnloadContent(); this.SolarSystemDict.Clear(); ShipDesignScreen.screen = (UniverseScreen)null; Fleet.screen = (UniverseScreen)null; Bomb.screen = (UniverseScreen)null; Anomaly.screen = (UniverseScreen)null; PlanetScreen.screen = (UniverseScreen)null; MinimapButtons.screen = (UniverseScreen)null; Projectile.contentManager = this.ScreenManager.Content; Projectile.universeScreen = (UniverseScreen)null; ShipModule.universeScreen = (UniverseScreen)null; Asteroid.universeScreen = (UniverseScreen)null; Empire.universeScreen = (UniverseScreen)null; SpaceJunk.universeScreen = (UniverseScreen)null; ResourceManager.universeScreen = (UniverseScreen)null; Planet.universeScreen = (UniverseScreen)null; Weapon.universeScreen = (UniverseScreen)null; Ship.universeScreen = (UniverseScreen)null; ArtificialIntelligence.universeScreen = (UniverseScreen)null; MissileAI.universeScreen = (UniverseScreen)null; Moon.universeScreen = (UniverseScreen)null; CombatScreen.universeScreen = (UniverseScreen)null; MuzzleFlashManager.universeScreen = (UniverseScreen)null; FleetDesignScreen.screen = (UniverseScreen)null; ExplosionManager.universeScreen = (UniverseScreen)null; FTLManager.universeScreen = (UniverseScreen)null; DroneAI.universeScreen = (UniverseScreen)null; StatTracker.SnapshotsDict.Clear(); EmpireManager.EmpireList.Clear(); this.ScreenManager.inter.Unload(); //GC.Collect(2, GCCollectionMode.Optimized); this.Dispose(); base.ExitScreen(); }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { if (this.starfield != null) this.starfield.Dispose(); if (this.DeepSpaceDone != null) this.DeepSpaceDone.Dispose(); if (this.EmpireDone != null) this.EmpireDone.Dispose(); if (this.DeepSpaceGateKeeper != null) this.DeepSpaceGateKeeper.Dispose(); if (this.ItemsToBuild != null) this.ItemsToBuild.Dispose(); if (this.WorkerBeginEvent != null) this.WorkerBeginEvent.Dispose(); if (this.WorkerCompletedEvent != null) this.WorkerCompletedEvent.Dispose(); if (this.anomalyManager != null) this.anomalyManager.Dispose(); if (this.bloomComponent != null) this.bloomComponent.Dispose(); if (this.ShipGateKeeper != null) this.ShipGateKeeper.Dispose(); if (this.SystemThreadGateKeeper != null) this.SystemThreadGateKeeper.Dispose(); if (this.FogMap != null) this.FogMap.Dispose(); if (this.MasterShipList != null) this.MasterShipList.Dispose(); if (this.EmpireGateKeeper != null) this.EmpireGateKeeper.Dispose(); if (this.BombList != null) this.BombList.Dispose(); if (this.flash != null) this.flash.Dispose(); if (this.lightning != null) this.lightning.Dispose(); if (this.neb_particles != null) this.neb_particles.Dispose(); if (this.photonExplosionParticles != null) this.photonExplosionParticles.Dispose(); if (this.projectileTrailParticles != null) this.projectileTrailParticles.Dispose(); if (this.sceneMap != null) this.sceneMap.Dispose(); if (this.shipListInfoUI != null) this.shipListInfoUI.Dispose(); if (this.smokePlumeParticles != null) this.smokePlumeParticles.Dispose(); if (this.sparks != null) this.sparks.Dispose(); if (this.star_particles != null) this.star_particles.Dispose(); if (this.engineTrailParticles != null) this.engineTrailParticles.Dispose(); if (this.explosionParticles != null) this.explosionParticles.Dispose(); if (this.explosionSmokeParticles != null) this.explosionSmokeParticles.Dispose(); if (this.fireTrailParticles != null) this.fireTrailParticles.Dispose(); if (this.fireParticles != null) this.fireParticles.Dispose(); if (this.flameParticles != null) this.flameParticles.Dispose(); if (this.beamflashes != null) this.beamflashes.Dispose(); if (this.dsbw != null) this.dsbw.Dispose(); if (this.SelectedShipList != null) this.SelectedShipList.Dispose(); if (this.NotificationManager != null) this.NotificationManager.Dispose(); if (this.FogMapTarget != null) this.FogMapTarget.Dispose(); } this.starfield = null; this.DeepSpaceDone = null; this.EmpireDone = null; this.DeepSpaceGateKeeper = null; this.ItemsToBuild = null; this.WorkerBeginEvent = null; this.WorkerCompletedEvent = null; this.anomalyManager = null; this.bloomComponent = null; this.ShipGateKeeper = null; this.SystemThreadGateKeeper = null; this.FogMap = null; this.MasterShipList = null; this.EmpireGateKeeper = null; this.BombList = null; this.flash = null; this.lightning = null; this.neb_particles = null; this.photonExplosionParticles = null; this.projectileTrailParticles = null; this.sceneMap = null; this.shipListInfoUI = null; this.smokePlumeParticles = null; this.sparks = null; this.star_particles = null; this.engineTrailParticles = null; this.explosionParticles = null; this.explosionSmokeParticles = null; this.fireTrailParticles = null; this.fireParticles = null; this.flameParticles = null; this.beamflashes = null; this.dsbw = null; this.SelectedShipList = null; this.NotificationManager = null; this.FogMapTarget = null; } }
private void DrawFullscreenQuad(Texture2D texture, int width, int height, Effect effect, BloomComponent.IntermediateBuffer currentBuffer) { Ship.universeScreen.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None); if (this.showBuffer >= currentBuffer) { effect.Begin(); effect.CurrentTechnique.Passes[0].Begin(); } Ship.universeScreen.ScreenManager.SpriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White); Ship.universeScreen.ScreenManager.SpriteBatch.End(); if (this.showBuffer >= currentBuffer) { effect.CurrentTechnique.Passes[0].End(); effect.End(); } }
public void LoadGraphics() { this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f); this.Frustum = new BoundingFrustum(this.view * this.projection); this.mmHousing = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 276, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 256, 276, 256); this.MinimapDisplayRect = new Rectangle(this.mmHousing.X + 61, this.mmHousing.Y + 43, 200, 200); this.minimap = new MiniMap(this.mmHousing); this.mmButtons = new MinimapButtons(this.mmHousing, this.EmpireUI); this.mmShowBorders = new Rectangle(this.MinimapDisplayRect.X, this.MinimapDisplayRect.Y - 25, 32, 32); this.mmDSBW = new Rectangle(this.mmShowBorders.X + 32, this.mmShowBorders.Y, 64, 32); this.mmAutomation = new Rectangle(this.mmDSBW.X + this.mmDSBW.Width, this.mmShowBorders.Y, 96, 32); this.mmShipView = new Rectangle(this.MinimapDisplayRect.X - 32, this.MinimapDisplayRect.Y, 32, 105); this.mmGalaxyView = new Rectangle(this.mmShipView.X, this.mmShipView.Y + 105, 32, 105); this.SectorMap = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 300, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.GalaxyMap = new Rectangle(this.SectorMap.X + this.SectorMap.Width, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.SelectedStuffRect = new Rectangle(0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 247, 407, 242); this.ShipInfoUIElement = new ShipInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.sInfoUI = new SystemInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.pInfoUI = new PlanetInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.shipListInfoUI = new ShipListInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.vuiElement = new VariableUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.SectorSourceRect = new Rectangle((this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 720) / 2, (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 720) / 2, 720, 720); this.EmpireUI = new EmpireUIOverlay(this.player, this.ScreenManager.GraphicsDevice, this); this.bloomComponent = new BloomComponent(this.ScreenManager); this.bloomComponent.LoadContent(); this.aw = new AutomationWindow(this.ScreenManager, this); PresentationParameters presentationParameters = this.ScreenManager.GraphicsDevice.PresentationParameters; int backBufferWidth = presentationParameters.BackBufferWidth; int backBufferHeight = presentationParameters.BackBufferHeight; SurfaceFormat backBufferFormat = presentationParameters.BackBufferFormat; this.sceneMap = new ResolveTexture2D(this.ScreenManager.GraphicsDevice, backBufferWidth, backBufferHeight, 1, backBufferFormat); this.MainTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.LightsTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.MiniMapSector = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.BorderRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.StencilRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (this.loadFogPath == null) { this.FogMap = ResourceManager.TextureDict["Textures/UniverseFeather"]; } else { using (FileStream fileStream = File.OpenRead(folderPath + "/StarDrive/Saved Games/Fog Maps/" + this.loadFogPath + ".png")) this.FogMap = Texture2D.FromFile(this.ScreenManager.GraphicsDevice, (Stream)fileStream); } this.FogMapTarget = new RenderTarget2D(this.ScreenManager.GraphicsDevice, 512, 512, 1, backBufferFormat, this.ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleType, presentationParameters.MultiSampleQuality); this.basicFogOfWarEffect = this.ScreenManager.Content.Load<Effect>("Effects/BasicFogOfWar"); this.LoadMenu(); MuzzleFlashManager.universeScreen = this; DroneAI.universeScreen = this; MuzzleFlashManager.flashModel = this.ScreenManager.Content.Load<Model>("Model/Projectiles/muzzleEnergy"); MuzzleFlashManager.FlashTexture = this.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/Textures/MuzzleFlash_01"); ExplosionManager.universeScreen = this; FTLManager.universeScreen = this; FTLManager.FTLTexture = this.ScreenManager.Content.Load<Texture2D>("Textures/Ships/FTL"); this.anomalyManager = new AnomalyManager(); ShipDesignScreen.screen = this; Fleet.screen = this; Bomb.screen = this; Anomaly.screen = this; PlanetScreen.screen = this; MinimapButtons.screen = this; Projectile.contentManager = this.ScreenManager.Content; Projectile.universeScreen = this; ShipModule.universeScreen = this; Asteroid.universeScreen = this; Empire.universeScreen = this; SpaceJunk.universeScreen = this; ResourceManager.universeScreen = this; Planet.universeScreen = this; Weapon.universeScreen = this; Ship.universeScreen = this; ArtificialIntelligence.universeScreen = this; MissileAI.universeScreen = this; Moon.universeScreen = this; CombatScreen.universeScreen = this; FleetDesignScreen.screen = this; this.xnaPlanetModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/planet"); this.atmoModel = this.ScreenManager.Content.Load<Model>("Model/sphere"); this.AtmoEffect = this.ScreenManager.Content.Load<Effect>("Effects/PlanetHalo"); this.cloudTex = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/earthcloudmap"); this.RingTexture = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/planet_rings"); this.ThrusterEffect = this.ScreenManager.Content.Load<Effect>("Effects/Thrust"); this.listener = new AudioListener(); this.SunModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.NebModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.ScreenRectangle = new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content); this.starfield.LoadContent(); //fbedard: new button for ShipsInCombat this.ShipsInCombat = new UIButton(); ShipsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 275, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); ShipsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; ShipsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; ShipsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; ShipsInCombat.Text = "Ships: 0"; ShipsInCombat.Launches = "ShipsInCombat"; //fbedard: new button for PlanetsInCombat this.PlanetsInCombat = new UIButton(); PlanetsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 135, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); PlanetsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; PlanetsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; PlanetsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; PlanetsInCombat.Text = "Planets: 0"; PlanetsInCombat.Launches = "PlanetsInCombat"; }
private void DrawFullscreenQuad(Texture2D texture, RenderTarget2D renderTarget, Effect effect, BloomComponent.IntermediateBuffer currentBuffer) { this.GraphicsDevice.SetRenderTarget(0, renderTarget); DepthStencilBuffer old = this.GraphicsDevice.DepthStencilBuffer; this.GraphicsDevice.DepthStencilBuffer = this.buffer; this.DrawFullscreenQuad(texture, renderTarget.Width, renderTarget.Height, effect, currentBuffer); this.GraphicsDevice.SetRenderTarget(0, null); this.GraphicsDevice.DepthStencilBuffer = old; }