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"; }
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; } }
public void Draw(Vector2 camPos, Starfield starfield, Ship_Game.ScreenManager ScreenManager) { Vector2 vector2 = -1f * (camPos - this.lastCamPos); int width = ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = ScreenManager.GraphicsDevice.Viewport; Rectangle blackRect = new Rectangle(0, 0, width, viewport.Height); ScreenManager.SpriteBatch.Begin(); Color c = new Color(255, 255, 255, 160); Primitives2D.FillRectangle(ScreenManager.SpriteBatch, blackRect, new Color(12, 17, 24)); ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["Textures/hqstarfield1"], blackRect, new Rectangle?(blackRect), c); Vector2 vector21 = new Vector2(camPos.X, camPos.Y); float percentX = camPos.X / 500000f; float percentY = camPos.Y / 500000f; float xDiff = (float)blackRect.Width / 10f; float yDiff = (float)blackRect.Height / 10f; float xPerc = percentX * xDiff; this.cam.Pos = new Vector2(xPerc, percentY * yDiff); starfield.Draw(this.cam.Pos, ScreenManager.SpriteBatch); ScreenManager.SpriteBatch.End(); float x = this.cam.Pos.X; Viewport viewport1 = ScreenManager.GraphicsDevice.Viewport; Rectangle bgRect = new Rectangle((int)(x - (float)(viewport1.Width / 2) - this.cam.Pos.X / 30f - 200f), (int)(this.cam.Pos.Y - (float)(ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2) - this.cam.Pos.Y / 30f) - 200, 2048, 2048); Vector2 vector22 = new Vector2(200f, 50f); ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, this.cam.get_transformation(ScreenManager.GraphicsDevice)); ScreenManager.SpriteBatch.Draw(ResourceManager.BigNebulas[1], bgRect, new Color(255, 255, 255, 60)); ScreenManager.SpriteBatch.Draw(ResourceManager.BigNebulas[3], bgRect, new Color(255, 255, 255, 60)); float single = this.cam.Pos.X; Viewport viewport2 = ScreenManager.GraphicsDevice.Viewport; bgRect = new Rectangle((int)(single - (float)(viewport2.Width / 2) - this.cam.Pos.X / 15f - 200f), (int)(this.cam.Pos.Y - (float)(ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2) - this.cam.Pos.Y / 15f) - 200, 2500, 2500); ScreenManager.SpriteBatch.End(); this.lastCamPos = camPos; }
public override void LoadContent() { GlobalStats.ResearchRootUIDToDisplay = "Colonization"; SystemInfoUIElement.SysFont = Fonts.Arial12Bold; SystemInfoUIElement.DataFont = Fonts.Arial10; this.NotificationManager = new NotificationManager(this.ScreenManager, this); this.aw = new AutomationWindow(this.ScreenManager, this); for (int index = 0; (double)index < (double)this.Size.X / 5000.0; ++index) { NebulousOverlay nebulousOverlay = new NebulousOverlay(); float z = RandomMath.RandomBetween(-200000f, -2E+07f); nebulousOverlay.Path = "Textures/smoke"; nebulousOverlay.Position = new Vector3(RandomMath.RandomBetween(-0.5f * this.Size.X, this.Size.X + 0.5f * this.Size.X), RandomMath.RandomBetween(-0.5f * this.Size.X, this.Size.X + 0.5f * this.Size.X), z); float radians = RandomMath.RandomBetween(0.0f, 6.283185f); nebulousOverlay.Scale = RandomMath.RandomBetween(10f, 100f); nebulousOverlay.WorldMatrix = Matrix.CreateScale(50f) * Matrix.CreateScale(nebulousOverlay.Scale) * Matrix.CreateRotationZ(radians) * Matrix.CreateTranslation(nebulousOverlay.Position); this.Stars.Add(nebulousOverlay); } this.LoadGraphics(); UniverseScreen.DeepSpaceManager.Setup((int)this.Size.X, (int)this.Size.Y, (int)(500000.0 * (double)this.GameScale), new Vector2(this.Size.X / 2f, this.Size.Y / 2f)); UniverseScreen.ShipSpatialManager.Setup((int)this.Size.X, (int)this.Size.Y, (int)(500000.0 * (double)this.GameScale), new Vector2(this.Size.X / 2f, this.Size.Y / 2f)); this.DoParticleLoad(); this.bg3d = new Background3D(this); this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content); this.starfield.LoadContent(); GameplayObject.audioListener = this.listener; Weapon.audioListener = this.listener; GameplayObject.audioListener = this.listener; this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f); this.SetLighting(this.UseRealLights); foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) { foreach (string FleetUID in solarSystem.DefensiveFleets) { Fleet defensiveFleetAt = HelperFunctions.CreateDefensiveFleetAt(FleetUID, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.PlanetList[0].Position); MilitaryTask militaryTask = new MilitaryTask(); militaryTask.AO = solarSystem.PlanetList[0].Position; militaryTask.AORadius = 120000f; militaryTask.type = MilitaryTask.TaskType.DefendSystem; defensiveFleetAt.Task = militaryTask; defensiveFleetAt.TaskStep = 3; militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10; EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, defensiveFleetAt); EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask); militaryTask.Step = 2; } if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.customRemnantElements) { foreach (Planet p in solarSystem.PlanetList) { foreach (string FleetUID in p.PlanetFleets) { Fleet planetFleetAt = HelperFunctions.CreateDefensiveFleetAt(FleetUID, EmpireManager.GetEmpireByName("The Remnant"), p.Position); MilitaryTask militaryTask = new MilitaryTask(); militaryTask.AO = solarSystem.PlanetList[0].Position; militaryTask.AORadius = 120000f; militaryTask.type = MilitaryTask.TaskType.DefendSystem; planetFleetAt.Task = militaryTask; planetFleetAt.TaskStep = 3; militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10; EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, planetFleetAt); EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask); militaryTask.Step = 2; } } } foreach (SolarSystem.FleetAndPos fleetAndPos in solarSystem.FleetsToSpawn) { Fleet defensiveFleetAt = HelperFunctions.CreateDefensiveFleetAt(fleetAndPos.fleetname, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.Position + fleetAndPos.Pos); MilitaryTask militaryTask = new MilitaryTask(); militaryTask.AO = solarSystem.Position + fleetAndPos.Pos; militaryTask.AORadius = 75000f; militaryTask.type = MilitaryTask.TaskType.DefendSystem; defensiveFleetAt.Task = militaryTask; defensiveFleetAt.TaskStep = 3; militaryTask.WhichFleet = EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10; EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().TryAdd(EmpireManager.GetEmpireByName("The Remnant").GetFleetsDict().Count + 10, defensiveFleetAt); EmpireManager.GetEmpireByName("The Remnant").GetGSAI().TaskList.Add(militaryTask); militaryTask.Step = 2; } foreach (string key in solarSystem.ShipsToSpawn) ResourceManager.CreateShipAt(key, EmpireManager.GetEmpireByName("The Remnant"), solarSystem.PlanetList[0], true); foreach (Planet p in solarSystem.PlanetList) { if (p.Owner != null) { foreach (string key in p.Guardians) ResourceManager.CreateShipAt(key, p.Owner, p, true); } else { //Added by McShooterz: alternate hostile fleets populate universe if (GlobalStats.ActiveModInfo != null && ResourceManager.HostileFleets.Fleets.Count > 0) { if (p.Guardians.Count > 0) { int randomFleet = HelperFunctions.GetRandomIndex(ResourceManager.HostileFleets.Fleets.Count); foreach (string ship in ResourceManager.HostileFleets.Fleets[randomFleet].Ships) { ResourceManager.CreateShipAt(ship, EmpireManager.GetEmpireByName(ResourceManager.HostileFleets.Fleets[randomFleet].Empire), p, true); } } } else { foreach (string key in p.Guardians) ResourceManager.CreateShipAt(key, EmpireManager.GetEmpireByName("The Remnant"), p, true); if (p.CorsairPresence) { ResourceManager.CreateShipAt("Corsair Asteroid Base", EmpireManager.GetEmpireByName("Corsairs"), p, true).TetherToPlanet(p); ResourceManager.CreateShipAt("Corsair", EmpireManager.GetEmpireByName("Corsairs"), p, true); ResourceManager.CreateShipAt("Captured Gunship", EmpireManager.GetEmpireByName("Corsairs"), p, true); ResourceManager.CreateShipAt("Captured Gunship", EmpireManager.GetEmpireByName("Corsairs"), p, true); } } } } foreach (Anomaly anomaly in solarSystem.AnomaliesList) { if (anomaly.type == "DP") this.anomalyManager.AnomaliesList.Add((Anomaly)new DimensionalPrison(solarSystem.Position + anomaly.Position)); } } float num = 10f; Matrix matrix = this.view; this.MaxCamHeight = 4E+07f; while ((double)num < (double)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 50)) { Vector2 vector2_1 = new Vector2(this.Size.X / 2f, this.Size.Y / 2f); Matrix view = Matrix.CreateTranslation(0.0f, 0.0f, 0.0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f)) * Matrix.CreateRotationX(MathHelper.ToRadians(0.0f)) * Matrix.CreateLookAt(new Vector3(-vector2_1.X, vector2_1.Y, this.MaxCamHeight), new Vector3(-vector2_1.X, vector2_1.Y, 0.0f), new Vector3(0.0f, -1f, 0.0f)); Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(Vector3.Zero, this.projection, view, Matrix.Identity); Vector2 vector2_2 = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.Size, 0.0f), this.projection, view, Matrix.Identity); num = new Vector2(vector3_2.X, vector3_2.Y).X - vector2_2.X; if ((double)num < (double)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth + 50)) this.MaxCamHeight -= 0.1f * this.MaxCamHeight; } if (MaxCamHeight > 23000000) MaxCamHeight = 23000000; if (!this.loading) { this.camPos.X = this.playerShip.Center.X; this.camPos.Y = this.playerShip.Center.Y; this.camHeight = 2750f; } this.transitionDestination = new Vector3(this.camPos.X, this.camPos.Y, this.camHeight); foreach (NebulousOverlay nebulousOverlay in this.Stars) this.star_particles.AddParticleThreadA(nebulousOverlay.Position, Vector3.Zero); if (this.MultiThread) { this.WorkerThread = new Thread(new ThreadStart(this.Worker)); this.WorkerThread.IsBackground = true; this.WorkerThread.Start(); //this.ShipUpdateThread = new Thread(new ThreadStart(this.ShipUpdater)); //this.ShipUpdateThread.IsBackground = true; #if !ALTERTHREAD this.SystemResetEvents = new ManualResetEvent[4]; this.SystemGateKeeper = new AutoResetEvent[4]; List<SolarSystem> list1 = new List<SolarSystem>(); List<SolarSystem> list2 = new List<SolarSystem>(); List<SolarSystem> list3 = new List<SolarSystem>(); List<SolarSystem> list4 = new List<SolarSystem>(); Rectangle rect1 = new Rectangle(0, 0, (int)this.Size.X / 2, (int)this.Size.Y / 2); Rectangle rect2 = new Rectangle((int)this.Size.X / 2, 0, (int)this.Size.X / 2, (int)this.Size.Y / 2); Rectangle rect3 = new Rectangle(0, (int)this.Size.Y / 2, (int)this.Size.X / 2, (int)this.Size.Y / 2); Rectangle rect4 = new Rectangle((int)this.Size.X / 2, (int)this.Size.Y / 2, (int)this.Size.X / 2, (int)this.Size.Y / 2); this.SystemResetEvents[0] = new ManualResetEvent(false); this.SystemGateKeeper[0] = new AutoResetEvent(false); this.SystemResetEvents[1] = new ManualResetEvent(false); this.SystemGateKeeper[1] = new AutoResetEvent(false); this.SystemResetEvents[2] = new ManualResetEvent(false); this.SystemGateKeeper[2] = new AutoResetEvent(false); this.SystemResetEvents[3] = new ManualResetEvent(false); this.SystemGateKeeper[3] = new AutoResetEvent(false); for (int index = 0; index < UniverseScreen.SolarSystemList.Count; ++index) { if (HelperFunctions.CheckIntersection(rect1, UniverseScreen.SolarSystemList[index].Position)) { UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 0; list1.Add(UniverseScreen.SolarSystemList[index]); } if (HelperFunctions.CheckIntersection(rect2, UniverseScreen.SolarSystemList[index].Position)) { UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 1; list2.Add(UniverseScreen.SolarSystemList[index]); } if (HelperFunctions.CheckIntersection(rect3, UniverseScreen.SolarSystemList[index].Position)) { UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 2; list3.Add(UniverseScreen.SolarSystemList[index]); } if (HelperFunctions.CheckIntersection(rect4, UniverseScreen.SolarSystemList[index].Position)) { UniverseScreen.SolarSystemList[index].IndexOfResetEvent = 3; list4.Add(UniverseScreen.SolarSystemList[index]); } } Thread thread1 = new Thread(new ParameterizedThreadStart(this.SystemUpdater)); this.SystemUpdateThreadList.Add(thread1); thread1.Start((object)list1); thread1.IsBackground = true; Thread thread2 = new Thread(new ParameterizedThreadStart(this.SystemUpdater)); this.SystemUpdateThreadList.Add(thread2); thread2.Start((object)list2); thread2.IsBackground = true; Thread thread3 = new Thread(new ParameterizedThreadStart(this.SystemUpdater)); this.SystemUpdateThreadList.Add(thread3); thread3.Start((object)list3); thread3.IsBackground = true; Thread thread4 = new Thread(new ParameterizedThreadStart(this.SystemUpdater)); this.SystemUpdateThreadList.Add(thread4); thread4.Start((object)list4); thread4.IsBackground = true; #endif //Thread thread5 = new Thread(new ThreadStart(this.DeepSpaceThread)); // this.SystemUpdateThreadList.Add(thread5); // thread5.Start(); // thread5.IsBackground = true; //Thread thread6 = new Thread(new ThreadStart(this.EmpireThread)); //this.SystemUpdateThreadList.Add(thread6); //thread6.Start(); //thread6.IsBackground = true; } this.PlanetsDict.Clear(); this.SolarSystemDict.Clear(); foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) { this.SolarSystemDict.Add(solarSystem.guid, solarSystem); foreach (Planet planet in solarSystem.PlanetList) this.PlanetsDict.Add(planet.guid, planet); } foreach (Ship ship in (List<Ship>)this.MasterShipList) { if (ship.TetherGuid != Guid.Empty) ship.TetherToPlanet(this.PlanetsDict[ship.TetherGuid]); } }
public void DrawGalaxyBackdrop(UniverseScreen universe, Starfield starfield) { Vector2 camPos = new Vector2(universe.camPos.X, universe.camPos.Y); Vector2 vector2 = -1f * (camPos - this.lastCamPos); int width = universe.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = universe.ScreenManager.GraphicsDevice.Viewport; Rectangle blackRect = new Rectangle(0, 0, width, viewport.Height); Viewport viewport1 = universe.ScreenManager.GraphicsDevice.Viewport; Viewport viewport2 = universe.ScreenManager.GraphicsDevice.Viewport; Rectangle rectangle = new Rectangle(0, 0, viewport1.Width * 2, viewport2.Height * 2); universe.ScreenManager.SpriteBatch.Begin(); Color color = new Color(255, 255, 255, 160); Primitives2D.FillRectangle(universe.ScreenManager.SpriteBatch, blackRect, Color.Black); Viewport viewport3 = universe.ScreenManager.GraphicsDevice.Viewport; Vector3 UpperLeft = viewport3.Project(Vector3.Zero, universe.projection, universe.view, Matrix.Identity); Viewport viewport4 = universe.ScreenManager.GraphicsDevice.Viewport; Vector3 LowerRight = viewport4.Project(new Vector3(universe.Size.X, universe.Size.Y, 0f), universe.projection, universe.view, Matrix.Identity); Viewport viewport5 = universe.ScreenManager.GraphicsDevice.Viewport; viewport5.Project(new Vector3(universe.Size.X / 2f, universe.Size.Y / 2f, 0f), universe.projection, universe.view, Matrix.Identity); Rectangle drawRect = new Rectangle((int)UpperLeft.X, (int)UpperLeft.Y, (int)LowerRight.X - (int)UpperLeft.X, (int)LowerRight.Y - (int)UpperLeft.Y); universe.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["Textures/galaxy"], drawRect, Color.White); universe.ScreenManager.SpriteBatch.End(); this.lastCamPos = camPos; }
public override void LoadContent() { LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/NewGamelight_rig"); base.ScreenManager.inter.LightManager.Clear(); base.ScreenManager.inter.LightManager.Submit(rig); Ship playerShip = Ship_Game.ResourceManager.GetPlayerShip("Fuckyoumobile"); playerShip.Position = new Vector2(500000f, 500000f); playerShip.Rotation = 0f; playerShip.SensorRange = 100000f; playerShip.Name = "Perseverence"; playerShip.GetSO().World = (Matrix.CreateRotationY(playerShip.yBankAmount) * Matrix.CreateRotationZ(playerShip.Rotation)) * Matrix.CreateTranslation(new Vector3(playerShip.Center, 0f)); base.ScreenManager.inter.ObjectManager.Submit(playerShip.GetSO()); PrimitiveQuad.graphicsDevice = base.ScreenManager.GraphicsDevice; this.starfield = new Starfield(Vector2.Zero, base.ScreenManager.GraphicsDevice, base.ScreenManager.Content); this.starfield.LoadContent(); float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport; float aspectRatio = width / (float)viewport.Height; Vector3 camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f); this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f)); this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 1f, 100000f); }
protected void Dispose(bool disposing) { if (!disposed) { if (disposing) { if (this.starfield != null) this.starfield.Dispose(); } this.starfield = null; this.disposed = true; } }
protected void Dispose(bool disposing) { if (disposing) { lock (this) { if (this.starfield != null) this.starfield.Dispose(); if (this.fleet != null) this.fleet.Dispose(); if (this.AvailableShips != null) this.AvailableShips.Dispose(); if (this.ShipSL != null) this.ShipSL.Dispose(); if (this.FleetSL != null) this.FleetSL.Dispose(); } this.starfield = null; this.fleet = null; this.ShipSL = null; this.FleetSL = null; this.AvailableShips = null; } }
public override void LoadContent() { this.close = new CloseButton(new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 38, 97, 20, 20)); LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/ShipyardLightrig"); lock (GlobalStats.ObjectManagerLocker) { base.ScreenManager.inter.LightManager.Clear(); base.ScreenManager.inter.LightManager.Submit(rig); } this.starfield = new Starfield(Vector2.Zero, base.ScreenManager.GraphicsDevice, base.ScreenManager.Content); this.starfield.LoadContent(); Rectangle titleRect = new Rectangle(2, 44, 250, 80); this.TitleBar = new Menu2(base.ScreenManager, titleRect); this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString("Fleet Hotkeys").X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle leftRect = new Rectangle(2, titleRect.Y + titleRect.Height + 5, titleRect.Width, 500); this.LeftMenu = new Menu1(base.ScreenManager, leftRect, true); this.FleetSL = new ScrollList(this.LeftMenu.subMenu, 40); int i = 0; foreach (KeyValuePair<int, Ship_Game.Gameplay.Fleet> Fleet in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetFleetsDict()) { this.FleetsRects.Add(Fleet.Key, new Rectangle(leftRect.X + 2, leftRect.Y + i * 53, 52, 48)); i++; } Rectangle shipRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 282, 140, 280, 80); this.ShipDesigns = new Menu2(base.ScreenManager, shipRect); this.ShipDesignsTitlePos = new Vector2((float)(shipRect.X + shipRect.Width / 2) - Fonts.Laserian14.MeasureString("Ship Designs").X / 2f, (float)(shipRect.Y + shipRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle shipDesignsRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - shipRect.Width - 2, shipRect.Y + shipRect.Height + 5, shipRect.Width, 500); this.RightMenu = new Menu1(base.ScreenManager, shipDesignsRect); this.sub_ships = new Submenu(base.ScreenManager, shipDesignsRect); this.ShipSL = new ScrollList(this.sub_ships, 40); this.sub_ships.AddTab("Designs"); this.sub_ships.AddTab("Owned"); foreach (Ship ship in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetShips()) { if (ship.fleet != null || !ship.Active) { continue; } this.AvailableShips.Add(ship); } this.PopulateShipSL(); this.SelectedStuffRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 220, -13 + base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 200, 440, 210); Vector2 OrdersBarPos = new Vector2((float)(this.SelectedStuffRect.X + 20), (float)(this.SelectedStuffRect.Y + 65)); ToggleButton AttackRuns = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_headon") { Action = "attack", HasToolTip = true, WhichToolTip = 1 }; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton Artillery = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_aft") { Action = "arty", HasToolTip = true, WhichToolTip = 2 }; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton HoldPos = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_x") { Action = "hold", HasToolTip = true, WhichToolTip = 65 }; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton OrbitLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_left") { Action = "orbit_left", HasToolTip = true, WhichToolTip = 3 }; OrdersBarPos.Y = OrdersBarPos.Y + 29f; ToggleButton BroadsideLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bleft") { Action = "broadside_left", HasToolTip = true, WhichToolTip = 159 }; OrdersBarPos.Y = OrdersBarPos.Y - 29f; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton OrbitRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_right") { Action = "orbit_right", HasToolTip = true, WhichToolTip = 4 }; OrdersBarPos.Y = OrdersBarPos.Y + 29f; ToggleButton BroadsideRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bright") { Action = "broadside_right", HasToolTip = true, WhichToolTip = 160 }; OrdersBarPos.Y = OrdersBarPos.Y - 29f; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton Evade = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_stop") { Action = "evade", HasToolTip = true, WhichToolTip = 6 }; this.OrdersButtons.Add(Artillery); this.OrdersButtons.Add(HoldPos); this.OrdersButtons.Add(OrbitLeft); this.OrdersButtons.Add(BroadsideLeft); this.OrdersButtons.Add(OrbitRight); this.OrdersButtons.Add(BroadsideRight); this.OrdersButtons.Add(Evade); this.OrdersButtons.Add(AttackRuns); this.RequisitionForces = new BlueButton(new Vector2((float)(this.SelectedStuffRect.X + 240), (float)(this.SelectedStuffRect.Y + Fonts.Arial20Bold.LineSpacing + 20)), "Requisition..."); this.SaveDesign = new BlueButton(new Vector2((float)(this.SelectedStuffRect.X + 240), (float)(this.SelectedStuffRect.Y + Fonts.Arial20Bold.LineSpacing + 20 + 50)), "Save Design..."); this.LoadDesign = new BlueButton(new Vector2((float)(this.SelectedStuffRect.X + 240), (float)(this.SelectedStuffRect.Y + Fonts.Arial20Bold.LineSpacing + 20 + 100)), "Load Design..."); this.RequisitionForces.ToggleOn = true; this.SaveDesign.ToggleOn = true; this.LoadDesign.ToggleOn = true; this.OperationsRect = new Rectangle(this.SelectedStuffRect.X + this.SelectedStuffRect.Width + 2, this.SelectedStuffRect.Y + 30, 360, this.SelectedStuffRect.Height - 30); Rectangle AssistRect = new Rectangle(this.OperationsRect.X + 15, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 20, 150, 40); this.Slider_Assist = new WeightSlider(AssistRect, "Assist Nearby Weight") { Tip_ID = 7 }; Rectangle DefenderRect = new Rectangle(this.OperationsRect.X + 15, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 70, 150, 40); this.Slider_Defend = new WeightSlider(DefenderRect, "Defend Nearby Weight") { Tip_ID = 8 }; Rectangle VultureRect = new Rectangle(this.OperationsRect.X + 15, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 120, 150, 40); this.Slider_Vulture = new WeightSlider(VultureRect, "Target Damaged Weight") { Tip_ID = 9 }; Rectangle ArmoredRect = new Rectangle(this.OperationsRect.X + 15 + 180, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 20, 150, 40); this.Slider_Armor = new WeightSlider(ArmoredRect, "Target Armored Weight") { Tip_ID = 10 }; Rectangle ShieldedRect = new Rectangle(this.OperationsRect.X + 15 + 180, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 70, 150, 40); this.Slider_Shield = new WeightSlider(ShieldedRect, "Target Shielded Weight") { Tip_ID = 11 }; Rectangle DPSRect = new Rectangle(this.OperationsRect.X + 15 + 180, this.OperationsRect.Y + Fonts.Arial12Bold.LineSpacing + 120, 150, 40); this.Slider_DPS = new WeightSlider(DPSRect, "Target DPS Weight") { Tip_ID = 12 }; this.PrioritiesRect = new Rectangle(this.SelectedStuffRect.X - this.OperationsRect.Width - 2, this.OperationsRect.Y, this.OperationsRect.Width, this.OperationsRect.Height); Rectangle oprect = new Rectangle(this.PrioritiesRect.X + 15, this.PrioritiesRect.Y + Fonts.Arial12Bold.LineSpacing + 20, 300, 40); this.OperationalRadius = new FloatSlider(oprect, "Operational Radius"); this.OperationalRadius.SetAmount(0.2f); this.OperationalRadius.Tip_ID = 13; Rectangle sizerect = new Rectangle(this.PrioritiesRect.X + 15, this.PrioritiesRect.Y + Fonts.Arial12Bold.LineSpacing + 70, 300, 40); this.Slider_Size = new SizeSlider(sizerect, "Target Size Preference"); this.Slider_Size.SetAmount(0.5f); this.Slider_Size.Tip_ID = 14; this.starfield = new Starfield(Vector2.Zero, base.ScreenManager.GraphicsDevice, base.ScreenManager.Content); this.starfield.LoadContent(); this.bg = new Background(); float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport; float aspectRatio = width / (float)viewport.Height; this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 100f, 15000f); foreach (Ship ship in this.fleet.Ships) { ship.GetSO().World = Matrix.CreateTranslation(new Vector3(ship.RelativeFleetOffset, 0f)); } base.LoadContent(); }