Exemple #1
0
        public void SelectTab(CampaignMode.InteractionType tab)
        {
            selectedTab = tab;
            for (int i = 0; i < tabs.Length; i++)
            {
                if (tabs[i] != null)
                {
                    tabs[i].Visible = (int)selectedTab == i;
                }
            }

            locationInfoPanel.Visible = tab == CampaignMode.InteractionType.Map && selectedLocation != null;

            switch (selectedTab)
            {
            case CampaignMode.InteractionType.Repair:
                repairHullsButton.Enabled =
                    (Campaign.PurchasedHullRepairs || Campaign.Money >= CampaignMode.HullRepairCost) &&
                    Campaign.AllowedToManageCampaign();
                repairHullsButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedHullRepairs;
                repairItemsButton.Enabled =
                    (Campaign.PurchasedItemRepairs || Campaign.Money >= CampaignMode.ItemRepairCost) &&
                    Campaign.AllowedToManageCampaign();
                repairItemsButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedItemRepairs;

                if (GameMain.GameSession?.SubmarineInfo == null || !GameMain.GameSession.SubmarineInfo.SubsLeftBehind)
                {
                    replaceShuttlesButton.Enabled = false;
                    replaceShuttlesButton.GetChild <GUITickBox>().Selected = false;
                }
                else
                {
                    replaceShuttlesButton.Enabled =
                        (Campaign.PurchasedLostShuttles || Campaign.Money >= CampaignMode.ShuttleReplaceCost) &&
                        Campaign.AllowedToManageCampaign();
                    replaceShuttlesButton.GetChild <GUITickBox>().Selected = Campaign.PurchasedLostShuttles;
                }
                break;

            case CampaignMode.InteractionType.Store:
                Store.RefreshItemsToSell();
                Store.Refresh();
                break;

            case CampaignMode.InteractionType.Crew:
                CrewManagement.UpdateCrew();
                break;

            case CampaignMode.InteractionType.PurchaseSub:
                if (submarineSelection == null)
                {
                    submarineSelection = new SubmarineSelection(false, () => Campaign.ShowCampaignUI = false, tabs[(int)CampaignMode.InteractionType.PurchaseSub].RectTransform);
                }
                submarineSelection.RefreshSubmarineDisplay(true);
                break;
            }
        }
        private string GetHeaderText(bool gameOver, CampaignMode.TransitionType transitionType)
        {
            string locationName = Submarine.MainSub.AtEndPosition ? endLocation?.Name : startLocation?.Name;

            string textTag;

            if (gameOver)
            {
                textTag = "RoundSummaryGameOver";
            }
            else
            {
                switch (transitionType)
                {
                case CampaignMode.TransitionType.LeaveLocation:
                    locationName = startLocation?.Name;
                    textTag      = "RoundSummaryLeaving";
                    break;

                case CampaignMode.TransitionType.ProgressToNextLocation:
                case CampaignMode.TransitionType.ProgressToNextEmptyLocation:
                    locationName = endLocation?.Name;
                    textTag      = "RoundSummaryProgress";
                    break;

                case CampaignMode.TransitionType.ReturnToPreviousLocation:
                case CampaignMode.TransitionType.ReturnToPreviousEmptyLocation:
                    locationName = startLocation?.Name;
                    textTag      = "RoundSummaryReturn";
                    break;

                default:
                    textTag = Submarine.MainSub.AtEndPosition ? "RoundSummaryProgress" : "RoundSummaryReturn";
                    break;
                }
            }

            if (textTag == null)
            {
                return("");
            }

            if (locationName == null)
            {
                DebugConsole.ThrowError($"Error while creating round summary: could not determine destination location. Start location: {startLocation?.Name ?? "null"}, end location: {endLocation?.Name ?? "null"}");
                locationName = "[UNKNOWN]";
            }

            string        subName          = string.Empty;
            SubmarineInfo currentOrPending = SubmarineSelection.CurrentOrPendingSubmarine();

            if (currentOrPending != null)
            {
                subName = currentOrPending.DisplayName;
            }

            return(TextManager.GetWithVariables(textTag, new string[2] {
                "[sub]", "[location]"
            }, new string[2] {
                subName, locationName
            }));
        }