//private float transitionElapsedTime; public EncounterScreen(UniverseScreen screen, Empire playerEmpire, Empire targetEmp, SolarSystem tarSys, Encounter e) { this.encounter = e; this.encounter.CurrentMessage = 0; this.encounter.SetPlayerEmpire(playerEmpire); this.encounter.SetSys(tarSys); this.encounter.SetTarEmp(targetEmp); this.screen = screen; base.IsPopup = true; base.TransitionOnTime = TimeSpan.FromSeconds(0.25); base.TransitionOffTime = TimeSpan.FromSeconds(0.25); }
public EncounterPopup(UniverseScreen s, Empire playerEmpire, Empire targetEmp, SolarSystem tarSys, Encounter e) { this.screen = s; this.encounter = e; this.encounter.CurrentMessage = 0; this.encounter.SetPlayerEmpire(playerEmpire); this.encounter.SetSys(tarSys); this.encounter.SetTarEmp(targetEmp); this.fade = true; base.IsPopup = true; this.FromGame = true; base.TransitionOnTime = TimeSpan.FromSeconds(0.25); base.TransitionOffTime = TimeSpan.FromSeconds(0); this.r = new Rectangle(0, 0, 600, 600); }
public static List<SpaceJunk> MakeJunk(int howMuchJunk, Vector2 Position, SolarSystem s) { List<SpaceJunk> JunkList = new List<SpaceJunk>(); if (UniverseScreen.JunkList.Count > 200) { return JunkList; } for (int i = 0; i < howMuchJunk; i++) { SpaceJunk newJunk = new SpaceJunk(Position) { system = s }; newJunk.LoadContent(SpaceJunk.contentManager); JunkList.Add(newJunk); } return JunkList; }
public void AddBeingInvadedNotification(SolarSystem beingInvaded, Empire Invader) { Notification cNote = new Notification() { RelevantEmpire = Invader }; string[] singular = new string[] { Invader.data.Traits.Singular, Localizer.Token(1500), "\n", Localizer.Token(1501), beingInvaded.Name, Localizer.Token(1502) }; cNote.Message = string.Concat(singular); cNote.ReferencedItem1 = beingInvaded; cNote.IconPath = "NewUI/icon_planet_terran_01_mid"; cNote.Action = "SnapToSystem"; cNote.ClickRect = new Rectangle(this.NotificationArea.X, this.NotificationArea.Y, 64, 64); cNote.DestinationRect = new Rectangle(this.NotificationArea.X, this.NotificationArea.Y + this.NotificationArea.Height - (this.NotificationList.Count + 1) * 70, 64, 64); AudioManager.PlayCue("sd_notify_alert"); lock (GlobalStats.NotificationLocker) { this.NotificationList.Add(cNote); } }
public SpaceRoad(SolarSystem Origin, SolarSystem Destination, Empire empire, float SSPBudget, float nodeMaintenance) { this.Origin = Origin; this.Destination = Destination; float Distance = Vector2.Distance(Origin.Position, Destination.Position); //int galaxySizeMod = (int)((Empire.universeScreen.Size.X ) / 250); float offset = (Empire.ProjectorRadius * 1.5f);// +galaxySizeMod; this.NumberOfProjectors = (int)(Math.Ceiling(Distance / offset)); if (SSPBudget - nodeMaintenance * this.NumberOfProjectors <= 0) { this.NumberOfProjectors = 0; return ; } for (int i = 0; i < this.NumberOfProjectors; i++) { RoadNode node = new RoadNode(); float angle = HelperFunctions.findAngleToTarget(Origin.Position, Destination.Position); node.Position = HelperFunctions.GeneratePointOnCircle(angle, Origin.Position, (float)i * (Distance / this.NumberOfProjectors)); bool reallyAdd = true; empire.BorderNodeLocker.EnterReadLock(); { foreach (Empire.InfluenceNode bordernode in empire.BorderNodes) { if (Vector2.Distance(node.Position, bordernode.Position) >= bordernode.Radius) { continue; } reallyAdd = false; } } empire.BorderNodeLocker.ExitReadLock(); if (reallyAdd) { this.RoadNodesList.Add(node); } } return ; }
public FleetGoal(SolarSystem toAttack, Fleet fleet, Fleet.FleetGoalType t) { this.fleet = fleet; this.sysToAttack = toAttack; this.type = t; }
public void SetSystem(SolarSystem s) { if (this.s != s) { this.SelectionTimer = 0f; } this.s = s; }
public void ApplyProductiontoQueue(float howMuch, int whichItem) { if (this.Crippled_Turns > 0 || this.RecentCombat || howMuch <= 0.0) return; this.planetLock.EnterWriteLock(); float cost = 0; if (this.ConstructionQueue.Count > 0 && this.ConstructionQueue.Count > whichItem) { QueueItem item = this.ConstructionQueue[whichItem]; cost = item.Cost; if (item.isShip) //howMuch += howMuch * this.ShipBuildingModifier; cost *= this.ShipBuildingModifier; cost -= item.productionTowards; if (howMuch < cost) { item.productionTowards += howMuch; //if (item.productionTowards >= cost) // this.ProductionHere += item.productionTowards - cost; } else { howMuch -= cost; item.productionTowards = item.Cost;// *this.ShipBuildingModifier; this.ProductionHere += howMuch; } this.ConstructionQueue[whichItem] = item; } else this.ProductionHere += howMuch; this.planetLock.ExitWriteLock(); for (int index1 = 0; index1 < this.ConstructionQueue.Count; ++index1) { QueueItem queueItem = this.ConstructionQueue[index1]; //Added by gremlin remove exess troops from queue if (queueItem.isTroop) { int space = 0; foreach (PlanetGridSquare tilesList in this.TilesList) { if (tilesList.TroopsHere.Count >= tilesList.number_allowed_troops || tilesList.building != null && (tilesList.building == null || tilesList.building.CombatStrength != 0)) { continue; } space++; } if (space < 1) { if (queueItem.productionTowards == 0) { this.ConstructionQueue.Remove(queueItem); } else { ProductionHere += queueItem.productionTowards; if (ProductionHere > MAX_STORAGE) ProductionHere = MAX_STORAGE; if (queueItem.pgs != null) queueItem.pgs.QItem = null; ConstructionQueue.Remove(queueItem); } } } if ((double)queueItem.productionTowards >= (double)queueItem.Cost && queueItem.NotifyOnEmpty == false) this.queueEmptySent = true; else if ((double)queueItem.productionTowards >= (double)queueItem.Cost) this.queueEmptySent = false; if (queueItem.isBuilding && (double)queueItem.productionTowards >= (double)queueItem.Cost) { Building building = ResourceManager.GetBuilding(queueItem.Building.Name); this.BuildingList.Add(building); this.Fertility -= ResourceManager.GetBuilding(queueItem.Building.Name).MinusFertilityOnBuild; if ((double)this.Fertility < 0.0) this.Fertility = 0.0f; if (queueItem.pgs != null) { if (queueItem.Building != null && queueItem.Building.Name == "Biospheres") { queueItem.pgs.Habitable = true; queueItem.pgs.Biosphere = true; queueItem.pgs.building = (Building)null; queueItem.pgs.QItem = (QueueItem)null; } else { queueItem.pgs.building = building; queueItem.pgs.QItem = (QueueItem)null; } } if (queueItem.Building.Name == "Space Port") { this.Station.planet = this; this.Station.ParentSystem = this.system; this.Station.LoadContent(Planet.universeScreen.ScreenManager); this.HasShipyard = true; } if (queueItem.Building.AllowShipBuilding) this.HasShipyard = true; if (building.EventOnBuild != null && this.Owner != null && this.Owner == EmpireManager.GetEmpireByName(Planet.universeScreen.PlayerLoyalty)) Planet.universeScreen.ScreenManager.AddScreen((GameScreen)new EventPopup(Planet.universeScreen, EmpireManager.GetEmpireByName(Planet.universeScreen.PlayerLoyalty), ResourceManager.EventsDict[building.EventOnBuild], ResourceManager.EventsDict[building.EventOnBuild].PotentialOutcomes[0], true)); this.ConstructionQueue.QueuePendingRemoval(queueItem); } else if (queueItem.isShip && !ResourceManager.ShipsDict.ContainsKey(queueItem.sData.Name)) { this.ConstructionQueue.QueuePendingRemoval(queueItem); this.ProductionHere += queueItem.productionTowards; if ((double)this.ProductionHere > (double)this.MAX_STORAGE) this.ProductionHere = this.MAX_STORAGE; } else if (queueItem.isShip && queueItem.productionTowards >= queueItem.Cost) { Ship shipAt; if (queueItem.isRefit) shipAt = ResourceManager.CreateShipAt(queueItem.sData.Name, this.Owner, this, true, !string.IsNullOrEmpty(queueItem.RefitName) ? queueItem.RefitName : queueItem.sData.Name, queueItem.sData.Level); else shipAt = ResourceManager.CreateShipAt(queueItem.sData.Name, this.Owner, this, true); this.ConstructionQueue.QueuePendingRemoval(queueItem); using (List<string>.Enumerator enumerator = Enumerable.ToList<string>((IEnumerable<string>)shipAt.GetMaxGoods().Keys).GetEnumerator()) { //label_35: while (enumerator.MoveNext()) { string current = enumerator.Current; while (true) { if ((double)this.ResourcesDict[current] > 0.0 && (double)shipAt.GetCargo()[current] < (double)shipAt.GetMaxGoods()[current]) { Dictionary<string, float> dictionary; string index2; (dictionary = this.ResourcesDict)[index2 = current] = dictionary[index2] - 1f; shipAt.AddGood(current, 1); } else break; //goto label_35; } } } if (queueItem.sData.Role == "station" || queueItem.sData.Role == "platform") { int num = this.Shipyards.Count / 9; shipAt.Position = this.Position + HelperFunctions.GeneratePointOnCircle((float)(this.Shipyards.Count * 40), Vector2.Zero, (float)(2000 + 2000 * num * this.scale)); shipAt.Center = shipAt.Position; shipAt.TetherToPlanet(this); this.Shipyards.TryAdd(shipAt.guid, shipAt); } if (queueItem.Goal != null) { if (queueItem.Goal.GoalName == "BuildConstructionShip") { shipAt.GetAI().OrderDeepSpaceBuild(queueItem.Goal); shipAt.Role = "construction"; shipAt.VanityName = "Construction Ship"; } else if (queueItem.Goal.GoalName != "BuildDefensiveShips" && queueItem.Goal.GoalName != "BuildOffensiveShips" && queueItem.Goal.GoalName != "FleetRequisition") { ++queueItem.Goal.Step; } else { if (this.Owner != EmpireManager.GetEmpireByName(Planet.universeScreen.PlayerLoyalty)) this.Owner.ForcePoolAdd(shipAt); queueItem.Goal.ReportShipComplete(shipAt); } } else if ((queueItem.sData.Role != "station" || queueItem.sData.Role == "platform") && this.Owner != EmpireManager.GetEmpireByName(Planet.universeScreen.PlayerLoyalty)) this.Owner.ForcePoolAdd(shipAt); } else if (queueItem.isTroop && (double)queueItem.productionTowards >= (double)queueItem.Cost) { Troop troop = ResourceManager.CreateTroop(queueItem.troop, this.Owner); if (this.AssignTroopToTile(troop)) { troop.SetOwner(this.Owner); if (queueItem.Goal != null) { Goal step = queueItem.Goal; step.Step = step.Step + 1; } this.ConstructionQueue.QueuePendingRemoval(queueItem); } } } this.ConstructionQueue.ApplyPendingRemovals(); }
private void DoSystemDefense(float elapsedTime) { //if (this.Owner.InCombat || this.State == AIState.Intercept) // return; if (this.SystemToDefend == null) { this.SystemToDefend = this.Owner.GetSystem(); } //if(this.Owner.GetSystem() != this.SystemToDefend) this.AwaitOrders(elapsedTime); //this.State = AIState.AwaitingOrders; }
public void DoExplore(float elapsedTime) { this.HasPriorityOrder = true; this.IgnoreCombat = true; if (this.ExplorationTarget == null) { this.ExplorationTarget = this.Owner.loyalty.GetGSAI().AssignExplorationTarget(this.Owner); if (this.ExplorationTarget == null) { this.OrderQueue.Clear(); this.State = AIState.AwaitingOrders; return; } } else if (this.DoExploreSystem(elapsedTime)) { if (this.Owner.loyalty == ArtificialIntelligence.universeScreen.player) { //added by gremlin add shamatts notification here string planetsInfo = ""; Dictionary<string, int> planetsTypesNumber = new Dictionary<string, int>(); SolarSystem system = this.ExplorationTarget; if (system.PlanetList.Count > 0) { foreach (Planet planet in system.PlanetList) { // some planets don't have Type set and it is null if (planet.Type == null) { planet.Type = "Other"; } if (!planetsTypesNumber.ContainsKey(planet.Type)) { planetsTypesNumber.Add(planet.Type, 1); } else { planetsTypesNumber[planet.Type] += 1; } } foreach (KeyValuePair<string, int> pair in planetsTypesNumber) { planetsInfo = planetsInfo + "\n" + pair.Value + " " + pair.Key; } } Notification cNote = new Notification() { Pause = false, RelevantEmpire = this.Owner.loyalty, Message = string.Concat(system.Name, " system explored."), ReferencedItem1 = system, IconPath = "NewUI/icon_planet_terran_01_mid", Action = "SnapToExpandSystem", ClickRect = new Rectangle(Planet.universeScreen.NotificationManager.NotificationArea.X, Planet.universeScreen.NotificationManager.NotificationArea.Y, 64, 64), DestinationRect = new Rectangle(Planet.universeScreen.NotificationManager.NotificationArea.X, Planet.universeScreen.NotificationManager.NotificationArea.Y + Planet.universeScreen.NotificationManager.NotificationArea.Height - (Planet.universeScreen.NotificationManager.NotificationList.Count + 1) * 70, 64, 64) }; cNote.Message = cNote.Message + planetsInfo; if (system.combatTimer > 0) { cNote.Message += "\nCombat in system!!!"; } if (system.OwnerList.Count > 0 && !system.OwnerList.Contains(this.Owner.loyalty)) { cNote.Message += "\nContested system!!!"; } foreach (Planet stuff in system.PlanetList) { foreach (Building tile in stuff.BuildingList) { if (tile.IsCommodity) { cNote.Message += "\n" + tile.Name + " on " + stuff.Name; break; } } } AudioManager.PlayCue("sd_ui_notification_warning"); lock (GlobalStats.NotificationLocker) { Planet.universeScreen.NotificationManager.NotificationList.Add(cNote); } } this.ExplorationTarget = null; } }
public DiplomacyScreen(Empire e, Empire us, string which, SolarSystem s) { float TheirOpinionOfUs; e.GetRelations()[us].turnsSinceLastContact = 0; this.sysToDiscuss = s; this.them = e; this.playerEmpire = us; this.whichDialogue = which; base.TransitionOnTime = TimeSpan.FromSeconds(1); string str = which; string str1 = str; if (str != null) { switch (str1) { case "Invaded NA Pact": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; break; } case "Invaded Start War": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; break; } case "Declare War Defense": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; break; } case "Declare War BC": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; break; } case "Declare War BC TarSys": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; break; } case "Stole Claim": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; break; } case "Stole Claim 2": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; break; } case "Stole Claim 3": { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; break; } default: { TheirOpinionOfUs = this.them.GetRelations()[this.playerEmpire].GetStrength(); if (TheirOpinionOfUs < 0f) { TheirOpinionOfUs = 0f; } this.TheirText = this.GetDialogue(TheirOpinionOfUs); base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } } } else { TheirOpinionOfUs = this.them.GetRelations()[this.playerEmpire].GetStrength(); if (TheirOpinionOfUs < 0f) { TheirOpinionOfUs = 0f; } this.TheirText = this.GetDialogue(TheirOpinionOfUs); base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } base.TransitionOnTime = TimeSpan.FromSeconds(1); }
public static List<SpaceJunk> MakeJunk(int howMuchJunk, Vector2 Position, SolarSystem s, GameplayObject source) { List<SpaceJunk> JunkList = new List<SpaceJunk>(); for (int i = 0; i < howMuchJunk; i++) { SpaceJunk newJunk = new SpaceJunk(Position, source) { system = s }; newJunk.LoadContent(SpaceJunk.contentManager); JunkList.Add(newJunk); } return JunkList; }
public void SnapToSystem(SolarSystem system) { AudioManager.PlayCue("sub_bass_whoosh"); this.screen.SnapViewSystem(system, UniverseScreen.UnivScreenState.SystemView); }
public void SnapToExpandedSystem(Planet p, SolarSystem system) { AudioManager.PlayCue("sub_bass_whoosh"); p= p!= null ? this.screen.SelectedPlanet = p:null; this.screen.SelectedSystem = system; // this.screen.mouseWorldPos = p == null ? system.Position : p.Position; this.screen.SnapViewSystem(system, UniverseScreen.UnivScreenState.GalaxyView); }
public void Update(float elapsedTime, SolarSystem system) { this.BeamList.ApplyPendingRemovals(); this.bucketUpdateTimer -= elapsedTime; if ((double)this.bucketUpdateTimer <= 0.0) { this.ClearBuckets(); if (system != null) { if (system.CombatInSystem && system.ShipList.Count > 10) { if (!this.FineDetail || this.Buckets.Count < 20 && this.CollidableProjectiles.Count > 0) { this.Setup(200000, 200000, 6000, system.Position); this.FineDetail = true; } } else if (this.FineDetail || this.Buckets.Count > 20 || this.CollidableProjectiles.Count == 0) this.Setup(200000, 200000, 50000, system.Position); } for (int index = 0; index < this.CollidableObjects.Count; ++index) { GameplayObject gameplayObject = this.CollidableObjects[index]; if (gameplayObject != null) { if (gameplayObject.GetSystem() != null && system == null) this.CollidableObjects.QueuePendingRemoval(gameplayObject); else if (gameplayObject != null) { if (gameplayObject.Active) this.RegisterObject(gameplayObject); else this.CollidableObjects.QueuePendingRemoval(gameplayObject); } } } for (int index = 0; index < this.CollidableProjectiles.Count; ++index) { Projectile projectile = this.CollidableProjectiles[index]; if (projectile.GetSystem() != null && system == null) this.CollidableProjectiles.QueuePendingRemoval(projectile); else if (projectile != null && projectile.Active) this.RegisterObject((GameplayObject)projectile); } this.bucketUpdateTimer = 0.5f; } if (this.CollidableProjectiles.Count > 0) { for (int index = 0; index < this.CollidableObjects.Count; ++index) { GameplayObject gameplayObject = this.CollidableObjects[index]; if (!(gameplayObject.GetSystem() != null & system == null) && gameplayObject != null && (!(gameplayObject is Ship) || system != null || (gameplayObject as Ship).GetAI().BadGuysNear)) this.MoveAndCollide(gameplayObject); } } for (int index = 0; index < this.BeamList.Count; ++index) { Beam beam = this.BeamList[index]; if (beam != null) this.CollideBeam(beam); } this.CollidableObjects.ApplyPendingRemovals(); this.CollidableProjectiles.ApplyPendingRemovals(); }
public override void ExitScreen() { if (this.MultiThread) { // this.ShipUpdateThread.Abort(); this.WorkerThread.Abort(); foreach (Thread thread in this.SystemUpdateThreadList) thread.Abort(); } this.EmpireUI.empire = (Empire)null; this.EmpireUI = (EmpireUIOverlay)null; UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableProjectiles.Clear(); UniverseScreen.ShipSpatialManager.CollidableObjects.Clear(); this.ScreenManager.Music.Stop(AudioStopOptions.Immediate); this.NebulousShit.Clear(); this.bloomComponent = (BloomComponent)null; this.bg3d.BGItems.Clear(); this.bg3d = (Background3D)null; this.playerShip = (Ship)null; this.ShipToView = (Ship)null; foreach (Ship ship in (List<Ship>)this.MasterShipList) ship.TotallyRemove(); this.MasterShipList.ApplyPendingRemovals(); this.MasterShipList.Clear(); foreach (SolarSystem solarSystem in UniverseScreen.SolarSystemList) { solarSystem.spatialManager.CollidableProjectiles.Clear(); solarSystem.spatialManager.CollidableObjects.Clear(); solarSystem.spatialManager.ClearBuckets(); solarSystem.spatialManager.Destroy(); solarSystem.spatialManager = (SpatialManager)null; solarSystem.FiveClosestSystems.Clear(); foreach (Planet planet in solarSystem.PlanetList) { planet.TilesList = new List<PlanetGridSquare>(); if (planet.SO != null) { planet.SO.Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)planet.SO); planet.SO = (SceneObject)null; } } foreach (Asteroid asteroid in (List<Asteroid>)solarSystem.AsteroidsList) { if (asteroid.GetSO() != null) { asteroid.GetSO().Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)asteroid.GetSO()); } } solarSystem.AsteroidsList.Clear(); foreach (Moon moon in solarSystem.MoonList) { if (moon.GetSO() != null) { moon.GetSO().Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)moon.GetSO()); } } solarSystem.MoonList.Clear(); } foreach (Empire empire in EmpireManager.EmpireList) empire.CleanOut(); foreach (SpaceJunk spaceJunk in (List<SpaceJunk>)UniverseScreen.JunkList) { spaceJunk.trailEmitter = (ParticleEmitter)null; spaceJunk.JunkSO.Clear(); this.ScreenManager.inter.ObjectManager.Remove((ISceneObject)spaceJunk.JunkSO); spaceJunk.JunkSO = (SceneObject)null; } UniverseScreen.JunkList.Clear(); this.SelectedShip = (Ship)null; this.SelectedFleet = (Fleet)null; this.SelectedPlanet = (Planet)null; this.SelectedSystem = (SolarSystem)null; ShieldManager.shieldList.Clear(); ShieldManager.PlanetaryShieldList.Clear(); this.PlanetsDict.Clear(); this.ClickableFleetsList.Clear(); this.ClickableShipsList.Clear(); this.ClickPlanetList.Clear(); this.ClickableSystems.Clear(); UniverseScreen.DeepSpaceManager.ClearBuckets(); UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableObjects.Clear(); UniverseScreen.DeepSpaceManager.CollidableProjectiles.Clear(); UniverseScreen.DeepSpaceManager.ClearBuckets(); UniverseScreen.DeepSpaceManager.Destroy(); UniverseScreen.DeepSpaceManager = (SpatialManager)null; UniverseScreen.SolarSystemList.Clear(); this.starfield.UnloadContent(); this.starfield.Dispose(); UniverseScreen.SolarSystemList.Clear(); this.beamflashes.UnloadContent(); this.explosionParticles.UnloadContent(); this.photonExplosionParticles.UnloadContent(); this.explosionSmokeParticles.UnloadContent(); this.projectileTrailParticles.UnloadContent(); this.fireTrailParticles.UnloadContent(); this.smokePlumeParticles.UnloadContent(); this.fireParticles.UnloadContent(); this.engineTrailParticles.UnloadContent(); this.flameParticles.UnloadContent(); this.sparks.UnloadContent(); this.lightning.UnloadContent(); this.flash.UnloadContent(); this.star_particles.UnloadContent(); this.neb_particles.UnloadContent(); this.SolarSystemDict.Clear(); ShipDesignScreen.screen = (UniverseScreen)null; Fleet.screen = (UniverseScreen)null; Bomb.screen = (UniverseScreen)null; Anomaly.screen = (UniverseScreen)null; PlanetScreen.screen = (UniverseScreen)null; MinimapButtons.screen = (UniverseScreen)null; Projectile.contentManager = this.ScreenManager.Content; Projectile.universeScreen = (UniverseScreen)null; ShipModule.universeScreen = (UniverseScreen)null; Asteroid.universeScreen = (UniverseScreen)null; Empire.universeScreen = (UniverseScreen)null; SpaceJunk.universeScreen = (UniverseScreen)null; ResourceManager.universeScreen = (UniverseScreen)null; Planet.universeScreen = (UniverseScreen)null; Weapon.universeScreen = (UniverseScreen)null; Ship.universeScreen = (UniverseScreen)null; ArtificialIntelligence.universeScreen = (UniverseScreen)null; MissileAI.universeScreen = (UniverseScreen)null; Moon.universeScreen = (UniverseScreen)null; CombatScreen.universeScreen = (UniverseScreen)null; MuzzleFlashManager.universeScreen = (UniverseScreen)null; FleetDesignScreen.screen = (UniverseScreen)null; ExplosionManager.universeScreen = (UniverseScreen)null; FTLManager.universeScreen = (UniverseScreen)null; DroneAI.universeScreen = (UniverseScreen)null; StatTracker.SnapshotsDict.Clear(); EmpireManager.EmpireList.Clear(); this.ScreenManager.inter.Unload(); //GC.Collect(2, GCCollectionMode.Optimized); this.Dispose(); base.ExitScreen(); }
public DiplomacyScreen(Empire e, Empire us, string which, Planet p) { float TheirOpinionOfUs; e.GetRelations()[us].turnsSinceLastContact = 0; this.pToDiscuss = p; this.sysToDiscuss = p.system; this.them = e; this.playerEmpire = us; this.whichDialogue = which; base.TransitionOnTime = TimeSpan.FromSeconds(1); string str = which; string str1 = str; if (str != null) { if (str1 == "Declare War Defense") { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } else if (str1 == "Declare War BC") { this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } else { if (str1 != "Declare War BC TarSys") { TheirOpinionOfUs = this.them.GetRelations()[this.playerEmpire].GetStrength(); if (TheirOpinionOfUs < 0f) { TheirOpinionOfUs = 0f; } this.TheirText = this.GetDialogue(TheirOpinionOfUs); base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } this.TheirText = this.GetDialogueByName(which); this.dState = DiplomacyScreen.DialogState.End; this.WarDeclared = true; base.TransitionOnTime = TimeSpan.FromSeconds(1); return; } } TheirOpinionOfUs = this.them.GetRelations()[this.playerEmpire].GetStrength(); if (TheirOpinionOfUs < 0f) { TheirOpinionOfUs = 0f; } this.TheirText = this.GetDialogue(TheirOpinionOfUs); base.TransitionOnTime = TimeSpan.FromSeconds(1); }
public void SetDestination(SolarSystem s) { this.Destination = s; }
public void OrderSystemDefense(SolarSystem system) { //if (this.State == AIState.Intercept || this.Owner.InCombatTimer > 0) // return; //bool inSystem = true; //if (this.Owner.BaseCanWarp && Vector2.Distance(system.Position, this.Owner.Position) / this.Owner.velocityMaximum > 11) // inSystem = false; //else // inSystem = this.Owner.GetSystem() == this.SystemToDefend; //if (this.SystemToDefend == null) //{ // this.HasPriorityOrder = false; // this.SystemToDefend = system; // this.OrderQueue.Clear(); //} //else ArtificialIntelligence.ShipGoal goal = this.OrderQueue.LastOrDefault(); this.orderqueue.EnterWriteLock(); //this.Owner.engineState != Ship.MoveState.Warp && if (this.SystemToDefend ==null ||(this.SystemToDefend != system || (this.Owner.GetSystem() != system && goal != null && this.OrderQueue.LastOrDefault().Plan != Plan.DefendSystem))) { #if SHOWSCRUB if (this.Target != null && (this.Target as Ship).Name == "Subspace Projector") System.Diagnostics.Debug.WriteLine(string.Concat("Scrubbed", (this.Target as Ship).Name)); #endif this.SystemToDefend = system; this.HasPriorityOrder = false; this.SystemToDefend = system; this.OrderQueue.Clear(); if (this.SystemToDefend.PlanetList.Count > 0) { List<Planet> Potentials = new List<Planet>(); foreach (Planet p in this.SystemToDefend.PlanetList) { if (p.Owner == null || p.Owner != this.Owner.loyalty) { continue; } Potentials.Add(p); } if (Potentials.Count > 0) { int Ran = (int)((this.Owner.GetSystem() != null ? this.Owner.GetSystem().RNG : ArtificialIntelligence.universeScreen.DeepSpaceRNG)).RandomBetween(0f, (float)Potentials.Count + 0.85f); if (Ran > Potentials.Count - 1) { Ran = Potentials.Count - 1; } // this.awaitClosest = Potentials[Ran]; this.OrderMoveTowardsPosition(Potentials[Ran].Position, 0f, Vector2.One, true,null); } } this.OrderQueue.AddLast(new ArtificialIntelligence.ShipGoal(ArtificialIntelligence.Plan.DefendSystem, Vector2.Zero, 0f)); } this.orderqueue.ExitWriteLock(); this.State = AIState.SystemDefender; }
public void SetOrigin(SolarSystem s) { this.Origin = s; }
private bool DoExploreSystem(float elapsedTime) { this.SystemToPatrol = this.ExplorationTarget; if (this.PatrolRoute == null || this.PatrolRoute.Count == 0) { foreach (Planet p in this.SystemToPatrol.PlanetList) { this.PatrolRoute.Add(p); } if (this.SystemToPatrol.PlanetList.Count == 0) { return this.ExploreEmptySystem(elapsedTime, this.SystemToPatrol); } } else { this.PatrolTarget = this.PatrolRoute[this.stopNumber]; if (this.PatrolTarget.ExploredDict[this.Owner.loyalty]) { ArtificialIntelligence artificialIntelligence = this; artificialIntelligence.stopNumber = artificialIntelligence.stopNumber + 1; if (this.stopNumber == this.PatrolRoute.Count) { this.stopNumber = 0; this.PatrolRoute.Clear(); return true; } } else { this.MovePosition = this.PatrolTarget.Position; float Distance = Vector2.Distance(this.Owner.Center, this.MovePosition); if (Distance < 75000f) { this.PatrolTarget.system.ExploredDict[this.Owner.loyalty] = true; } if (Distance > 15000f) { if (this.Owner.velocityMaximum > Distance && this.Owner.speed >= this.Owner.velocityMaximum) this.Owner.speed = Distance; this.ThrustTowardsPosition(this.MovePosition, elapsedTime, this.Owner.speed); } else if (Distance >= 5500f) { if (this.Owner.velocityMaximum > Distance && this.Owner.speed >= this.Owner.velocityMaximum) this.Owner.speed = Distance; this.ThrustTowardsPosition(this.MovePosition, elapsedTime, this.Owner.speed); } else { this.ThrustTowardsPosition(this.MovePosition, elapsedTime, this.Owner.speed); if (Distance < 500f) { this.PatrolTarget.ExploredDict[this.Owner.loyalty] = true; ArtificialIntelligence artificialIntelligence1 = this; artificialIntelligence1.stopNumber = artificialIntelligence1.stopNumber + 1; if (this.stopNumber == this.PatrolRoute.Count) { this.stopNumber = 0; this.PatrolRoute.Clear(); return true; } } } } } return false; }
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; } } }
private bool ExploreEmptySystem(float elapsedTime, SolarSystem system) { if (system.ExploredDict[this.Owner.loyalty]) { return true; } this.MovePosition = system.Position; float Distance = Vector2.Distance(this.Owner.Center, this.MovePosition); if (Distance < 75000f) { system.ExploredDict[this.Owner.loyalty] = true; return true; } if (Distance > 75000f) { this.ThrustTowardsPosition(this.MovePosition, elapsedTime, this.Owner.speed); } return false; }
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 void DamageRelationship(Empire Us, Empire Them, string why, float Amount, Planet p) { if (Us.data.DiplomaticPersonality == null) { return; } #if PERF if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty)==Them) return; #endif if (GlobalStats.perf && EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them) return; string str = why; string str1 = str; if (str != null) { if (str1 == "Caught Spying") { Relationship angerDiplomaticConflict = this; angerDiplomaticConflict.Anger_DiplomaticConflict = angerDiplomaticConflict.Anger_DiplomaticConflict + Amount; Relationship totalAnger = this; totalAnger.TotalAnger = totalAnger.TotalAnger + Amount; Relationship trust = this; trust.Trust = trust.Trust - Amount; Relationship spiesDetected = this; spiesDetected.SpiesDetected = spiesDetected.SpiesDetected + 1; if (Us.data.DiplomaticPersonality.Name == "Honorable" || Us.data.DiplomaticPersonality.Name == "Xenophobic") { Relationship relationship = this; relationship.Anger_DiplomaticConflict = relationship.Anger_DiplomaticConflict + Amount; Relationship totalAnger1 = this; totalAnger1.TotalAnger = totalAnger1.TotalAnger + Amount; Relationship trust1 = this; trust1.Trust = trust1.Trust - Amount; } if (this.Treaty_Alliance) { Relationship timesSpiedOnAlly = this; timesSpiedOnAlly.TimesSpiedOnAlly = timesSpiedOnAlly.TimesSpiedOnAlly + 1; if (this.TimesSpiedOnAlly == 1) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_Ally_1", true)); return; } } else if (this.TimesSpiedOnAlly > 1) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_Ally_2", true)); } this.Treaty_Alliance = false; this.Treaty_NAPact = false; this.Treaty_OpenBorders = false; this.Treaty_Trade = false; this.Posture = Ship_Game.Gameplay.Posture.Hostile; return; } } else if (this.SpiesDetected == 1 && !this.AtWar && EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { if (this.SpiesDetected == 1) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_1", true)); return; } } else if (this.SpiesDetected == 2) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_2", true)); return; } } else if (this.SpiesDetected >= 3) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_3", true)); } this.Treaty_Alliance = false; this.Treaty_NAPact = false; this.Treaty_OpenBorders = false; this.Treaty_Trade = false; this.Posture = Ship_Game.Gameplay.Posture.Hostile; return; } } } else if (str1 == "Caught Spying Failed") { Relationship angerDiplomaticConflict1 = this; angerDiplomaticConflict1.Anger_DiplomaticConflict = angerDiplomaticConflict1.Anger_DiplomaticConflict + Amount; Relationship relationship1 = this; relationship1.TotalAnger = relationship1.TotalAnger + Amount; Relationship trust2 = this; trust2.Trust = trust2.Trust - Amount; if (Us.data.DiplomaticPersonality.Name == "Honorable" || Us.data.DiplomaticPersonality.Name == "Xenophobic") { Relationship angerDiplomaticConflict2 = this; angerDiplomaticConflict2.Anger_DiplomaticConflict = angerDiplomaticConflict2.Anger_DiplomaticConflict + Amount; Relationship totalAnger2 = this; totalAnger2.TotalAnger = totalAnger2.TotalAnger + Amount; Relationship relationship2 = this; relationship2.Trust = relationship2.Trust - Amount; } Relationship spiesKilled = this; spiesKilled.SpiesKilled = spiesKilled.SpiesKilled + 1; if (this.Treaty_Alliance) { Relationship timesSpiedOnAlly1 = this; timesSpiedOnAlly1.TimesSpiedOnAlly = timesSpiedOnAlly1.TimesSpiedOnAlly + 1; if (this.TimesSpiedOnAlly == 1) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_Ally_1", true)); return; } } else if (this.TimesSpiedOnAlly > 1) { if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Caught_Spying_Ally_2", true)); } this.Treaty_Alliance = false; this.Treaty_NAPact = false; this.Treaty_OpenBorders = false; this.Treaty_Trade = false; this.Posture = Ship_Game.Gameplay.Posture.Hostile; return; } } else if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Killed_Spy_1", true)); return; } } else if (str1 == "Insulted") { Relationship angerDiplomaticConflict3 = this; angerDiplomaticConflict3.Anger_DiplomaticConflict = angerDiplomaticConflict3.Anger_DiplomaticConflict + Amount; Relationship totalAnger3 = this; totalAnger3.TotalAnger = totalAnger3.TotalAnger + Amount; Relationship trust3 = this; trust3.Trust = trust3.Trust - Amount; if (Us.data.DiplomaticPersonality.Name == "Honorable" || Us.data.DiplomaticPersonality.Name == "Xenophobic") { Relationship relationship3 = this; relationship3.Anger_DiplomaticConflict = relationship3.Anger_DiplomaticConflict + Amount; Relationship totalAnger4 = this; totalAnger4.TotalAnger = totalAnger4.TotalAnger + Amount; Relationship trust4 = this; trust4.Trust = trust4.Trust - Amount; return; } } else if (str1 == "Colonized Owned System") { List<Planet> OurTargetPlanets = new List<Planet>(); List<Planet> TheirTargetPlanets = new List<Planet>(); foreach (Goal g in Us.GetGSAI().Goals) { if (g.type != GoalType.Colonize) { continue; } OurTargetPlanets.Add(g.GetMarkedPlanet()); } foreach (Planet theirp in Them.GetPlanets()) { TheirTargetPlanets.Add(theirp); } bool MatchFound = false; SolarSystem sharedSystem = null; foreach (Planet planet in OurTargetPlanets) { foreach (Planet other in TheirTargetPlanets) { if (p == null || other == null || p.system != other.system) { continue; } sharedSystem = p.system; MatchFound = true; break; } if (!MatchFound || !Us.GetRelations()[Them].WarnedSystemsList.Contains(sharedSystem.guid)) { continue; } return; } Relationship angerTerritorialConflict = this; angerTerritorialConflict.Anger_TerritorialConflict = angerTerritorialConflict.Anger_TerritorialConflict + Amount; Relationship relationship4 = this; relationship4.Trust = relationship4.Trust - Amount; if (this.Anger_TerritorialConflict < (float)Us.data.DiplomaticPersonality.Territorialism && !this.AtWar) { if (this.AtWar) { return; } if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { if (!this.WarnedAboutShips) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Colonized Warning", p)); } else if (!this.AtWar) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Warning Ships then Colonized", p)); } this.turnsSinceLastContact = 0; this.WarnedAboutColonizing = true; this.contestedSystem = p.system; this.contestedSystemGuid = p.system.guid; return; } } } else { if (str1 != "Destroyed Ship") { return; } if (this.Anger_MilitaryConflict == 0f && !this.AtWar) { Relationship angerMilitaryConflict = this; angerMilitaryConflict.Anger_MilitaryConflict = angerMilitaryConflict.Anger_MilitaryConflict + Amount; Relationship trust5 = this; trust5.Trust = trust5.Trust - Amount; if (EmpireManager.GetEmpireByName(Us.GetUS().PlayerLoyalty) == Them && !Us.isFaction) { if (this.Anger_MilitaryConflict < 2f) { Us.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(Us, Them, "Aggression Warning")); } Relationship relationship5 = this; relationship5.Trust = relationship5.Trust - Amount; } } Relationship angerMilitaryConflict1 = this; angerMilitaryConflict1.Anger_MilitaryConflict = angerMilitaryConflict1.Anger_MilitaryConflict + Amount; } } }
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; }
private SolarSystem FindBestRoadOrigin(SolarSystem Origin, SolarSystem Destination) { SolarSystem Closest = Origin; List<SolarSystem> ConnectedToOrigin = new List<SolarSystem>(); foreach (SpaceRoad road in this.empire.SpaceRoadsList) { if (road.GetOrigin() != Origin) { continue; } ConnectedToOrigin.Add(road.GetDestination()); } foreach (SolarSystem system in ConnectedToOrigin) { if (Vector2.Distance(system.Position, Destination.Position) + 25000f >= Vector2.Distance(Closest.Position, Destination.Position)) { continue; } Closest = system; } if (Closest != Origin) { Closest = this.FindBestRoadOrigin(Closest, Destination); } return Closest; }
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 SetSys(SolarSystem s) { this.sysToDiscuss = s; }
protected void ViewSystem(SolarSystem system) { this.ViewingShip = false; this.transitionDestination = new Vector3(system.Position, 147000f); this.AdjustCamTimer = 1f; this.transDuration = 3f; this.transitionElapsedTime = 0.0f; }