Пример #1
0
        protected void registerRepairProject(UnloadedQualitySummary qualitySummary)
        {
            //Show tooltip: The repair attempt might not suceed!
            if (!BARISScenario.showedRepairProjectTip && BARISScenario.partsCanBreak)
            {
                BARISScenario.showedRepairProjectTip = true;
                BARISEventCardView cardView = new BARISEventCardView();

                cardView.WindowTitle = BARISScenario.RepairProjectTitle;
                cardView.description = BARISScenario.RepairProjectMsg;
                cardView.imagePath   = BARISScenario.RepairProjectImagePath;

                cardView.SetVisible(true);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            }

            //Create repair project
            BARISRepairProject repairProject = new BARISRepairProject();

            repairProject.vesselID          = qualitySummary.vessel.id.ToString();
            repairProject.repairCostFunds   = qualitySummary.repairCostFunds;
            repairProject.repairCostScience = qualitySummary.repairCostScience;
            repairProject.repairCostTime    = qualitySummary.repairCostTime;
            repairProject.startTime         = Planetarium.GetUniversalTime();

            //Register the project
            BARISScenario.Instance.RegisterRepairProject(repairProject);
        }
Пример #2
0
        protected void drawTigerTeamRepairs(UnloadedQualitySummary qualitySummary)
        {
            bool canAffordScience = true;
            bool canAffordFunds   = true;
            bool commNetEnabled   = true;

            //Do we have a repair entry? If so, draw the progress.
            BARISRepairProject repairProject = BARISScenario.Instance.GetRepairProject(qualitySummary.vessel);

            if (repairProject != null)
            {
                GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.RepairTimeProgress) + "</b>" + string.Format("{0:f3}", repairProject.RepairProgress) + "%</color>");
                return;
            }

            //Calculate repair costs
            qualitySummary.CalculateRepairCosts();

            //If we don't then draw the repair costs and buttons.
            //Science cost to upgrade flight experience.
            GUILayout.BeginHorizontal();
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                canAffordScience = ResearchAndDevelopment.CanAfford(qualitySummary.repairCostScience);

                if (canAffordScience)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostScience) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchScienceCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostScience) + "</color>");
                }
            }

            //Funds cost to upgrade flight experience.
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                canAffordFunds = Funding.CanAfford(qualitySummary.repairCostFunds);

                if (canAffordFunds)
                {
                    GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostFunds) + "</color>");
                }
                else
                {
                    GUILayout.Label("<color=red><b>" + Localizer.Format(BARISScenario.TestBenchFundsCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostFunds) + "</color>");
                }
            }

            //CommNet status
            if (CommNet.CommNetScenario.CommNetEnabled)
            {
                commNetEnabled = qualitySummary.vessel.connection.IsConnectedHome;
            }

            //Time to attempt repair
            GUILayout.Label("<color=white><b>" + Localizer.Format(BARISScenario.RepairTimeCost) + "</b>" + string.Format("{0:n2}", qualitySummary.repairCostTime) +
                            " " + Localizer.Format(BARISScenario.RepairTimeDays) + "</color>");

            //Repair button
            if (GUILayout.Button(wrenchIcon, buttonOptions))
            {
                //Can we afford the funds?
                if (!canAffordFunds)
                {
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoFunds));
                    GUILayout.EndHorizontal();
                    return;
                }

                //Can we afford the science?
                else if (!canAffordScience)
                {
                    GUILayout.EndHorizontal();
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoScience));
                    return;
                }

                //Do we have a CommNet connection?
                else if (!commNetEnabled)
                {
                    GUILayout.EndHorizontal();
                    BARISScenario.Instance.LogPlayerMessage(Localizer.Format(BARISScenario.TigerTeamNoComm));
                    return;
                }

                //Deduct the costs
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
                {
                    Funding.Instance.AddFunds(-qualitySummary.repairCostFunds, TransactionReasons.Any);
                }
                if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
                {
                    ResearchAndDevelopment.Instance.AddScience(-qualitySummary.repairCostScience, TransactionReasons.Any);
                }

                //Register the new project
                registerRepairProject(qualitySummary);
            }

            GUILayout.EndHorizontal();
        }