public override void Draw(GameTime gameTime) { if (this.MultiThread) { this.WorkerCompletedEvent.WaitOne(); if (!this.Paused && this.IsActive) { double totalSeconds = gameTime.ElapsedGameTime.TotalSeconds; } this.WorkerCompletedEvent.Reset(); } lock (GlobalStats.BeamEffectLocker) { Beam.BeamEffect.Parameters["View"].SetValue(this.view); Beam.BeamEffect.Parameters["Projection"].SetValue(this.projection); } this.AdjustCamera((float)gameTime.ElapsedGameTime.TotalSeconds); this.camPos.Z = this.camHeight; this.view = Matrix.CreateTranslation(0.0f, 0.0f, 0.0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f)) * Matrix.CreateRotationX(MathHelper.ToRadians(0.0f)) * Matrix.CreateLookAt(new Vector3(-this.camPos.X, this.camPos.Y, this.camHeight), new Vector3(-this.camPos.X, this.camPos.Y, 0.0f), new Vector3(0.0f, -1f, 0.0f)); Matrix matrix = this.view; this.ScreenManager.GraphicsDevice.SetRenderTarget(0, this.MainTarget); this.DrawMain(gameTime); this.ScreenManager.GraphicsDevice.SetRenderTarget(0, (RenderTarget2D)null); this.DrawLights(gameTime); this.ScreenManager.GraphicsDevice.SetRenderTarget(0, this.BorderRT); this.ScreenManager.GraphicsDevice.Clear(Color.TransparentBlack); this.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); this.ScreenManager.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true; this.ScreenManager.GraphicsDevice.RenderState.AlphaBlendOperation = BlendFunction.Add; this.ScreenManager.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One; this.ScreenManager.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.One; this.ScreenManager.GraphicsDevice.RenderState.MultiSampleAntiAlias = true; if (this.viewState >= UniverseScreen.UnivScreenState.SectorView) this.DrawBorders(); this.ScreenManager.SpriteBatch.End(); this.ScreenManager.GraphicsDevice.SetRenderTarget(0, (RenderTarget2D)null); Texture2D texture1 = this.MainTarget.GetTexture(); Texture2D texture2 = this.LightsTarget.GetTexture(); Texture2D texture3 = this.BorderRT.GetTexture(); this.ScreenManager.GraphicsDevice.SetRenderTarget(0, (RenderTarget2D)null); this.ScreenManager.GraphicsDevice.Clear(Color.Black); this.basicFogOfWarEffect.Parameters["LightsTexture"].SetValue((Texture)texture2); this.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); this.basicFogOfWarEffect.Begin(); this.basicFogOfWarEffect.CurrentTechnique.Passes[0].Begin(); this.ScreenManager.SpriteBatch.Draw(texture1, new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White); this.basicFogOfWarEffect.CurrentTechnique.Passes[0].End(); this.basicFogOfWarEffect.End(); this.ScreenManager.SpriteBatch.End(); this.view = matrix; if (this.drawBloom) this.bloomComponent.Draw(gameTime); this.ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); Color color = Color.White; float num = (float)(75.0 * (double)this.camHeight / 1800000.0); if ((double)num > 75.0) num = 75f; if ((double)num < 10.0) num = 0.0f; color = new Color(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)MathHelper.Lerp((float)color.A, num, 0.99f)); this.ScreenManager.SpriteBatch.Draw(texture3, new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight), color); this.RenderOverFog(gameTime); this.ScreenManager.SpriteBatch.End(); this.ScreenManager.SpriteBatch.Begin(); this.DrawPlanetInfo(); if (this.LookingAtPlanet && this.SelectedPlanet != null && this.workersPanel != null) this.workersPanel.Draw(this.ScreenManager.SpriteBatch, gameTime); this.DrawShipsInRange(); foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) { try { if (solarSystem.isVisible) { foreach (Planet planet in solarSystem.PlanetList) { foreach (Projectile projectile in (List<Projectile>)planet.Projectiles) { if (projectile.WeaponType != "Missile" && projectile.WeaponType != "Rocket" && projectile.WeaponType != "Drone") this.DrawTransparentModel(ResourceManager.ProjectileModelDict[projectile.modelPath], projectile.GetWorld(), this.view, this.projection, projectile.weapon.Animated != 0 ? ResourceManager.TextureDict[projectile.texturePath] : ResourceManager.ProjTextDict[projectile.texturePath], projectile.Scale); } } } } catch { } } this.DrawTacticalPlanetIcons(); if (this.showingFTLOverlay && GlobalStats.PlanetaryGravityWells && !this.LookingAtPlanet) { lock (GlobalStats.ClickableSystemsLock) { foreach (UniverseScreen.ClickablePlanets item_1 in this.ClickPlanetList) { float local_14 = (float)(GlobalStats.GravityWellRange * (1 + ((Math.Log(item_1.planetToClick.scale)) / 1.5))); Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(item_1.planetToClick.Position.X, item_1.planetToClick.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, item_1.planetToClick.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node_inhibit"].Width / 2), (float)(ResourceManager.TextureDict["UI/node_inhibit"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node_inhibit"], local_21, new Rectangle?(), new Color((byte)200, (byte)0, (byte)0, (byte)50), 0.0f, local_22, SpriteEffects.None, 1f); Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color(byte.MaxValue, (byte)50, (byte)0, (byte)150), 1f); } } foreach (ClickableShip ship in this.ClickableShipsList) { if (ship.shipToClick != null && ship.shipToClick.InhibitionRadius > 0) { float local_14 = (float)(ship.shipToClick.InhibitionRadius); Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.shipToClick.Position.X, ship.shipToClick.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, ship.shipToClick.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node_inhibit"].Width / 2), (float)(ResourceManager.TextureDict["UI/node_inhibit"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node_inhibit"], local_21, new Rectangle?(), new Color((byte)200, (byte)0, (byte)0, (byte)40), 0.0f, local_22, SpriteEffects.None, 1f); Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color(byte.MaxValue, (byte)50, (byte)0, (byte)150), 1f); } } List<Empire.InfluenceNode> influenceNodes; this.player.BorderNodeLocker.EnterReadLock(); { influenceNodes = new List<Empire.InfluenceNode>(this.player.BorderNodes); } //Color col = EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).EmpireColor; this.player.BorderNodeLocker.ExitReadLock(); { try { if (this.viewState >= UniverseScreen.UnivScreenState.SectorView) { foreach (Empire.InfluenceNode item_0 in influenceNodes) { float local_14 = (float)(item_0.Radius); Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(item_0.Position.X, item_0.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, item_0.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node_inhibit"].Width / 2), (float)(ResourceManager.TextureDict["UI/node_inhibit"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node_inhibit"], local_21, new Rectangle?(), new Color((byte)0, (byte)200, (byte)0, (byte)20), 0.0f, local_22, SpriteEffects.None, 1f); Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color((byte)30, (byte)30, (byte)150, (byte)150), 1f); } } } catch { } } } if (this.showingRangeOverlay && !this.LookingAtPlanet) { foreach (ClickableShip ship in this.ClickableShipsList) { if (ship.shipToClick != null && ship.shipToClick.RangeForOverlay > 0 && ship.shipToClick.loyalty == EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty)) { float local_14 = (float)(ship.shipToClick.RangeForOverlay); Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.shipToClick.Position.X, ship.shipToClick.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, ship.shipToClick.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node_shiprange"].Width / 2), (float)(ResourceManager.TextureDict["UI/node_shiprange"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node_shiprange"], local_21, new Rectangle?(), new Color((byte)0, (byte)200, (byte)0, (byte)30), 0.0f, local_22, SpriteEffects.None, 1f); //Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color(byte.MaxValue, (byte)50, (byte)0, (byte)150), 2f); } else if (ship.shipToClick != null && ship.shipToClick.RangeForOverlay > 0) { float local_14 = (float)(ship.shipToClick.RangeForOverlay); Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(ship.shipToClick.Position.X, ship.shipToClick.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, ship.shipToClick.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node_shiprange"].Width / 2), (float)(ResourceManager.TextureDict["UI/node_shiprange"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node_shiprange"], local_21, new Rectangle?(), new Color((byte)200, (byte)0, (byte)0, (byte)30), 0.0f, local_22, SpriteEffects.None, 1f); //Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color(byte.MaxValue, (byte)50, (byte)0, (byte)150), 2f); } } } if (this.showingDSBW && !this.LookingAtPlanet) { lock (GlobalStats.ClickableSystemsLock) { foreach (UniverseScreen.ClickablePlanets item_1 in this.ClickPlanetList) { float local_14 = 2500f * item_1.planetToClick.scale; Vector3 local_15 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(item_1.planetToClick.Position.X, item_1.planetToClick.Position.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 local_16 = new Vector2(local_15.X, local_15.Y); Vector3 local_18 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, item_1.planetToClick.Position, local_14), 0.0f), this.projection, this.view, Matrix.Identity); float local_20 = Vector2.Distance(new Vector2(local_18.X, local_18.Y), local_16); Rectangle local_21 = new Rectangle((int)local_16.X, (int)local_16.Y, (int)local_20 * 2, (int)local_20 * 2); Vector2 local_22 = new Vector2((float)(ResourceManager.TextureDict["UI/node"].Width / 2), (float)(ResourceManager.TextureDict["UI/node"].Height / 2)); this.ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["UI/node1"], local_21, new Rectangle?(), new Color((byte)0, (byte)0, byte.MaxValue, (byte)50), 0.0f, local_22, SpriteEffects.None, 1f); Primitives2D.DrawCircle(this.ScreenManager.SpriteBatch, local_16, local_20, 50, new Color(byte.MaxValue, (byte)165, (byte)0, (byte)150), 1f); } } this.dsbw.Draw(gameTime); } this.DrawFleetIcons(gameTime); //fbedard: display values in new buttons this.ShipsInCombat.Text = "Ships: " + this.player.empireShipCombat.ToString(); if (this.player.empireShipCombat > 0) { ShipsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"]; ShipsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"]; ShipsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"]; } else { 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"]; } this.ShipsInCombat.Draw(ScreenManager.SpriteBatch); this.PlanetsInCombat.Text = "Planets: " + this.player.empirePlanetCombat.ToString(); if (this.player.empirePlanetCombat > 0) { PlanetsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"]; PlanetsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"]; PlanetsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"]; } else { 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"]; } this.PlanetsInCombat.Draw(ScreenManager.SpriteBatch); if (!this.LookingAtPlanet) this.pieMenu.Draw(this.ScreenManager.SpriteBatch, Fonts.Arial12Bold); Primitives2D.DrawRectangle(this.ScreenManager.SpriteBatch, this.SelectionBox, Color.Green, 1f); this.EmpireUI.Draw(this.ScreenManager.SpriteBatch); if (!this.LookingAtPlanet) this.DrawShipUI(gameTime); if (!this.LookingAtPlanet || this.LookingAtPlanet && this.workersPanel is UnexploredPlanetScreen || this.LookingAtPlanet && this.workersPanel is UnownedPlanetScreen) { Vector2 vector2_1 = new Vector2((float)(this.SectorMap.X + 75) - Fonts.Arial12Bold.MeasureString("Sector View").X / 2f, (float)(this.SectorMap.Y + 75 - Fonts.Arial12Bold.LineSpacing / 2)); Vector2 vector2_2 = new Vector2((float)(this.GalaxyMap.X + 75) - Fonts.Arial12Bold.MeasureString("Galaxy View").X / 2f, (float)(this.GalaxyMap.Y + 75 - Fonts.Arial12Bold.LineSpacing / 2)); this.DrawMinimap(); } if (this.SelectedShipList.Count == 0) this.shipListInfoUI.ClearShipList(); if (this.SelectedSystem != null && !this.LookingAtPlanet) { this.sInfoUI.SetSystem(this.SelectedSystem); this.sInfoUI.Update(gameTime); if (this.viewState == UniverseScreen.UnivScreenState.GalaxyView) this.sInfoUI.Draw(gameTime); } if (this.SelectedPlanet != null && !this.LookingAtPlanet) { this.pInfoUI.SetPlanet(this.SelectedPlanet); this.pInfoUI.Update(gameTime); this.pInfoUI.Draw(gameTime); } else if (this.SelectedShip != null && !this.LookingAtPlanet) { this.ShipInfoUIElement.ship = this.SelectedShip; this.ShipInfoUIElement.ShipNameArea.Text = this.SelectedShip.VanityName; this.ShipInfoUIElement.Update(gameTime); this.ShipInfoUIElement.Draw(gameTime); } else if (this.SelectedShipList.Count > 1 && this.SelectedFleet == null) { this.shipListInfoUI.Update(gameTime); this.shipListInfoUI.Draw(gameTime); } else if (this.SelectedItem != null) { bool flag = false; for (int index = 0; index < this.SelectedItem.AssociatedGoal.empire.GetGSAI().Goals.Count; ++index) { if (this.SelectedItem.AssociatedGoal.empire.GetGSAI().Goals[index].guid == this.SelectedItem.AssociatedGoal.guid) { flag = true; break; } } if (flag) { string TitleText = "(" + ResourceManager.ShipsDict[this.SelectedItem.UID].Name + ")"; string BodyText = Localizer.Token(1410) + this.SelectedItem.AssociatedGoal.GetPlanetWhereBuilding().Name; this.vuiElement.Draw(gameTime, TitleText, BodyText); this.DrawItemInfoForUI(); } else this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; } else if (this.SelectedFleet != null && !this.LookingAtPlanet) { this.shipListInfoUI.Update(gameTime); this.shipListInfoUI.Draw(gameTime); } if (this.SelectedShip == null || this.LookingAtPlanet) this.ShipInfoUIElement.ShipNameArea.HandlingInput = false; this.DrawToolTip(); if (!this.LookingAtPlanet) this.NotificationManager.Draw(); if (this.Debug && this.showdebugwindow) this.debugwin.Draw(gameTime); if (this.aw.isOpen && !this.LookingAtPlanet) this.aw.Draw(gameTime); if (this.Paused) this.ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, Localizer.Token(4005), new Vector2((float)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2) - Fonts.Pirulen16.MeasureString(Localizer.Token(4005)).X / 2f, 45f), Color.White); if (RandomEventManager.ActiveEvent != null && RandomEventManager.ActiveEvent.InhibitWarp) this.ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, "Hyperspace Flux", new Vector2((float)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2) - Fonts.Pirulen16.MeasureString(Localizer.Token(4005)).X / 2f, (float)(45 + Fonts.Pirulen16.LineSpacing + 2)), Color.Yellow); if (SavedGame.thread != null && SavedGame.thread.IsAlive && this.IsActive) this.ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, "Saving...", new Vector2((float)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2) - Fonts.Pirulen16.MeasureString(Localizer.Token(4005)).X / 2f, (float)(45 + Fonts.Pirulen16.LineSpacing * 2 + 4)), new Color(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Math.Abs((float)Math.Sin(gameTime.TotalGameTime.TotalSeconds)) * (float)byte.MaxValue))); if (this.IsActive && (this.GameSpeed > 1.0f || this.GameSpeed < 1.0f)) { Vector2 vector29 = new Vector2((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - Fonts.Pirulen16.MeasureString(string.Concat(this.GameSpeed, "x")).X - 13f, 44f); this.ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, (this.GameSpeed < 1f ? string.Concat(this.GameSpeed.ToString("#.0"), "x") : string.Concat(this.GameSpeed, "x")), vector29, Color.White); } if (this.Debug) { Vector2 position = new Vector2((float)(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 250), 44f); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Comparisons: " + (object)GlobalStats.Comparisons, position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Dis Check Avg: " + (object)(GlobalStats.DistanceCheckTotal / GlobalStats.ComparisonCounter), position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Modules Moved: " + (object)GlobalStats.ModulesMoved, position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Modules Updated: " + (object)GlobalStats.ModuleUpdates, position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Arc Checks: " + (object)GlobalStats.WeaponArcChecks, position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Beam Tests: " + (object)GlobalStats.BeamTests, position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Memory: " + this.Memory.ToString(), position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Ship Count: " + this.MasterShipList.Count.ToString(), position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Ship Lag(s): " + (this.perfavg2.Average()*this.GameSpeed).ToString("#.000") + " ("+(this.perfavg2.Max()).ToString("#.00")+")", position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Empire Lag(s): " + (this.perfavg.Average() * this.GameSpeed).ToString("#.000") + " (" + (this.perfavg.Max()).ToString("#.00") + ")", position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "PreEmpire Lag(s): " + (this.perfavg3.Average()*this.GameSpeed).ToString("#.000") + " (" + (this.perfavg3.Max()).ToString("#.00") + ")", position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Post Empire Lag(s): " + (this.perfavg4.Average() * this.GameSpeed).ToString("#.000") + " (" + (this.perfavg4.Max()).ToString("#.00") + ")", position, Color.White); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); position.Y += (float)(Fonts.Arial12Bold.LineSpacing + 2); this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "Total Lag(s): " + (this.perfavg5.Average() * this.GameSpeed).ToString("#.000") + " (" + (this.perfavg5.Max()).ToString("#.00") + ")", position, Color.White); } if (this.IsActive) ToolTip.Draw(this.ScreenManager); this.ScreenManager.SpriteBatch.End(); if (!this.MultiThread) return; this.WorkerBeginEvent.Set(); }
protected void HandleSelectionBox(InputState input) { if (this.LookingAtPlanet) return; if (this.SelectedShip != null) { //if (input.CurrentKeyboardState.IsKeyDown(Keys.R) && !input.LastKeyboardState.IsKeyDown(Keys.R)) //fbedard: what is that !!!! // this.SelectedShip.FightersOut = !this.SelectedShip.FightersOut; if (input.CurrentKeyboardState.IsKeyDown(Keys.Q) && !input.LastKeyboardState.IsKeyDown(Keys.Q)) { if (!this.pieMenu.Visible) { if (this.SelectedShip != null) this.LoadShipMenuNodes(this.SelectedShip.loyalty == this.player ? 1 : 0); this.pieMenu.RootNode = this.shipMenu; this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } } Vector2 vector2 = input.CursorPosition - this.pieMenu.Position; vector2.Y *= -1f; Vector2 selectionVector = vector2 / this.pieMenu.Radius; this.pieMenu.HandleInput(input, selectionVector); if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released && !this.pieMenu.Visible) { this.SelectedShip = (Ship)null; this.SelectedPlanet = (Planet)null; this.SelectedFleet = (Fleet)null; this.SelectedFlank = (List<Fleet.Squad>)null; this.SelectedSystem = (SolarSystem)null; this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.ProjectingPosition = false; this.projectedGroup = (ShipGroup)null; bool flag1 = false; if (this.viewState >= UniverseScreen.UnivScreenState.SectorView) { lock (GlobalStats.ClickableSystemsLock) { for (int local_2 = 0; local_2 < this.ClickableSystems.Count; ++local_2) { UniverseScreen.ClickableSystem local_3 = this.ClickableSystems[local_2]; if ((double)Vector2.Distance(input.CursorPosition, local_3.ScreenPos) <= (double)local_3.Radius) { AudioManager.PlayCue("mouse_over4"); this.SelectedSystem = local_3.systemToClick; this.sInfoUI.SetSystem(this.SelectedSystem); flag1 = true; } } } } bool flag2 = false; if (!flag1) { foreach (UniverseScreen.ClickableFleet clickableFleet in this.ClickableFleetsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableFleet.ScreenPos) <= (double)clickableFleet.ClickRadius) { this.SelectedShipList.Clear(); this.SelectedFleet = clickableFleet.fleet; flag2 = true; this.pickedSomethingThisFrame = true; AudioManager.PlayCue("techy_affirm1"); using (List<Ship>.Enumerator enumerator = this.SelectedFleet.Ships.GetEnumerator()) { while (enumerator.MoveNext()) this.SelectedShipList.Add(enumerator.Current); break; } } } if (!flag2) { foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableShip.ScreenPos) <= (double)clickableShip.Radius) { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) && this.SelectedShipList.Count > 1 && this.SelectedShipList.Contains(clickableShip.shipToClick)) { this.SelectedShipList.Remove(clickableShip.shipToClick); this.pickedSomethingThisFrame = true; AudioManager.GetCue("techy_affirm1").Play(); break; } else { if (this.SelectedShipList.Count > 0 && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && !this.pickedSomethingThisFrame) this.SelectedShipList.Clear(); this.pickedSomethingThisFrame = true; AudioManager.GetCue("techy_affirm1").Play(); this.SelectedShip = clickableShip.shipToClick; this.SelectedSomethingTimer = 3f; if (!this.SelectedShipList.Contains(clickableShip.shipToClick)) { if (clickableShip.shipToClick != null) { if (clickableShip.shipToClick.inSensorRange) { this.SelectedShipList.Add(clickableShip.shipToClick); break; } else break; } else break; } else break; } } } if (this.SelectedShip != null && this.SelectedShipList.Count == 1) this.ShipInfoUIElement.SetShip(this.SelectedShip); else if (this.SelectedShipList.Count > 1) this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, false); bool flag3 = false; if (this.SelectedShipList.Count == 1) { if (this.SelectedShipList[0] == this.playerShip) this.LoadShipMenuNodes(1); else if (this.SelectedShipList[0].loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); } else { lock (GlobalStats.ClickableSystemsLock) { foreach (UniverseScreen.ClickablePlanets item_2 in this.ClickPlanetList) { if ((double)Vector2.Distance(input.CursorPosition, item_2.ScreenPos) <= (double)item_2.Radius) { if ((double)this.ClickTimer2 < (double)this.TimerDelay) { this.SelectedPlanet = item_2.planetToClick; this.pInfoUI.SetPlanet(this.SelectedPlanet); this.SelectedSomethingTimer = 3f; flag3 = true; this.ViewPlanet((object)null); this.SelectionBox = new Rectangle(); } else { AudioManager.GetCue("techy_affirm1").Play(); this.SelectedPlanet = item_2.planetToClick; this.pInfoUI.SetPlanet(this.SelectedPlanet); this.SelectedSomethingTimer = 3f; flag3 = true; this.ClickTimer2 = 0.0f; } } } } } if (!flag3) { lock (GlobalStats.ClickableItemLocker) { for (int local_17 = 0; local_17 < this.ItemsToBuild.Count; ++local_17) { UniverseScreen.ClickableItemUnderConstruction local_18 = this.ItemsToBuild[local_17]; if (local_18 != null && (double)Vector2.Distance(input.CursorPosition, local_18.ScreenPos) <= (double)local_18.Radius) { AudioManager.GetCue("techy_affirm1").Play(); this.SelectedItem = local_18; } } } } } } } if (this.SelectedShip == null && this.SelectedShipList.Count == 0 && (this.SelectedPlanet != null && input.CurrentKeyboardState.IsKeyDown(Keys.Q)) && !input.LastKeyboardState.IsKeyDown(Keys.Q)) { if (!this.pieMenu.Visible) { this.pieMenu.RootNode = this.planetMenu; if (this.SelectedPlanet.Owner == null && this.SelectedPlanet.habitable) this.LoadMenuNodes(false, true); else this.LoadMenuNodes(false, false); this.pieMenu.Show(this.pieMenu.Position); } else this.pieMenu.ChangeTo((PieMenuNode)null); } if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) this.SelectionBox = new Rectangle(input.CurrentMouseState.X, input.CurrentMouseState.Y, 0, 0); if (this.SelectedShipList.Count == 1) this.SelectedShip = this.SelectedShipList[0]; if (input.CurrentMouseState.LeftButton == ButtonState.Pressed) { this.SelectingWithBox = true; if (this.SelectionBox.X == 0 || this.SelectionBox.Y == 0) return; this.SelectionBox = new Rectangle(this.SelectionBox.X, this.SelectionBox.Y, input.CurrentMouseState.X - this.SelectionBox.X, input.CurrentMouseState.Y - this.SelectionBox.Y); } else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed) { if (input.CurrentMouseState.X < this.SelectionBox.X) this.SelectionBox.X = input.CurrentMouseState.X; if (input.CurrentMouseState.Y < this.SelectionBox.Y) this.SelectionBox.Y = input.CurrentMouseState.Y; this.SelectionBox.Width = Math.Abs(this.SelectionBox.Width); this.SelectionBox.Height = Math.Abs(this.SelectionBox.Height); bool flag1 = true; List<Ship> list = new List<Ship>(); foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if (this.SelectionBox.Contains(new Point((int)clickableShip.ScreenPos.X, (int)clickableShip.ScreenPos.Y)) && !this.SelectedShipList.Contains(clickableShip.shipToClick)) { this.SelectedPlanet = (Planet)null; this.SelectedShipList.Add(clickableShip.shipToClick); this.SelectedSomethingTimer = 3f; list.Add(clickableShip.shipToClick); } } if (this.SelectedShipList.Count > 0 && flag1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in list) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply")) flag2 = true; else flag3 = true; } if (flag3 && flag2) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply")) this.SelectedShipList.QueuePendingRemoval(ship); } } this.SelectedShipList.ApplyPendingRemovals(); } if (this.SelectedShipList.Count > 1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty == this.player) flag2 = true; if (ship.loyalty != this.player) flag3 = true; } if (flag2 && flag3) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) this.SelectedShipList.QueuePendingRemoval(ship); } this.SelectedShipList.ApplyPendingRemovals(); } this.SelectedShip = (Ship)null; this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, true); } else if (this.SelectedShipList.Count == 1) { this.SelectedShip = this.SelectedShipList[0]; this.ShipInfoUIElement.SetShip(this.SelectedShip); } this.SelectionBox = new Rectangle(0, 0, -1, -1); } else { if (input.CurrentMouseState.LeftButton != ButtonState.Released || input.LastMouseState.LeftButton != ButtonState.Pressed) return; this.SelectingWithBox = false; if (input.CurrentMouseState.X < this.SelectionBox.X) this.SelectionBox.X = input.CurrentMouseState.X; if (input.CurrentMouseState.Y < this.SelectionBox.Y) this.SelectionBox.Y = input.CurrentMouseState.Y; this.SelectionBox.Width = Math.Abs(this.SelectionBox.Width); this.SelectionBox.Height = Math.Abs(this.SelectionBox.Height); bool flag1 = false; if (this.SelectedShipList.Count == 0) flag1 = true; foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if (this.SelectionBox.Contains(new Point((int)clickableShip.ScreenPos.X, (int)clickableShip.ScreenPos.Y))) { this.SelectedPlanet = (Planet)null; this.SelectedShipList.Add(clickableShip.shipToClick); this.SelectedSomethingTimer = 3f; } } if (this.SelectedShipList.Count > 0 && flag1) { bool flag2 = false; bool flag3 = false; try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply") || (ship.Role == "freighter" || ship.Role == "colony")) flag2 = true; else flag3 = true; } } catch { } if (flag3) { if (flag2) { try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.Role == "station" || ship.Role == "construction" || (ship.Role == "platform" || ship.Role == "supply") || (ship.Role == "freighter" || ship.Role == "colony")) this.SelectedShipList.QueuePendingRemoval(ship); } } catch { } } } this.SelectedShipList.ApplyPendingRemovals(); } if (this.SelectedShipList.Count > 1) { bool flag2 = false; bool flag3 = false; foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty == this.player) flag2 = true; if (ship.loyalty != this.player) flag3 = true; } if (flag2 && flag3) { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.loyalty != this.player) this.SelectedShipList.QueuePendingRemoval(ship); } this.SelectedShipList.ApplyPendingRemovals(); } this.SelectedShip = (Ship)null; bool flag4 = true; if (this.SelectedShipList.Count > 0) { if (this.SelectedShipList[0].fleet != null) { if (this.SelectedShipList.Count == this.SelectedShipList[0].fleet.Ships.Count) { try { foreach (Ship ship in (List<Ship>)this.SelectedShipList) { if (ship.fleet == null || ship.fleet != this.SelectedShipList[0].fleet) flag4 = false; } if (flag4) this.SelectedFleet = this.SelectedShipList[0].fleet; } catch { } } } if (this.SelectedFleet != null) this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, true); else this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, false); } if (this.SelectedFleet == null) this.ShipInfoUIElement.SetShip(this.SelectedShipList[0]); } else if (this.SelectedShipList.Count == 1) { this.SelectedShip = this.SelectedShipList[0]; this.ShipInfoUIElement.SetShip(this.SelectedShip); if (this.SelectedShipList[0] == this.playerShip) this.LoadShipMenuNodes(1); else if (this.SelectedShipList[0].loyalty == this.player) this.LoadShipMenuNodes(1); else this.LoadShipMenuNodes(0); } this.SelectionBox = new Rectangle(0, 0, -1, -1); } }
public void ViewToShip(object sender) { if (this.SelectedShip == null) return; this.ShipToView = this.SelectedShip; this.ShipInfoUIElement.SetShip(this.SelectedShip); //fbedard: was not updating correctly from shiplist this.SelectedFleet = (Fleet)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.SelectedSystem = (SolarSystem)null; this.SelectedPlanet = (Planet)null; this.snappingToShip = true; this.HeightOnSnap = this.camHeight; this.transitionDestination.Z = 3500f; this.AdjustCamTimer = 1.0f; this.transitionElapsedTime = 0.0f; this.transitionDestination.Z = 4500f; this.snappingToShip = true; this.ViewingShip = true; }
public void ViewPlanet(object sender) { this.ShowShipNames = false; if (this.SelectedPlanet == null) return; if (!this.SelectedPlanet.system.ExploredDict[this.player]) { this.PlayNegativeSound(); } else { bool flag = false; foreach (Mole mole in (List<Mole>)this.player.data.MoleList) { if (mole.PlanetGuid == this.SelectedPlanet.guid) flag = true; } this.workersPanel = this.SelectedPlanet.Owner == this.player || flag || this.Debug && this.SelectedPlanet.Owner != null ? (PlanetScreen)new ColonyScreen(this.SelectedPlanet, this.ScreenManager, this.EmpireUI) : (this.SelectedPlanet.Owner == null ? (PlanetScreen)new UnexploredPlanetScreen(this.SelectedPlanet, this.ScreenManager) : (PlanetScreen)new UnownedPlanetScreen(this.SelectedPlanet, this.ScreenManager)); this.LookingAtPlanet = true; this.transitionStartPosition = this.camPos; this.transitionDestination = new Vector3(this.SelectedPlanet.Position.X, this.SelectedPlanet.Position.Y + 400f, 2500f); this.AdjustCamTimer = 2f; this.transitionElapsedTime = 0.0f; this.transDuration = 5f; if (this.ViewingShip) this.returnToShip = true; this.ViewingShip = false; this.snappingToShip = false; this.SelectedFleet = (Fleet)null; this.SelectedShip = (Ship)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; } }
public void UpdateClickableItems() { lock (GlobalStats.ClickableItemLocker) this.ItemsToBuild.Clear(); for (int index = 0; index < EmpireManager.GetEmpireByName(this.PlayerLoyalty).GetGSAI().Goals.Count; ++index) { Goal goal = this.player.GetGSAI().Goals[index]; if (goal.GoalName == "BuildConstructionShip") { float radius = 100f; Vector3 vector3_1 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(goal.BuildPosition, 0.0f), this.projection, this.view, Matrix.Identity); Vector2 vector2 = new Vector2(vector3_1.X, vector3_1.Y); Vector3 vector3_2 = this.ScreenManager.GraphicsDevice.Viewport.Project(new Vector3(this.GeneratePointOnCircle(90f, goal.BuildPosition, radius), 0.0f), this.projection, this.view, Matrix.Identity); float num = Vector2.Distance(new Vector2(vector3_2.X, vector3_2.Y), vector2) + 10f; UniverseScreen.ClickableItemUnderConstruction underConstruction = new UniverseScreen.ClickableItemUnderConstruction(); underConstruction.Radius = num; underConstruction.BuildPos = goal.BuildPosition; underConstruction.ScreenPos = vector2; underConstruction.UID = goal.ToBuildUID; underConstruction.AssociatedGoal = goal; lock (GlobalStats.ClickableItemLocker) this.ItemsToBuild.Add(underConstruction); } } }
public void SnapViewSystem(SolarSystem system, UniverseScreen.UnivScreenState camHeight) { float x = this.GetZfromScreenState(camHeight); this.transitionDestination = new Vector3(system.Position.X, system.Position.Y + 400f, x);//80000);// this.transitionStartPosition = this.camPos; this.AdjustCamTimer = 2f; this.transitionElapsedTime = 0.0f; this.transDuration = 5f; this.ViewingShip = false; this.snappingToShip = false; if (this.ViewingShip) this.returnToShip = true; this.ViewingShip = false; this.snappingToShip = false; this.SelectedFleet = (Fleet)null; this.SelectedShip = (Ship)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; //this.input.CursorPosition = //this.ClickTimer2 = this.TimerDelay; }
public override void HandleInput(InputState input) { if (this.ScreenManager.input.CurrentKeyboardState.IsKeyDown(Keys.Space) && this.ScreenManager.input.LastKeyboardState.IsKeyUp(Keys.Space) && !GlobalStats.TakingInput) this.Paused = !this.Paused; for (int index = 0; index < this.SelectedShipList.Count; ++index) { Ship ship = this.SelectedShipList[index]; if (!ship.Active) this.SelectedShipList.QueuePendingRemoval(ship); } //CG: previous target code. if (this.previousSelection != null && input.CurrentMouseState.XButton1 == ButtonState.Pressed && input.LastMouseState.XButton1 == ButtonState.Released) { if (this.previousSelection.Active) { Ship tempship = this.previousSelection; if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedShip = tempship; this.ShipInfoUIElement.SetShip(this.SelectedShip); this.SelectedFleet = (Fleet)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.SelectedSystem = (SolarSystem)null; this.SelectedPlanet = (Planet)null; this.SelectedShipList.Add(this.SelectedShip); } else this.SelectedShip = null; //fbedard: remove inactive ship } //fbedard: Set camera chase on ship if (input.CurrentMouseState.MiddleButton == ButtonState.Pressed) { this.ViewToShip(null); } this.input = input; this.ShowTacticalCloseup = input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt); // something nicer... //if (input.CurrentKeyboardState.IsKeyDown(Keys.P) && input.LastKeyboardState.IsKeyUp(Keys.P) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl)) if (input.CurrentKeyboardState.IsKeyDown(Keys.F5) && input.LastKeyboardState.IsKeyUp(Keys.F5)) { if (this.UseRealLights) { this.UseRealLights = false; } else { this.UseRealLights = true; this.SetLighting(this.UseRealLights); } } if (input.CurrentKeyboardState.IsKeyDown(Keys.F6) && input.LastKeyboardState.IsKeyUp(Keys.F6) && !ExceptionTracker.active) { bool switchedmode = false; #if RELEASE //only switch screens in release if (Game1.Instance.graphics.IsFullScreen) { switchedmode = true; Game1.Instance.graphics.ToggleFullScreen(); } #endif Exception ex = new Exception("Manual Report"); ExceptionTracker.TrackException(ex); // if(ExceptionViewer.ActiveForm == null) { bool paused = false; if (!this.Paused) { paused = true; this.Paused = true; } ExceptionTracker.DisplayException(ex); if (paused) { this.Paused = false; } } if (switchedmode) { switchedmode = false; Game1.Instance.graphics.ToggleFullScreen(); } } if (input.CurrentKeyboardState.IsKeyDown(Keys.F7) && input.LastKeyboardState.IsKeyUp(Keys.F7) && !ExceptionTracker.active) { bool switchedmode = false; #if RELEASE //only switch screens in release if (Game1.Instance.graphics.IsFullScreen) { switchedmode = true; Game1.Instance.graphics.ToggleFullScreen(); } #endif Exception ex = new Exception("Kudos"); ExceptionTracker.TrackException(ex); ExceptionTracker.Kudos = true; // if(ExceptionViewer.ActiveForm == null) { bool paused = false; if (!this.Paused) { paused = true; this.Paused = true; } ExceptionTracker.DisplayException(ex); if (paused) { this.Paused = false; } } if (switchedmode) { switchedmode = false; Game1.Instance.graphics.ToggleFullScreen(); } } if (input.CurrentKeyboardState.IsKeyDown(Keys.OemTilde) && input.LastKeyboardState.IsKeyUp(Keys.OemTilde) && (input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift))) { this.Debug = !this.Debug; UniverseScreen.debug = !this.Debug; foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) solarSystem.ExploredDict[this.player] = true; GlobalStats.LimitSpeed = this.Debug; } if (this.Debug && input.CurrentKeyboardState.IsKeyDown(Keys.G) && input.LastKeyboardState.IsKeyUp(Keys.G)) { this.Memory = (float)GC.GetTotalMemory(true); this.Memory /= 1000f; } this.HandleEdgeDetection(input); if (input.CurrentKeyboardState.IsKeyDown(Keys.OemPlus) && input.LastKeyboardState.IsKeyUp(Keys.OemPlus)) { if (this.GameSpeed < 1.0) this.GameSpeed = 1f; else ++this.GameSpeed; if (this.GameSpeed > 4.0 && GlobalStats.LimitSpeed) this.GameSpeed = 4f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.OemMinus) && input.LastKeyboardState.IsKeyUp(Keys.OemMinus)) { if (this.GameSpeed <= 1.0) this.GameSpeed = 0.5f; else --this.GameSpeed; } if (input.CurrentKeyboardState.IsKeyDown(Keys.Add) && input.LastKeyboardState.IsKeyUp(Keys.Add)) { if (this.GameSpeed < 1.0) this.GameSpeed = 1f; else ++this.GameSpeed; if (this.GameSpeed > 4.0 && GlobalStats.LimitSpeed) this.GameSpeed = 4f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.Subtract) && input.LastKeyboardState.IsKeyUp(Keys.Subtract)) { if (this.GameSpeed <= 1.0) this.GameSpeed = 0.5f; else --this.GameSpeed; } //fbedard: Click button to Cycle through ships in Combat if (!HelperFunctions.CheckIntersection(this.ShipsInCombat.Rect, input.CursorPosition)) { this.ShipsInCombat.State = UIButton.PressState.Normal; } else { this.ShipsInCombat.State = UIButton.PressState.Hover; if (input.InGameSelect) { if (this.player.empireShipCombat > 0) { AudioManager.PlayCue("echo_affirm"); int nbrship = 0; if (lastshipcombat >= this.player.empireShipCombat) lastshipcombat = 0; foreach (Ship ship in EmpireManager.GetEmpireByName(this.PlayerLoyalty).GetShips()) { if (ship.fleet != null || !ship.InCombat || ship.Mothership != null || !ship.Active || ship.Name == "Subspace Projector") continue; else { if (nbrship == lastshipcombat) { if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedShip = ship; this.ViewToShip(null); this.SelectedShipList.Add(this.SelectedShip); lastshipcombat++; break; } else nbrship++; } } } else { AudioManager.PlayCue("blip_click"); } } } //fbedard: Click button to Cycle through Planets in Combat if (!HelperFunctions.CheckIntersection(this.PlanetsInCombat.Rect, input.CursorPosition)) { this.PlanetsInCombat.State = UIButton.PressState.Normal; } else { this.PlanetsInCombat.State = UIButton.PressState.Hover; if (input.InGameSelect) { if (this.player.empirePlanetCombat > 0) { AudioManager.PlayCue("echo_affirm"); Planet PlanetToView = (Planet)null; int nbrplanet = 0; if (lastplanetcombat >= this.player.empirePlanetCombat) lastplanetcombat = 0; bool flagPlanet; foreach (SolarSystem system in UniverseScreen.SolarSystemList) { foreach (Planet p in system.PlanetList) { if (p.ExploredDict[EmpireManager.GetEmpireByName(Empire.universeScreen.PlayerLoyalty)] && p.RecentCombat) { if (p.Owner == EmpireManager.GetEmpireByName(Empire.universeScreen.PlayerLoyalty)) { if (nbrplanet == lastplanetcombat) PlanetToView = p; else nbrplanet++; } else { flagPlanet = false; foreach (PlanetGridSquare planetGridSquare in p.TilesList) { if (!flagPlanet) { planetGridSquare.TroopsHere.thisLock.EnterReadLock(); foreach (Troop troop in planetGridSquare.TroopsHere) { if (troop.GetOwner() != null && troop.GetOwner() == EmpireManager.GetEmpireByName(Empire.universeScreen.PlayerLoyalty)) { flagPlanet = true; break; } } planetGridSquare.TroopsHere.thisLock.ExitReadLock(); } } if (flagPlanet) { if (nbrplanet == lastplanetcombat) PlanetToView = p; else nbrplanet++; } } } } } if (PlanetToView != null) { this.SelectedShip = (Ship)null; //this.ShipInfoUIElement.SetShip(this.SelectedShip); this.SelectedFleet = (Fleet)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.SelectedSystem = (SolarSystem)null; this.SelectedPlanet = PlanetToView; this.pInfoUI.SetPlanet(PlanetToView); lastplanetcombat++; this.transitionDestination = new Vector3(this.SelectedPlanet.Position.X, this.SelectedPlanet.Position.Y, 9000f); this.LookingAtPlanet = false; this.transitionStartPosition = this.camPos; this.AdjustCamTimer = 2f; this.transitionElapsedTime = 0.0f; this.transDuration = 5f; this.returnToShip = false; this.ViewingShip = false; this.snappingToShip = false; this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; //PlanetToView.OpenCombatMenu(null); } } else { AudioManager.PlayCue("blip_click"); } } } if (!this.LookingAtPlanet) { if (this.HandleGUIClicks(input)) { this.SkipRightOnce = true; this.NeedARelease = true; return; } } else { if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedFleet = (Fleet)null; this.SelectedShip = (Ship)null; this.SelectedShipList.Clear(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; this.SelectedSystem = (SolarSystem)null; } if ((input.CurrentKeyboardState.IsKeyDown(Keys.Back) || input.CurrentKeyboardState.IsKeyDown(Keys.Delete)) && (this.SelectedItem != null && this.SelectedItem.AssociatedGoal.empire == this.player)) { this.player.GetGSAI().Goals.QueuePendingRemoval(this.SelectedItem.AssociatedGoal); bool flag = false; foreach (Ship ship in (List<Ship>)this.player.GetShips()) { if (ship.Role == "construction" && ship.GetAI().OrderQueue.Count > 0) { for (int index = 0; index < ship.GetAI().OrderQueue.Count; ++index) { if (Enumerable.ElementAt<ArtificialIntelligence.ShipGoal>((IEnumerable<ArtificialIntelligence.ShipGoal>)ship.GetAI().OrderQueue, index).goal == this.SelectedItem.AssociatedGoal) { flag = true; ship.GetAI().OrderScrapShip(); break; } } } } if (!flag) { foreach (Planet planet in this.player.GetPlanets()) { foreach (QueueItem queueItem in (List<QueueItem>)planet.ConstructionQueue) { if (queueItem.Goal == this.SelectedItem.AssociatedGoal) { planet.ProductionHere += queueItem.productionTowards; if ((double)planet.ProductionHere > (double)planet.MAX_STORAGE) planet.ProductionHere = planet.MAX_STORAGE; planet.ConstructionQueue.QueuePendingRemoval(queueItem); } } planet.ConstructionQueue.ApplyPendingRemovals(); } } lock (GlobalStats.ClickableItemLocker) { for (int local_10 = 0; local_10 < this.ItemsToBuild.Count; ++local_10) { UniverseScreen.ClickableItemUnderConstruction local_11 = this.ItemsToBuild[local_10]; if (local_11.BuildPos == this.SelectedItem.BuildPos) { this.ItemsToBuild.QueuePendingRemoval(local_11); AudioManager.PlayCue("blip_click"); } } this.ItemsToBuild.ApplyPendingRemovals(); } this.player.GetGSAI().Goals.ApplyPendingRemovals(); this.SelectedItem = (UniverseScreen.ClickableItemUnderConstruction)null; } if (input.CurrentKeyboardState.IsKeyDown(Keys.H) && !input.LastKeyboardState.IsKeyDown(Keys.H) && this.Debug) { this.debugwin = new DebugInfoScreen(this.ScreenManager, this); this.showdebugwindow = !this.showdebugwindow; } if (this.DefiningAO) { if (this.NeedARelease) { if (input.CurrentMouseState.LeftButton == ButtonState.Released) this.NeedARelease = false; } else { this.DefineAO(input); return; } } this.pickedSomethingThisFrame = false; this.input = input; if (this.LookingAtPlanet) this.workersPanel.HandleInput(input); if (this.IsActive) this.EmpireUI.HandleInput(input); if (this.ShowingPlanetToolTip && (double)Vector2.Distance(new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y), this.tippedPlanet.ScreenPos) > (double)this.tippedPlanet.Radius) { this.ShowingPlanetToolTip = false; this.TooltipTimer = 0.5f; } if (this.ShowingSysTooltip && (double)Vector2.Distance(new Vector2((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y), this.tippedSystem.ScreenPos) > (double)this.tippedSystem.Radius) { this.ShowingSysTooltip = false; this.sTooltipTimer = 0.5f; } if (!this.LookingAtPlanet) { Vector3 position = this.ScreenManager.GraphicsDevice.Viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 0.0f), this.projection, this.view, Matrix.Identity); Vector3 direction = this.ScreenManager.GraphicsDevice.Viewport.Unproject(new Vector3((float)input.CurrentMouseState.X, (float)input.CurrentMouseState.Y, 1f), this.projection, this.view, Matrix.Identity) - position; direction.Normalize(); Ray ray = new Ray(position, direction); float num = -ray.Position.Z / ray.Direction.Z; Vector3 vector3 = new Vector3(ray.Position.X + num * ray.Direction.X, ray.Position.Y + num * ray.Direction.Y, 0.0f); this.mouseWorldPos = new Vector2(vector3.X, vector3.Y); if (input.CurrentKeyboardState.IsKeyDown(Keys.B) && !input.LastKeyboardState.IsKeyDown(Keys.B)) { if (!this.showingDSBW) { this.dsbw = new DeepSpaceBuildingWindow(this.ScreenManager, this); AudioManager.PlayCue("echo_affirm"); this.showingDSBW = true; } else this.showingDSBW = false; } if (input.CurrentKeyboardState.IsKeyDown(Keys.L) && !input.LastKeyboardState.IsKeyDown(Keys.L)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.ScreenManager.AddScreen((GameScreen)new PlanetListScreen(this.ScreenManager, this.EmpireUI)); } if (input.CurrentKeyboardState.IsKeyDown(Keys.F1) && !input.LastKeyboardState.IsKeyDown(Keys.F1)) { AudioManager.PlayCue("sd_ui_accept_alt3"); if (!this.showingFTLOverlay) { this.showingFTLOverlay = true; } else this.showingFTLOverlay = false; } if (input.CurrentKeyboardState.IsKeyDown(Keys.F2) && !input.LastKeyboardState.IsKeyDown(Keys.F2)) { AudioManager.PlayCue("sd_ui_accept_alt3"); if (!this.showingRangeOverlay) { this.showingRangeOverlay = true; } else this.showingRangeOverlay = false; } if (input.CurrentKeyboardState.IsKeyDown(Keys.K) && !input.LastKeyboardState.IsKeyDown(Keys.K)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.ScreenManager.AddScreen((GameScreen)new ShipListScreen(this.ScreenManager, this.EmpireUI)); } if (input.CurrentKeyboardState.IsKeyDown(Keys.J) && !input.LastKeyboardState.IsKeyDown(Keys.J)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.ScreenManager.AddScreen((GameScreen)new FleetDesignScreen(this.EmpireUI)); FleetDesignScreen.Open = true; } if (input.CurrentKeyboardState.IsKeyDown(Keys.H) && !input.LastKeyboardState.IsKeyDown(Keys.H)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.aw.isOpen = !this.aw.isOpen; } if (input.CurrentKeyboardState.IsKeyDown(Keys.PageUp) && !input.LastKeyboardState.IsKeyDown(Keys.PageUp)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; this.transitionDestination.Z = 4500f; this.snappingToShip = true; this.ViewingShip = true; } if (input.CurrentKeyboardState.IsKeyDown(Keys.PageDown) && !input.LastKeyboardState.IsKeyDown(Keys.PageDown)) { AudioManager.PlayCue("sd_ui_accept_alt3"); this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; this.transitionDestination.X = this.camPos.X; this.transitionDestination.Y = this.camPos.Y; this.transitionDestination.Z = 4200000f * UniverseScreen.GameScaleStatic; } if (this.Debug) { if (input.C) ResourceManager.CreateShipAtPoint("Kulrathi Assault Ship", this.player, this.mouseWorldPos); else if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && input.C) ResourceManager.CreateShipAtPoint("Kulrathi Assault Ship", EmpireManager.GetEmpireByName("The Remnant"), this.mouseWorldPos); try { if (input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && input.CurrentKeyboardState.IsKeyDown(Keys.Z) && !input.LastKeyboardState.IsKeyDown(Keys.Z)) HelperFunctions.CreateFleetAt("Fleet 2", EmpireManager.GetEmpireByName("The Remnant"), this.mouseWorldPos); else if (input.CurrentKeyboardState.IsKeyDown(Keys.Z) && !input.LastKeyboardState.IsKeyDown(Keys.Z)) HelperFunctions.CreateFleetAt("Fleet 1", this.player, this.mouseWorldPos); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.InnerException); } if (this.SelectedShip != null && this.Debug) { if (input.CurrentKeyboardState.IsKeyDown(Keys.X) && !input.LastKeyboardState.IsKeyDown(Keys.X)) this.SelectedShip.Die((GameplayObject)null, false); } else if (this.SelectedPlanet != null && this.Debug && (input.CurrentKeyboardState.IsKeyDown(Keys.X) && !input.LastKeyboardState.IsKeyDown(Keys.X))) { foreach (KeyValuePair<string, Troop> keyValuePair in ResourceManager.TroopsDict) this.SelectedPlanet.AssignTroopToTile(ResourceManager.CreateTroop(keyValuePair.Value, EmpireManager.GetEmpireByName("The Remnant"))); } if (input.CurrentKeyboardState.IsKeyDown(Keys.X) && !input.LastKeyboardState.IsKeyDown(Keys.X)) ResourceManager.CreateShipAtPoint("Target Dummy", EmpireManager.GetEmpireByName("The Remnant"), this.mouseWorldPos); if (input.CurrentKeyboardState.IsKeyDown(Keys.V) && !input.LastKeyboardState.IsKeyDown(Keys.V)) ResourceManager.CreateShipAtPoint("Remnant Mothership", EmpireManager.GetEmpireByName("The Remnant"), this.mouseWorldPos); } this.HandleFleetSelections(input); if (input.Escaped) { this.snappingToShip = false; this.ViewingShip = false; if ((double)this.camHeight < 1175000.0 && (double)this.camHeight > 146900.0) { this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; this.transitionDestination = new Vector3(this.camPos.X, this.camPos.Y, 1175000f); } else if ((double)this.camHeight < 146900.0) { this.AdjustCamTimer = 1f; this.transitionElapsedTime = 0.0f; this.transitionDestination = new Vector3(this.camPos.X, this.camPos.Y, 147000f); } else if (this.viewState < UniverseScreen.UnivScreenState.SystemView) this.transitionDestination =new Vector3(this.camPos.X, this.camPos.Y, this.GetZfromScreenState(UnivScreenState.SystemView)); } if (input.Tab) this.ShowShipNames = !this.ShowShipNames; this.HandleRightMouseNew(input); if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { if ((double)this.ClickTimer < (double)this.TimerDelay) { this.SelectedShipList.Clear(); if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedShip = (Ship)null; if (this.viewState <= UniverseScreen.UnivScreenState.SystemView) { foreach (UniverseScreen.ClickablePlanets clickablePlanets in this.ClickPlanetList) { if ((double)Vector2.Distance(input.CursorPosition, clickablePlanets.ScreenPos) <= (double)clickablePlanets.Radius) { AudioManager.PlayCue("sub_bass_whoosh"); this.SelectedPlanet = clickablePlanets.planetToClick; if (!this.SnapBackToSystem) this.HeightOnSnap = this.camHeight; this.ViewPlanet((object)this.SelectedPlanet); } } } foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableShip.ScreenPos) <= (double)clickableShip.Radius) { this.pickedSomethingThisFrame = true; this.SelectedShipList.Add(clickableShip.shipToClick); using (List<UniverseScreen.ClickableShip>.Enumerator enumerator = this.ClickableShipsList.GetEnumerator()) { while (enumerator.MoveNext()) { UniverseScreen.ClickableShip current = enumerator.Current; if (clickableShip.shipToClick != current.shipToClick && current.shipToClick.loyalty == clickableShip.shipToClick.loyalty && current.shipToClick.Role == clickableShip.shipToClick.Role) this.SelectedShipList.Add(current.shipToClick); } break; } } } if (this.viewState > UniverseScreen.UnivScreenState.SystemView) { lock (GlobalStats.ClickableSystemsLock) { for (int local_27 = 0; local_27 < this.ClickableSystems.Count; ++local_27) { UniverseScreen.ClickableSystem local_28 = this.ClickableSystems[local_27]; if ((double)Vector2.Distance(input.CursorPosition, local_28.ScreenPos) <= (double)local_28.Radius) { if (local_28.systemToClick.ExploredDict[this.player]) { AudioManager.GetCue("sub_bass_whoosh").Play(); this.HeightOnSnap = this.camHeight; this.ViewSystem(local_28.systemToClick); } else this.PlayNegativeSound(); } } } } } else if (this.SelectedShip !=null) this.ClickTimer = 0.0f; //this.ClickTimer = 0.5f; } this.HandleSelectionBox(input); this.HandleScrolls(input); } if (this.LookingAtPlanet) { if (input.Tab) this.ShowShipNames = !this.ShowShipNames; if ((input.Escaped || input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Released || this.workersPanel is ColonyScreen && (this.workersPanel as ColonyScreen).close.HandleInput(input)) && (!(this.workersPanel is ColonyScreen) || !(this.workersPanel as ColonyScreen).ClickedTroop)) { if (this.workersPanel is ColonyScreen && (this.workersPanel as ColonyScreen).p.Owner == null) { this.AdjustCamTimer = 1f; if (this.returnToShip) { this.ViewingShip = true; this.returnToShip = false; this.snappingToShip = true; this.transitionDestination.Z = this.transitionStartPosition.Z; } else this.transitionDestination = this.transitionStartPosition; this.transitionElapsedTime = 0.0f; this.LookingAtPlanet = false; } else { this.AdjustCamTimer = 1f; if (this.returnToShip) { this.ViewingShip = true; this.returnToShip = false; this.snappingToShip = true; this.transitionDestination.Z = this.transitionStartPosition.Z; } else this.transitionDestination = this.transitionStartPosition; this.transitionElapsedTime = 0.0f; this.LookingAtPlanet = false; } } } if (input.InGameSelect && !this.pickedSomethingThisFrame && (!input.CurrentKeyboardState.IsKeyDown(Keys.LeftShift) && !this.pieMenu.Visible)) { if (this.SelectedShip != null && this.SelectedShip != this.previousSelection) this.previousSelection = this.SelectedShip; this.SelectedShip = (Ship)null; this.SelectedShipList.Clear(); this.SelectedFleet = (Fleet)null; lock (GlobalStats.FleetButtonLocker) { for (int local_31 = 0; local_31 < this.FleetButtons.Count; ++local_31) { UniverseScreen.FleetButton local_32 = this.FleetButtons[local_31]; if (HelperFunctions.CheckIntersection(local_32.ClickRect, input.CursorPosition)) { this.SelectedFleet = local_32.Fleet; this.SelectedShipList.Clear(); foreach (Ship item_7 in (List<Ship>)this.SelectedFleet.Ships) { if (item_7.inSensorRange) this.SelectedShipList.Add(item_7); } if (this.SelectedShipList.Count == 1) { this.SelectedShip = this.SelectedShipList[0]; this.ShipInfoUIElement.SetShip(this.SelectedShip); this.SelectedShipList.Clear(); } else if (this.SelectedShipList.Count > 1) this.shipListInfoUI.SetShipList((List<Ship>)this.SelectedShipList, true); this.SelectedSomethingTimer = 3f; if ((double)this.ClickTimer < (double)this.TimerDelay) { this.ViewingShip = false; this.AdjustCamTimer = 0.5f; this.transitionDestination.X = this.SelectedFleet.findAveragePosition().X; this.transitionDestination.Y = this.SelectedFleet.findAveragePosition().Y; if (this.viewState < UniverseScreen.UnivScreenState.SystemView) this.transitionDestination.Z = this.GetZfromScreenState(UniverseScreen.UnivScreenState.SystemView); } else this.ClickTimer = 0.0f; } } } } this.cState = this.SelectedShip != null || this.SelectedShipList.Count > 0 ? UniverseScreen.CursorState.Move : UniverseScreen.CursorState.Normal; if (this.SelectedShip == null && this.SelectedShipList.Count <= 0) return; foreach (UniverseScreen.ClickableShip clickableShip in this.ClickableShipsList) { if ((double)Vector2.Distance(input.CursorPosition, clickableShip.ScreenPos) <= (double)clickableShip.Radius) this.cState = UniverseScreen.CursorState.Follow; } if (this.cState == UniverseScreen.CursorState.Follow) return; lock (GlobalStats.ClickableSystemsLock) { foreach (UniverseScreen.ClickablePlanets item_9 in this.ClickPlanetList) { if ((double)Vector2.Distance(input.CursorPosition, item_9.ScreenPos) <= (double)item_9.Radius && item_9.planetToClick.habitable) this.cState = UniverseScreen.CursorState.Orbit; } } }