Exemplo n.º 1
0
        protected override void OnCommitMission()
        {
            if (this._selectedPlanetToEvacuate == 0)
            {
                double num1 = 0.0;
                foreach (int num2 in this.App.GameDatabase.GetStarSystemPlanets(this.TargetSystem).ToList <int>())
                {
                    ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(num2);
                    if (colonyInfoForPlanet != null && colonyInfoForPlanet.PlayerID == this.App.LocalPlayer.ID)
                    {
                        double civilianPopulation = this.App.GameDatabase.GetCivilianPopulation(num2, 0, false);
                        if (civilianPopulation > num1)
                        {
                            this._selectedPlanetToEvacuate = num2;
                            num1 = civilianPopulation;
                        }
                    }
                }
            }
            if (this._selectedPlanetToEvacuate == 0)
            {
                return;
            }
            Kerberos.Sots.StarFleet.StarFleet.SetEvacuationMission(this.App.Game, this.SelectedFleet, this.TargetSystem, this._useDirectRoute, this._selectedPlanetToEvacuate, this.GetDesignsToBuild());
            AdmiralInfo admiralInfo = this.App.GameDatabase.GetAdmiralInfo(this.App.GameDatabase.GetFleetInfo(this._selectedFleet).AdmiralID);

            if (admiralInfo != null)
            {
                this.App.PostRequestSpeech(string.Format("STRAT_002-01_{0}_{1}EvacuationMissionConfirmation", (object)this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(this.App.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(this.App.AssetDatabase)), 50, 120, 0.0f);
            }
            FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), this.GetMissionTargetPlanets());
            this.App.GetGameState <StarMapState>().RefreshStarmap(StarMapState.StarMapRefreshType.REFRESH_NORMAL);
        }
Exemplo n.º 2
0
        protected override void OnCommitMission()
        {
            if (this._selectedPlanetForColonize == 0)
            {
                foreach (int starSystemPlanet in this.App.GameDatabase.GetStarSystemPlanets(this.TargetSystem))
                {
                    if (this.App.GameDatabase.CanColonizePlanet(this.App.LocalPlayer.ID, starSystemPlanet, this.App.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, this.App.LocalPlayer.ID)))
                    {
                        this._selectedPlanetForColonize = starSystemPlanet;
                        break;
                    }
                }
            }
            if (this._selectedPlanetForColonize == 0)
            {
                return;
            }
            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.COLONIZATION);
                this.RebuildShipLists(this.SelectedFleet);
            }
            Kerberos.Sots.StarFleet.StarFleet.SetColonizationMission(this.App.Game, this.SelectedFleet, this.TargetSystem, this._useDirectRoute, this._selectedPlanetForColonize, this.GetDesignsToBuild(), this.RebaseTarget);
            AdmiralInfo admiralInfo = this.App.GameDatabase.GetAdmiralInfo(this.App.GameDatabase.GetFleetInfo(this._selectedFleet).AdmiralID);

            if (admiralInfo != null)
            {
                this.App.PostRequestSpeech(string.Format("STRAT_002-01_{0}_{1}ColonizationMissionConfirmation", (object)this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(this.App.LocalPlayer.ID)), (object)admiralInfo.GetAdmiralSoundCueContext(this.App.AssetDatabase)), 50, 120, 0.0f);
            }
            FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), this.GetMissionTargetPlanets());
            this.App.GetGameState <StarMapState>().RefreshMission();
        }
Exemplo n.º 3
0
        protected override void OnRefreshMissionDetails(MissionEstimate estimate)
        {
            this.AddCommonMissionTimes(estimate);
            string hint1 = App.Localize("@MISSIONWIDGET_TOOLTIP_COLONIZATION_TIME");

            this.AddMissionTime(2, App.Localize("@MISSIONWIDGET_COLONIZATION_TIME"), estimate.TurnsAtTarget, hint1);
            string hint2 = App.Localize("@COLONIZEMISSION_HINT");

            this.AddMissionTime(6, App.Localize("@MISSIONWIDGET_SUPPORT_TIME"), estimate.TurnsColonySupport, hint2);
            this.AddMissionCost(estimate);
            int num = estimate.TurnsTillPhase1Completion;

            if (num < 1)
            {
                num = 1;
            }
            string str = num == 1 ? App.Localize("@UI_GENERAL_TURN") : App.Localize("@UI_GENERAL_TURNS");

            this.AddMissionNote(string.Format(App.Localize("@MISSIONWIDGET_PHASE_ONE"), (object)num, (object)str));
            if (!this._fleetCentric)
            {
                return;
            }
            FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), this.GetMissionTargetPlanets());
        }
