void MakeMission() { Bounty = (Random.value < 0.5f); if(Bounty) { NameText.text = "Bounty"; //InfoText = Distance, Enemy Count FollowPlayer[] AllEnemies = GameObject.FindWithTag("Overview").GetComponentsInChildren<FollowPlayer>(); TargetObject = AllEnemies[Random.Range(0, AllEnemies.Length)].gameObject; FleetInfo TargetFleet = TargetObject.GetComponent<FleetInfo>(); CreditGain = (TargetFleet.Ships.Count * UniversalConstants.BountyShipDefeatCredits); int Distance = Mathf.RoundToInt(Vector3.Distance(P.transform.position, TargetObject.transform.position)); InfoText.text = Distance.ToString() + "ly " + TargetFleet.Ships.Count + " Ships"; ReputationGain = TargetFleet.Ships.Count * 3; }else { NameText.text = "Delivery"; Planet[] AllPlanets = GameObject.FindWithTag("Overview").GetComponentsInChildren<Planet>(); TargetObject = AllPlanets[Random.Range(0, AllPlanets.Length)].gameObject; int Distance = Mathf.RoundToInt(Vector3.Distance(P.transform.position, TargetObject.transform.position)); CreditGain = Distance * UniversalConstants.DeliveryCreditsMultiplier; ReputationGain = Distance; InfoText.text = Distance.ToString() + "ly " + TargetObject.GetComponent<Planet>().PlanetName; } RewardText.text = CreditGain.ToString() + "c"; }
private bool IsKeeperFleet(FleetInfo fleet) { List <ShipInfo> list = this.App.GameDatabase.GetShipInfoByFleetID(fleet.ID, true).ToList <ShipInfo>(); if (list.Count == 0) { return(false); } if (!this._interestedRoles.ContainsValue(true)) { return(true); } foreach (ShipInfo shipInfo in list) { bool flag; if (!this._interestedRoles.TryGetValue(shipInfo.DesignInfo.Role, out flag)) { flag = false; } if (flag) { return(true); } } return(false); }
protected virtual StarMapFleet CreateFleet( GameObjectSet gos, FleetInfo oi, StarMapBase.SyncContext context) { return((StarMapFleet)null); }
private ButtonItem <FleetInfo> addFleetSelection(FleetInfo fleet) { if (fleet == null) { return(null); } var lang = LocalizationManifest.Get.CurrentLanguage; var context = lang["GalaxyScene"]; var biggestGroup = fleet.Ships.Aggregate((a, b) => (a.Quantity * a.Design.Size > b.Quantity * b.Design.Size) ? a : b); //TODO(v0.9) text might be long, do word wrap var text = fleet.Missions.Waypoints.Count == 0 ? context["StationaryFleet"].Text() : context["MovingFleet"].Text(new TextVar( "destination", this.currentPlayer.Star(fleet.Missions.Waypoints[0].Destionation).Name.ToText(lang) ).Get); return(new ButtonItem <FleetInfo>(fleet) { ImageBackground = fleet.Owner.Color, Image = GalaxyTextures.Get.Sprite(biggestGroup.Design.ImagePath), Text = text, OnSelect = item => showSelectionPanel(null, new List <FleetInfo> { item }) }); }
public static void OnConstructionPlaced( GameSession sim, int selectedFleet, int targetSystem, bool useDirectRoute, int selectedPlanet, List <int> designsToBuild, StationType stationType, int?ReBaseTarget, bool AskForCompo) { if (selectedPlanet == 0) { return; } Kerberos.Sots.StarFleet.StarFleet.SetConstructionMission(sim, selectedFleet, targetSystem, useDirectRoute, selectedPlanet, designsToBuild, stationType, ReBaseTarget); FleetInfo fleetInfo = sim.GameDatabase.GetFleetInfo(selectedFleet); AdmiralInfo admiralInfo = sim.GameDatabase.GetAdmiralInfo(fleetInfo.AdmiralID); if (admiralInfo != null) { string cueName = string.Format("STRAT_007-01_{0}_{1}ConstructionMissionConfirmation", (object)sim.GameDatabase.GetFactionName(sim.GameDatabase.GetPlayerFactionID(sim.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(sim.AssetDatabase)); sim.App.PostRequestSpeech(cueName, 50, 120, 0.0f); } if (sim.LocalPlayer.Faction == sim.AssetDatabase.GetFaction("loa") && AskForCompo) { sim.UI.CreateDialog((Dialog) new DialogLoaFleetSelector(sim.App, MissionType.CONSTRUCT_STN, sim.GameDatabase.GetFleetInfo(selectedFleet), true), null); } sim.App.GetGameState <StarMapState>().RefreshMission(); }
public BuildManagement() { this.FleetToFill = (FleetInfo)null; this.Invoices = new List <BuildScreenState.InvoiceItem>(); this.BuildTime = 0; this.AIFleetID = new int?(); }
public void SyncSDBSlots() { FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this._defenseWidget.GetSynchedFleet()); if (fleetInfo == null) { return; } foreach (ShipInfo shipInfo in this.App.GameDatabase.GetShipInfoByFleetID(fleetInfo.ID, true)) { bool flag = false; SDBInfo sdbInfo = (SDBInfo)null; foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections) { if (designSection.FilePath.ToLower().Contains("_sdb")) { flag = true; sdbInfo = this.App.GameDatabase.GetSDBInfoFromShip(shipInfo.ID); break; } } if (flag && sdbInfo != null) { this._manager.PostSetProp(nameof(SyncSDBSlots), (object)sdbInfo.ShipId, (object)sdbInfo.OrbitalId); } } }
private void CommitMission() { FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(this._interceptFleetWidget.SelectedFleet); int systemId1 = fleetInfo.SystemID; int systemId2 = this._currentReaction.fleet.SystemID; this._app.GameDatabase.ChangeDiplomacyState(this._currentReaction.fleet.PlayerID, fleetInfo.PlayerID, DiplomacyState.WAR); this._app.GameDatabase.UpdateFleetLocation(this._currentReaction.fleet.ID, systemId1, new int?()); MissionInfo missionByFleetId = this._app.GameDatabase.GetMissionByFleetID(this._currentReaction.fleet.ID); if (missionByFleetId == null) { Kerberos.Sots.StarFleet.StarFleet.SetRelocationMission(this._app.Game, this._currentReaction.fleet.ID, systemId2, false, (List <int>)null); } else { List <WaypointInfo> list = this._app.GameDatabase.GetWaypointsByMissionID(missionByFleetId.ID).ToList <WaypointInfo>(); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.RemoveWaypoint(waypointInfo.ID); } this._app.GameDatabase.InsertWaypoint(missionByFleetId.ID, WaypointType.TravelTo, new int?(systemId2)); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.InsertWaypoint(missionByFleetId.ID, waypointInfo.Type, waypointInfo.SystemID); } } this.GetNextReaction(); }
public static void RefreshFleetAdmiralDetails(App game, int fleetId) { FleetInfo fleetInfo = game.GameDatabase.GetFleetInfo(fleetId); string str1 = game.GameDatabase.GetFactionName(game.GameDatabase.GetFleetFaction(fleetId)); string str2 = string.Empty; string str3 = string.Empty; if (fleetInfo.AdmiralID != 0) { AdmiralInfo admiralInfo = game.GameDatabase.GetAdmiralInfo(fleetInfo.AdmiralID); str2 = admiralInfo.Name; str3 = StationPlacementState.GetAdmiralTraitsString(game, fleetInfo.AdmiralID); str1 = admiralInfo.Race; } string upperInvariant1 = string.Format(App.Localize("@MISSIONWIDGET_ADMIRAL"), (object)str2).ToUpperInvariant(); game.UI.SetText("gameAdmiralName", upperInvariant1); string upperInvariant2 = string.Format(App.Localize("@MISSIONWIDGET_FLEET"), (object)fleetInfo.Name).ToUpperInvariant(); game.UI.SetText("gameAdmiralFleet", upperInvariant2); string text = string.Format(App.Localize("@MISSIONWIDGET_ADMIRAL_TRAITS"), (object)str3); game.UI.SetText("gameAdmiralSkills", text); string propertyValue = string.Format("admiral_{0}", (object)str1); if (fleetInfo.AdmiralID != 0) { propertyValue = Kerberos.Sots.StarFleet.StarFleet.GetAdmiralAvatar(game, fleetInfo.AdmiralID); } game.UI.SetPropertyString("gameAdmiralAvatar", "sprite", propertyValue); }
private FleetInfo addFleet(ICollection <Fleet> shipOrders, Fleet newFleet) { var similarFleet = shipOrders.FirstOrDefault(x => x.Missions.SequenceEqual(newFleet.Missions)); var playerProc = this.game.Derivates[this.player]; if (similarFleet != null) { foreach (var shipGroup in newFleet.Ships) { if (similarFleet.Ships.WithDesign.Contains(shipGroup.Design)) { similarFleet.Ships.WithDesign[shipGroup.Design].Quantity += shipGroup.Quantity; } else { similarFleet.Ships.Add(shipGroup); } } return(new FleetInfo(similarFleet, playerProc, this.game.Statics)); } else { if (newFleet.Ships.Count > 0) { shipOrders.Add(newFleet); } var fleetInfo = new FleetInfo(newFleet, playerProc, this.game.Statics); return(fleetInfo); } }
protected override bool CanConfirmMission() { if (this.CaravanMode && this.CaravanFleet.HasValue) { return(this.App.GameDatabase.GetShipInfoByFleetID(this.CaravanFleet.Value, false).Any <ShipInfo>()); } FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this.SelectedFleet); if (fleetInfo == null) { return(false); } if (Kerberos.Sots.StarFleet.StarFleet.IsSuulkaFleet(this.App.GameDatabase, fleetInfo) || Kerberos.Sots.StarFleet.StarFleet.IsGardenerFleet(this.App.Game, fleetInfo)) { return(true); } if (fleetInfo.AdmiralID == 0) { return(false); } bool flag = fleetInfo.SupportingSystemID == this.TargetSystem; if (this.IsValidFleetID(this.SelectedFleet) && Kerberos.Sots.StarFleet.StarFleet.CanSystemSupportFleet(this.App.Game, this.TargetSystem, this.SelectedFleet)) { return(!flag); } return(false); }
public FleetManagement() { this.Fleet = (FleetInfo)null; this.MissionTime = (MissionEstimate)null; this.Score = 0; this.FleetStrength = 0; }
private bool RetrofitShips() { FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this._ship.FleetID); if (fleetInfo == null) { return(false); } if (this.Allshiptog) { List <ShipInfo> list = this.App.GameDatabase.GetShipInfoByFleetID(this._ship.FleetID, false).ToList <ShipInfo>(); List <int> intList = new List <int>(); foreach (ShipInfo shipInfo in list) { if (shipInfo.DesignID == this._ship.DesignID) { intList.Add(shipInfo.ID); } } if (!Kerberos.Sots.StarFleet.StarFleet.FleetCanFunctionWithoutShips(this.App, this._ship.FleetID, (IEnumerable <int>)intList)) { return(false); } this._app.GameDatabase.RetrofitShips((IEnumerable <int>)intList, fleetInfo.SystemID, this.App.LocalPlayer.ID); return(true); } if (!Kerberos.Sots.StarFleet.StarFleet.FleetCanFunctionWithoutShip(this.App, this._ship.FleetID, this._ship.ID)) { return(false); } this._app.GameDatabase.RetrofitShip(this._ship.ID, fleetInfo.SystemID, this.App.LocalPlayer.ID, new int?()); return(true); }
private static void SimulateMorrigiRelics( Random rand, GameSession game, int systemId, FleetInfo randomsFleet, int aiPlayerID, List <FleetInfo> aiPlayerFleets) { int numToKill = rand.NextInclusive(5, 6); Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets); if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0) { return; } CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill); MorrigiRelicInfo relicInfo = game.GameDatabase.GetMorrigiRelicInfos().ToList <MorrigiRelicInfo>().FirstOrDefault <MorrigiRelicInfo>((Func <MorrigiRelicInfo, bool>)(x => x.FleetId == randomsFleet.ID)); if (relicInfo != null && relicInfo.IsAggressive) { List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>(); game.ScriptModules.MorrigiRelic.ApplyRewardsToPlayers(game.App, relicInfo, list, new List <Player>() { game.GetPlayerObject(aiPlayerID) }); } else { CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, (ShipInfo)null); game.GameDatabase.RemoveFleet(randomsFleet.ID); } }
protected override void OnCommitMission() { foreach (OverlayReactionlMission.ReactionUIContainer container in this._containers) { OverlayReactionlMission.ReactionUIContainer rui = container; if (rui.TargetFleet.HasValue) { FleetInfo fleetInfo = rui.Reaction.fleetsInRange.FirstOrDefault <FleetInfo>((Func <FleetInfo, bool>)(x => { int id = x.ID; int?targetFleet = rui.TargetFleet; if (id == targetFleet.GetValueOrDefault()) { return(targetFleet.HasValue); } return(false); })); int systemId = rui.Reaction.fleet.SystemID; this._app.GameDatabase.ChangeDiplomacyState(rui.Reaction.fleet.PlayerID, fleetInfo.PlayerID, DiplomacyState.WAR); this._app.GameDatabase.UpdateFleetLocation(rui.Reaction.fleet.ID, fleetInfo.SystemID, new int?()); MissionInfo missionByFleetId = this._app.GameDatabase.GetMissionByFleetID(rui.Reaction.fleet.ID); if (missionByFleetId == null) { Kerberos.Sots.StarFleet.StarFleet.SetRelocationMission(this._app.Game, rui.Reaction.fleet.ID, systemId, false, (List <int>)null); } else { List <WaypointInfo> list = this._app.GameDatabase.GetWaypointsByMissionID(missionByFleetId.ID).ToList <WaypointInfo>(); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.RemoveWaypoint(waypointInfo.ID); } this._app.GameDatabase.InsertWaypoint(missionByFleetId.ID, WaypointType.TravelTo, new int?(systemId)); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.InsertWaypoint(missionByFleetId.ID, waypointInfo.Type, waypointInfo.SystemID); } } } this._app.Game.RemoveReaction(rui.Reaction); } if (!this._app.GameSetup.IsMultiplayer) { this._app.Game.Phase4_Combat(); } else if (this._app.Network.IsJoined) { this._app.GameDatabase.LogComment("SYNC REACTIONS"); this._app.Network.SendHistory(this._app.GameDatabase.GetTurnCount()); } else { if (!this._app.Network.IsHosting) { return; } this._app.Network.ReactionComplete(); } }
private string GetFleetName(FleetInfo f) { if (!string.IsNullOrEmpty(f.Name)) { return(f.Name); } return(string.Format(App.Localize("@DEFAULT_FLEET_NAME"), (object)this.db.GetPlayerInfo(f.PlayerID).Name)); }
public static void SyncShipsCount( App game, string panelName, FleetInfo fleet, List <ShipItem> listships, bool essentials) { }
private void UpdateScoutMission( GameSession game, LocustSwarmInfo info, FleetInfo fleet, StarSystemInfo currentSystem, bool nestWaitingToGroupUp) { List <LocustSwarmScoutInfo> list1 = game.GameDatabase.GetLocustSwarmScoutsForLocustNest(info.Id).ToList <LocustSwarmScoutInfo>(); if (list1.Count == 0) { return; } List <int> scoutedSystems = new List <int>(); List <LocustSwarmScoutTargetInfo> list2 = game.GameDatabase.GetLocustSwarmScoutTargetInfos().ToList <LocustSwarmScoutTargetInfo>(); List <LocustSwarmScoutInfo> list3 = game.GameDatabase.GetLocustSwarmScoutInfos().ToList <LocustSwarmScoutInfo>(); scoutedSystems.AddRange((IEnumerable <int>)list2.Select <LocustSwarmScoutTargetInfo, int>((Func <LocustSwarmScoutTargetInfo, int>)(x => x.SystemId)).ToList <int>()); foreach (LocustSwarmScoutInfo locustSwarmScoutInfo in list3) { if (locustSwarmScoutInfo.TargetSystemId != 0 && !scoutedSystems.Contains(locustSwarmScoutInfo.TargetSystemId)) { scoutedSystems.Add(locustSwarmScoutInfo.TargetSystemId); } } int num1 = list1.Where <LocustSwarmScoutInfo>((Func <LocustSwarmScoutInfo, bool>)(x => x.TargetSystemId == currentSystem.ID)).Count <LocustSwarmScoutInfo>(); foreach (LocustSwarmScoutInfo locustSwarmScoutInfo in list1) { ShipInfo shipInfo = game.GameDatabase.GetShipInfo(locustSwarmScoutInfo.ShipId, false); if (nestWaitingToGroupUp) { if (shipInfo.FleetID != fleet.ID && game.GameDatabase.GetMissionByFleetID(shipInfo.FleetID) == null) { game.GameDatabase.TransferShip(locustSwarmScoutInfo.ShipId, fleet.ID); Vector3 vector3 = new Vector3(); vector3.Y = 0.0f; float num2 = (float)(((num1 + 1) % 5 + 1) / 2); float num3 = (num1 + 1) % 2 == 0 ? 1f : -1f; vector3.Z = -300f * num2; vector3.X = num3 * 500f * num2; game.GameDatabase.UpdateShipFleetPosition(locustSwarmScoutInfo.ShipId, new Vector3?(vector3)); locustSwarmScoutInfo.TargetSystemId = fleet.SystemID; game.GameDatabase.UpdateLocustSwarmScoutInfo(locustSwarmScoutInfo); game.GameDatabase.RemoveFleet(shipInfo.FleetID); ++num1; } } else if (shipInfo.FleetID == fleet.ID || game.GameDatabase.GetMissionByFleetID(shipInfo.FleetID) == null) { int num2 = this.SetNextScoutTarget(game, info, currentSystem, locustSwarmScoutInfo, scoutedSystems); if (!scoutedSystems.Contains(num2)) { scoutedSystems.Add(num2); } } } }
protected override CommandQueueElement RunInternal() { using (Client.EnterPlanetExclusive(this)) { HttpRequestMessage req; ResponseContainer resp; Dictionary <string, string> postParams = new Dictionary <string, string>(); req = Client.RequestBuilder.GetPage(PageType.Fleet, PlanetId); resp = Client.IssueRequest(req); _source = resp.GetParsedSingle <OgamePageInfo>().PlanetCoord; // 1 _step = 1; postParams = resp.GetHiddenFields(); postParams.Merge(Fleet.Ships.ToDictionary(s => "am" + (int)s.Key, s => s.Value.ToString())); req = Client.RequestBuilder.PostPage(PageType.FleetDestination, postParams.ToArray()); resp = Client.IssueRequest(req); // 2 _step = 2; postParams = resp.GetHiddenFields(); postParams["galaxy"] = Destination.Galaxy.ToString(); postParams["system"] = Destination.System.ToString(); postParams["position"] = Destination.Planet.ToString(); postParams["type"] = ((int)Destination.Type).ToString(); postParams["speed"] = Speed.ToString(); req = Client.RequestBuilder.PostPage(PageType.FleetMission, postParams.ToArray()); resp = Client.IssueRequest(req); // 3 _step = 3; postParams = resp.GetHiddenFields(); postParams["metal"] = Fleet.Resources.Metal.ToString(); postParams["crystal"] = Fleet.Resources.Crystal.ToString(); postParams["deuterium"] = Fleet.Resources.Deuterium.ToString(); postParams["mission"] = ((int)Mission).ToString(); req = Client.RequestBuilder.PostPage(PageType.FleetMovement, postParams.ToArray()); resp = Client.IssueRequest(req); resp = Client.IssueRequest(Client.RequestBuilder.GetPage(PageType.FleetMovement)); var fleets = resp.GetParsed <FleetInfo>(); FleetInfo fi = fleets.Where(s => s.Origin.Coordinate == _source && s.Destination.Coordinate == Destination).FirstOrDefault(); if (fi != null) { Logger.Instance.Log(LogLevel.Success, $"Sent {this}"); } else { Logger.Instance.Log(LogLevel.Error, $"Could not send {this}"); } } return(null); }
protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams) { if (!(msgType == "button_clicked")) { return; } if (panelName == "btnOk") { if (this.mission != null) { FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(this.mission.FleetID); if (fleetInfo == null) { this._app.GameDatabase.RemoveMission(this.mission.ID); return; } AdmiralInfo admiralInfo = this._app.GameDatabase.GetAdmiralInfo(fleetInfo.AdmiralID); if (admiralInfo != null) { this._app.PostRequestSpeech(string.Format("STRAT_009-01_{0}_{1}UniversalMissionComplete", (object)this._app.GameDatabase.GetFactionName(this._app.GameDatabase.GetPlayerFactionID(this._app.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(this._app.AssetDatabase)), 50, 120, 0.0f); } } this._app.UI.CloseDialog((Dialog)this, true); } else { if (!(panelName == "btnSupport")) { return; } List <WaypointInfo> list = this._app.GameDatabase.GetWaypointsByMissionID(this.mission.ID).ToList <WaypointInfo>(); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.RemoveWaypoint(waypointInfo.ID); } FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(this.mission.FleetID); int numSupportTrips = this._app.Game.GetNumSupportTrips(this.mission); for (int index = 0; index < numSupportTrips; ++index) { if (this.mission.TargetSystemID != fleetInfo.SupportingSystemID) { this._app.GameDatabase.InsertWaypoint(this.mission.ID, WaypointType.TravelTo, new int?(this.mission.TargetSystemID)); } this._app.GameDatabase.InsertWaypoint(this.mission.ID, WaypointType.DoMission, new int?()); if (this.mission.TargetSystemID != fleetInfo.SupportingSystemID) { this._app.GameDatabase.InsertWaypoint(this.mission.ID, WaypointType.ReturnHome, new int?()); } } this._app.GameDatabase.InsertWaypoint(this.mission.ID, WaypointType.CheckSupportColony, new int?()); foreach (WaypointInfo waypointInfo in list) { this._app.GameDatabase.InsertWaypoint(this.mission.ID, waypointInfo.Type, waypointInfo.SystemID); } this._app.UI.CloseDialog((Dialog)this, true); } }
private static void SimulateAsteroidMonitors( Random rand, GameSession game, int systemId, FleetInfo randomsFleet, int aiPlayerID, List <FleetInfo> aiPlayerFleets) { int numToKill = rand.NextInclusive(1, 3); Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets); if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)) == 0) { return; } CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill); int encounterIdAtSystem = game.GameDatabase.GetEncounterIDAtSystem(EasterEgg.EE_ASTEROID_MONITOR, systemId); ShipInfo shipInfo = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>().FirstOrDefault <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignID == game.ScriptModules.AsteroidMonitor.MonitorCommandDesignId)); if (shipInfo != null) { AsteroidMonitorInfo asteroidMonitorInfo = game.GameDatabase.GetAsteroidMonitorInfo(encounterIdAtSystem); if (asteroidMonitorInfo != null) { asteroidMonitorInfo.IsAggressive = false; game.GameDatabase.UpdateAsteroidMonitorInfo(asteroidMonitorInfo); } shipInfo.DesignInfo = game.GameDatabase.GetDesignInfo(shipInfo.DesignID); List <DesignModuleInfo> source = new List <DesignModuleInfo>(); foreach (DesignSectionInfo designSection in shipInfo.DesignInfo.DesignSections) { source.AddRange((IEnumerable <DesignModuleInfo>)designSection.Modules.ToList <DesignModuleInfo>()); } if (source.Any <DesignModuleInfo>()) { foreach (SectionInstanceInfo sectionInstanceInfo in game.GameDatabase.GetShipSectionInstances(shipInfo.ID).ToList <SectionInstanceInfo>()) { foreach (ModuleInstanceInfo module in game.GameDatabase.GetModuleInstances(sectionInstanceInfo.ID).ToList <ModuleInstanceInfo>()) { module.Structure = 0; game.GameDatabase.UpdateModuleInstance(module); } } game.InsertNewMonitorSpecialProject(aiPlayerID, encounterIdAtSystem, randomsFleet.ID); } else { game.GameDatabase.RemoveFleet(randomsFleet.ID); game.GameDatabase.RemoveEncounter(encounterIdAtSystem); } } else { game.GameDatabase.RemoveFleet(randomsFleet.ID); game.GameDatabase.RemoveEncounter(encounterIdAtSystem); } }
private void addFleetSelection(FleetInfo fleet) { var fleetView = new FleetInfoView(); fleetView.SetData(fleet, this.currentPlayer); fleetView.OnSelect += fleetInfoView_OnSelect; this.shipList.Controls.Add(fleetView); }
public FleetController SelectFleet(FleetInfo fleet) { if (fleet == null) { throw new ArgumentNullException(nameof(fleet)); } var game = this.gameInstance; return(new FleetController(fleet, game)); }
private string GetFleetName(int admiralID) { string str = "zzzzzzzzzzzzzz"; FleetInfo fleetInfoByAdmiralId = this._app.GameDatabase.GetFleetInfoByAdmiralID(admiralID, FleetType.FL_NORMAL); if (fleetInfoByAdmiralId != null) { str = fleetInfoByAdmiralId.Name; } return(str); }
private static void SimulateSwarmerNest( Random rand, GameSession game, int systemId, FleetInfo randomsFleet, int aiPlayerID, List <FleetInfo> aiPlayerFleets) { int numToKill = rand.NextInclusive(2, 4); Dictionary <FleetInfo, List <ShipInfo> > shipsInFleets = CombatSimulatorRandoms.GetShipsInFleets(game, aiPlayerFleets); shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => x.Value.Count)); if (shipsInFleets.Sum <KeyValuePair <FleetInfo, List <ShipInfo> > >((Func <KeyValuePair <FleetInfo, List <ShipInfo> >, int>)(x => { if (x.Value.Count <= 0) { return(0); } return(x.Value.Sum <ShipInfo>((Func <ShipInfo, int>)(y => { if (y.DesignInfo == null) { return 0; } return CombatAI.GetShipStrength(y.DesignInfo.Class) / 3; }))); })) <= 2) { foreach (KeyValuePair <FleetInfo, List <ShipInfo> > keyValuePair in shipsInFleets) { foreach (ShipInfo shipInfo in keyValuePair.Value) { game.GameDatabase.RemoveShip(shipInfo.ID); } CombatSimulatorRandoms.FleetDestroyed(game, randomsFleet.PlayerID, keyValuePair.Key, (ShipInfo)null); game.GameDatabase.RemoveFleet(keyValuePair.Key.ID); } if (game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>().Count != 0) { return; } game.GameDatabase.RemoveFleet(randomsFleet.ID); } else { CombatSimulatorRandoms.UpdateShipsKilled(game, rand, shipsInFleets, randomsFleet.PlayerID, numToKill); List <ShipInfo> list = game.GameDatabase.GetShipInfoByFleetID(randomsFleet.ID, false).ToList <ShipInfo>(); if (list.Count > 0) { CombatSimulatorRandoms.FleetDestroyed(game, aiPlayerID, randomsFleet, list.First <ShipInfo>()); } game.GameDatabase.RemoveFleet(randomsFleet.ID); } }
public DialogLoaFleetSelector( App app, MissionType mission, FleetInfo basefleet, bool ForceSelection = false) : base(app, "dialogLoaFleetSelector") { this._mission = mission; this._basefleet = basefleet; this._forceSelection = ForceSelection; }
public FleetWidget.FilterShips RightListFilter(ShipInfo ship, DesignInfo design) { FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(ship.FleetID); if ((fleetInfo != null ? fleetInfo.PlayerID : design.PlayerID) != this._app.LocalPlayer.ID || Kerberos.Sots.StarFleet.StarFleet.DesignIsSuulka(this._app, design) || FleetWidget.IsWeaponBattleRider(design)) { return(FleetWidget.FilterShips.Ignore); } Kerberos.Sots.StarFleet.StarFleet.GetHealthAndHealthMax(this._app.Game, design, ship.ID); return(FleetWidget.FilterShips.Enable); }
internal FleetController(FleetInfo fleet, MainGame game, Player player) { this.Fleet = fleet; this.game = game; this.player = player; if (this.Fleet.IsMoving) { this.simulationWaypoints = new List <WaypointInfo>(this.Fleet.Missions.Waypoints); this.calcEta(); } }
protected override void OnCommitMission() { if (this.CaravanMode && this.CaravanFleet.HasValue) { this.SelectedFleet = this.CaravanFleet.Value; } if (this._app.LocalPlayer.Faction.Name == "loa") { Kerberos.Sots.StarFleet.StarFleet.ConvertFleetIntoLoaCubes(this._app.Game, this._selectedFleet); Kerberos.Sots.StarFleet.StarFleet.BuildFleetFromComposition(this._app.Game, this._selectedFleet, MissionType.NO_MISSION); this.RebuildShipLists(this.SelectedFleet); } Kerberos.Sots.StarFleet.StarFleet.SetRelocationMission(this.App.Game, this.SelectedFleet, this.TargetSystem, this._useDirectRoute, this.GetDesignsToBuild()); FleetInfo fleetInfo = this.App.GameDatabase.GetFleetInfo(this._selectedFleet); AdmiralInfo admiralInfo = this.App.GameDatabase.GetAdmiralInfo(fleetInfo.AdmiralID); if (admiralInfo != null) { this.App.PostRequestSpeech(string.Format("STRAT_011-01_{0}_{1}TransferMissionConfirmation", (object)this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(this.App.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(this.App.AssetDatabase)), 50, 120, 0.0f); } if (this.CaravanMode && this.CaravanFleet.HasValue) { List <FreighterInfo> list = this.App.GameDatabase.GetFreighterInfosForSystem(fleetInfo.SystemID).Where <FreighterInfo>((Func <FreighterInfo, bool>)(x => { if (x.PlayerId == this.App.LocalPlayer.ID) { return(x.IsPlayerBuilt); } return(false); })).ToList <FreighterInfo>(); foreach (ShipInfo shipInfo in this.App.GameDatabase.GetShipInfoByFleetID(this.CaravanFleet.Value, false).ToList <ShipInfo>()) { ShipInfo ship = shipInfo; if (list.Any <FreighterInfo>((Func <FreighterInfo, bool>)(x => x.ShipId == ship.ID))) { this.App.GameDatabase.RemoveFreighterInfo(list.First <FreighterInfo>((Func <FreighterInfo, bool>)(x => x.ShipId == ship.ID)).ID); } } } this.App.GetGameState <StarMapState>().RefreshMission(); this.CaravanFleet = new int?(); this.SelectedCaravanSourceSystem = new int?(); if (this._fleetWidget.SyncedFleets != null) { this._fleetWidget.SetSyncedFleets(this._fleetWidget.SyncedFleets); } if (this._RelocatefleetWidget.SyncedFleets != null) { this._RelocatefleetWidget.SetSyncedFleets(this._RelocatefleetWidget.SyncedFleets); } this.EnterAssetRelocateMode(false); }
public void MakeBattle(FleetInfo Player, FleetInfo Enemy, Mission M) { OriginalFriendlyShips = Player.Ships; OriginalEnemyShips = Enemy.Ships; CurrentMission = M; FriendlyShips = new List <ShipStats>(); EnemyShips = new List <ShipStats>(); PlayerFleet = Player; float xPos = 0; for (int i = 0; i < Player.Ships.Count; i++) { GameObject P = Instantiate(Player.Ships[i].ShipPrefab, new Vector3(5f * xPos, 5f * Mathf.Floor(i / 10f), -50f), Quaternion.identity); P.transform.SetParent(this.transform); P.GetComponent <ShipStats>().Team = 0; P.GetComponent <BattleShipController>().BM = this; FriendlyShips.Add(P.GetComponent <ShipStats>()); if (i == 0) { P.GetComponent <BattleShipController>().PlayerControlled = true; Camera.transform.SetParent(P.transform); Camera.transform.localPosition = Vector3.zero; Camera.transform.GetChild(0).transform.localPosition = Player.Ships[0].CameraPosition; Camera.SetActive(true); } xPos++; if (xPos >= 10) { xPos = 0; } } xPos = 0; for (int i = 0; i < Enemy.Ships.Count; i++) { GameObject E = Instantiate(Enemy.Ships[i].ShipPrefab, new Vector3(-5f * xPos, 5f * Mathf.Floor(i / 10f), 50f), Quaternion.identity); E.transform.SetParent(this.transform); E.GetComponent <ShipStats>().Team = 1; E.GetComponent <BattleShipController>().BM = this; EnemyShips.Add(E.GetComponent <ShipStats>()); xPos++; if (xPos >= 10) { xPos = 0; } } }
Color HPColor(FleetInfo.ShipInfo info) { if (info.Name == "") return SystemColors.Control; double ratio = (double)info.CurrentHP / info.MaxHP; if(ratio <= 0) return Color.LightBlue; if (ratio <= 0.25) return Color.LightPink; if (ratio < 0.5) return Color.Gold; if (ratio < 0.75) return Color.Beige; return Color.LightGreen; }
string HPString(FleetInfo.ShipInfo info) { if (info.Name == "") return ""; double ratio = (double)info.CurrentHP / info.MaxHP; return string.Format("{0}/{1}({2})", info.CurrentHP, info.MaxHP, ratio.ToString("0.00%")); }