Exemplo n.º 4
0
		protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
		{
			if (FleetUI.HandleFleetAndPlanetWidgetInput(this.App, "fleetDetailsWidget", panelName))
				this.UpdateCanConfirmMission();
			else if (msgType == "list_sel_changed")
			{
				if (panelName == "gameFleetList" && msgParams.Length > 0 && !string.IsNullOrEmpty(msgParams[0]))
					this.SelectedFleet = int.Parse(msgParams[0]);
				this.UpdateCanConfirmMission();
			}
			else
				base.OnPanelMessage(panelName, msgType, msgParams);
		}
Exemplo n.º 5
0
 public static void SyncPlanetListControl(
     GameSession game,
     string panelName,
     IEnumerable <int> orbitalObjects)
 {
     game.UI.ClearItems(panelName);
     foreach (int orbitalObject in orbitalObjects)
     {
         OrbitalObjectInfo orbitalObjectInfo = game.GameDatabase.GetOrbitalObjectInfo(orbitalObject);
         FleetUI.SyncPlanetItemControl(game, panelName, orbitalObjectInfo);
     }
     game.UI.AutoSize(panelName);
 }
Exemplo n.º 6
0
        protected override void OnEnter()
        {
            base.OnEnter();
            this._planetWidget = new PlanetWidget(this.App, this.App.UI.Path(this.ID, "planetDetailsCard"));
            IEnumerable <int> missionTargetPlanets = this.GetMissionTargetPlanets();

            FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), missionTargetPlanets);
            this.App.UI.SetEnabled("gameConfirmMissionButton", false);
            if (missionTargetPlanets.Count <int>() <= 0)
            {
                return;
            }
            this.SetSelectedPlanet(missionTargetPlanets.First <int>(), "");
        }
Exemplo n.º 7
0
 public static void SyncFleetAndPlanetListWidget(
     GameSession game,
     string panelName,
     int systemId,
     bool show = true)
 {
     if (systemId == 0)
     {
         game.UI.SetVisible(panelName, false);
     }
     else
     {
         bool               flag1 = game.GameDatabase.IsSurveyed(game.LocalPlayer.ID, systemId);
         List <FleetInfo>   list1 = game.GameDatabase.GetFleetInfoBySystemID(systemId, FleetType.FL_NORMAL | FleetType.FL_RESERVE | FleetType.FL_GATE | FleetType.FL_ACCELERATOR).ToList <FleetInfo>();
         List <StationInfo> list2 = game.GameDatabase.GetStationForSystemAndPlayer(systemId, game.LocalPlayer.ID).ToList <StationInfo>();
         bool               flag2 = true;
         if (!game.SystemHasPlayerColony(systemId, game.LocalPlayer.ID) && !StarMap.IsInRange(game.GameDatabase, game.LocalPlayer.ID, game.GameDatabase.GetStarSystemInfo(systemId), (Dictionary <int, List <ShipInfo> >)null))
         {
             flag2 = false;
         }
         List <int> list3 = game.GameDatabase.GetStarSystemPlanets(systemId).ToList <int>();
         if (list1.Count == 0 && list2.Count == 0 && !flag1 || !flag2 && !flag1)
         {
             game.UI.SetVisible(panelName, false);
         }
         else
         {
             bool flag3 = FleetUI.ShowFleetListDefault;
             bool flag4 = (list1.Count <FleetInfo>() != 0 && flag2 || list2.Count != 0) && show;
             bool flag5 = list3.Count <int>() != 0 && flag1 && show;
             if (flag3 && !flag4)
             {
                 flag3 = false;
             }
             else if (!flag3 && !flag5)
             {
                 flag3 = true;
             }
             game.UI.SetEnabled("planetsTab", flag5);
             game.UI.SetVisible("partSystemPlanets", flag5 && !flag3);
             game.UI.SetChecked("planetsTab", flag5 && !flag3);
             game.UI.SetEnabled("fleetsTab", flag4);
             game.UI.SetChecked("fleetsTab", flag4 && flag3);
             game.UI.SetVisible("partSystemFleets", flag4 && flag3);
             game.UI.SetVisible(panelName, show);
             FleetUI.SyncPlanetListControl(game, "partSystemPlanets", systemId, (IEnumerable <int>)list3);
         }
     }
 }
Exemplo n.º 8
0
        public static void SyncPlanetItemControl(
            GameSession game,
            string panelName,
            OrbitalObjectInfo orbital)
        {
            PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbital.ID);

            if (planetInfo == null)
            {
                return;
            }
            game.GameDatabase.GetMoons(orbital.ID);
            string        propertyValue        = App.Localize("@UI_PLANET_TYPE_" + planetInfo.Type.ToUpperInvariant());
            Vector4       color                = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            AIColonyIntel colonyIntelForPlanet = game.GameDatabase.GetColonyIntelForPlanet(game.LocalPlayer.ID, planetInfo.ID);

            if (colonyIntelForPlanet != null)
            {
                PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(colonyIntelForPlanet.OwningPlayerID);
                color.X = playerInfo.PrimaryColor.X * (float)byte.MaxValue;
                color.Y = playerInfo.PrimaryColor.Y * (float)byte.MaxValue;
                color.Z = playerInfo.PrimaryColor.Z * (float)byte.MaxValue;
                color.W = (float)byte.MaxValue;
            }
            game.UI.AddItem(panelName, string.Empty, orbital.ID, string.Empty);
            string itemGlobalId = game.UI.GetItemGlobalID(panelName, string.Empty, orbital.ID, string.Empty);
            string panelId      = game.UI.Path(itemGlobalId, "expand_button");

            game.UI.SetVisible(panelId, false);
            bool flag = game.GameDatabase.CanColonizePlanet(game.LocalPlayer.ID, planetInfo.ID, game.GameDatabase.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, game.LocalPlayer.ID)) || colonyIntelForPlanet != null && colonyIntelForPlanet.PlayerID == game.LocalPlayer.ID;

            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.idle", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.mouse_over", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.idle", orbital.Name, color, true);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.mouse_over", orbital.Name, color, true);
            game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "planetItemPlanetType"), "text", propertyValue);
            game.UI.AutoSize(game.UI.Path(itemGlobalId, "expanded"));
        }
Exemplo n.º 9
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (this._supportTripsSpinner.TryPanelMessage(panelName, msgType, msgParams, PanelBinding.PanelMessageTargetFlags.Self | PanelBinding.PanelMessageTargetFlags.Recursive))
     {
         this._supportTripsSpinner.SetValue(Math.Max(this._supportTripsSpinner.MinValue, Math.Min(this._supportTripsSpinner.MaxValue, this._supportTripsSpinner.Value)));
     }
     else if (FleetUI.HandleFleetAndPlanetWidgetInput(this.App, "fleetDetailsWidget", panelName))
     {
         this.UpdateCanConfirmMission();
     }
     else if (msgType == "mapicon_clicked")
     {
         if (!(panelName == "partMiniSystem") || !this.App.GameDatabase.IsSurveyed(this.App.LocalPlayer.ID, this.TargetSystem))
         {
             return;
         }
         this.SetSelectedPlanet(int.Parse(msgParams[0]), panelName);
     }
     else if (msgType == "list_sel_changed")
     {
         if (panelName == "overlayPlanetList")
         {
             int num = 0;
             if (msgParams.Length > 0 && !string.IsNullOrEmpty(msgParams[0]))
             {
                 num = int.Parse(msgParams[0]);
             }
             this.SetSelectedPlanet(num, panelName);
         }
         else if (panelName == "gameFleetList" && msgParams.Length > 0 && !string.IsNullOrEmpty(msgParams[0]))
         {
             this.SelectedFleet = int.Parse(msgParams[0]);
         }
         this.UpdateCanConfirmMission();
     }
     else
     {
         base.OnPanelMessage(panelName, msgType, msgParams);
     }
 }
Exemplo n.º 10
0
 public static void SyncFleetAndPlanetListWidget(
     GameSession game,
     string panelName,
     int systemId,
     IEnumerable <FleetInfo> fleets,
     IEnumerable <int> orbitalObjectIds,
     bool show = true)
 {
     if (systemId == 0 || fleets.Count <FleetInfo>() == 0 && orbitalObjectIds.Count <int>() == 0)
     {
         game.UI.SetVisible(panelName, false);
     }
     else
     {
         if (fleets.Count <FleetInfo>() == 0)
         {
             game.UI.SetVisible("fleetsTab", false);
         }
         else
         {
             game.UI.SetVisible("fleetsTab", show);
         }
         if (orbitalObjectIds.Count <int>() == 0)
         {
             game.UI.SetVisible("planetsTab", false);
             game.UI.SetPropertyInt("fleetsTab", "left", 30);
         }
         else
         {
             game.UI.SetVisible("planetsTab", show);
             game.UI.SetPropertyInt("fleetsTab", "left", 115);
         }
         game.UI.AutoSize("fleetsTab");
         game.UI.SetVisible(panelName, show);
         FleetUI.SyncPlanetListControl(game, "partSystemPlanets", systemId, orbitalObjectIds);
     }
 }
Exemplo n.º 11
0
 protected override void OnRefreshMissionDetails(MissionEstimate estimate)
 {
     this.AddCommonMissionTimes(estimate);
     this.AddMissionCost(estimate);
     FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), this.GetMissionTargetPlanets());
 }
Exemplo n.º 12
0
        public static void SyncPlanetListControl(
            GameSession game,
            string panelName,
            int systemId,
            IEnumerable <int> orbitalObjects)
        {
            bool flag = game.GameDatabase.IsSurveyed(game.LocalPlayer.ID, systemId);

            game.UI.ClearItems(panelName);
            List <OrbitalObjectInfo> list        = game.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId).ToList <OrbitalObjectInfo>();
            Dictionary <int, float>  DistanceMap = new Dictionary <int, float>();

            foreach (OrbitalObjectInfo orbitalObjectInfo in list)
            {
                DistanceMap.Add(orbitalObjectInfo.ID, orbitalObjectInfo.OrbitalPath.Scale.Y);
            }
            list.Sort((Comparison <OrbitalObjectInfo>)((x, y) =>
            {
                int num = (x.ParentID.HasValue ? DistanceMap[x.ParentID.Value] : x.OrbitalPath.Scale.Y).CompareTo(y.ParentID.HasValue ? DistanceMap[y.ParentID.Value] : y.OrbitalPath.Scale.Y);
                if (num == 0)
                {
                    if (x.ParentID.HasValue && y.ParentID.HasValue)
                    {
                        return(x.OrbitalPath.Scale.Y.CompareTo(y.OrbitalPath.Scale.Y));
                    }
                    if (x.ParentID.HasValue)
                    {
                        return(1);
                    }
                    if (y.ParentID.HasValue)
                    {
                        return(-1);
                    }
                }
                return(num);
            }));
            if (orbitalObjects.Contains <int>(FleetUI.StarItemID))
            {
                Vector4        color          = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
                StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(systemId);
                game.UI.AddItem(panelName, string.Empty, FleetUI.StarItemID, string.Empty);
                string itemGlobalId = game.UI.GetItemGlobalID(panelName, string.Empty, FleetUI.StarItemID, string.Empty);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.idle", starSystemInfo.Name, color, false);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.mouse_over", starSystemInfo.Name, color, false);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.idle", starSystemInfo.Name, color, true);
                FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.mouse_over", starSystemInfo.Name, color, true);
                string panelId = game.UI.Path(panelName, itemGlobalId, "expand_button");
                game.UI.SetVisible(panelId, false);
            }
            if (flag)
            {
                foreach (OrbitalObjectInfo orbital in list)
                {
                    if (orbital.ID != FleetUI.StarItemID && orbitalObjects.Contains <int>(orbital.ID))
                    {
                        FleetUI.SyncPlanetItemControl(game, panelName, orbital);
                    }
                }
            }
            game.UI.AutoSize(panelName);
        }