Exemple #1
0
        /// <summary>
        /// Draws the mission parameters
        /// </summary>
        private void drawMission(Mission mission, Status s)
        {
            if (s.missionAlreadyFinished)
            {
                GUILayout.Label("Mission already finished!", styleWarning);
            }

            GUILayout.Label("Mission: ", styleValueGreenBold);
            GUILayout.Label(mission.name, styleText);
            GUILayout.Label("Description: ", styleCaption);
            GUILayout.Label(mission.description, styleText);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Reward: ", styleValueGreenBold);
            if (settings.difficulty == 1)
            {
                GUILayout.Label(mission.reward + CurrencySuffix, styleValueYellow);
            }
            if (settings.difficulty == 2)
            {
                GUILayout.Label(mission.reward * 60 / 100 + CurrencySuffix, styleValueYellow);
            }
            GUILayout.EndHorizontal();

            if (mission.passiveMission)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Reward every day: ", styleValueYellow);
                GUILayout.Label(mission.passiveReward + CurrencySuffix, styleValueGreen);
                GUILayout.EndHorizontal();
            }

            if (mission.lifetime != 0.0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Lifetime: ", styleValueYellow);
                GUILayout.Label(MathTools.formatTime(mission.lifetime), styleValueGreen);
                GUILayout.EndHorizontal();
            }

            if (mission.clientControlled)
            {
                GUILayout.Label("The client will get the control over this vessel once the mission is finished!", styleWarning);
            }

            if (mission.repeatable)
            {
                GUILayout.Label("Mission is repeatable!", styleCaption);
            }

            if (s.requiresAnotherMission)
            {
                GUILayout.Label("This mission requires the mission \"" + mission.requiresMission + "\". Finish mission \"" +
                                mission.requiresMission + "\" first, before you proceed.", styleWarning);
            }

            drawMissionGoals(mission, s);

            if (s.missionIsFinishable)
            {
                if (manager.budget < 0)
                {
                    if (settings.difficulty == 1)
                    {
                        GUILayout.Label("All goals accomplished. You can finish the mission now! Deducted 25% for loans!", styleCaption);
                        showCostValue("Total Mission Payout:", currentMission.reward * 75 / 100, styleValueGreen);
                    }
                    if (settings.difficulty == 2)
                    {
                        GUILayout.Label("All Goals accomplished. Finish The Mission. Deducted 25% for loans and 40% for HardCore mode"); // .75 * .6 = .45
                        showCostValue("Total Mission Payout:", currentMission.reward * 45 / 100, styleValueGreen);
                    }
                }
                else
                {
                    if (settings.difficulty == 1)
                    {
                        GUILayout.Label("All goals accomplished. you can finish the mission now!", styleCaption);
                        showCostValue("Total Mission Payout:", currentMission.reward, styleValueGreen);
                    }
                    if (settings.difficulty == 2)
                    {
                        GUILayout.Label("All goals accomplished. you can finish the mission now: HardCore Mode 40 % Reduction!", styleCaption);
                        showCostValue("Total Mission Payout:", currentMission.reward * 60 / 100, styleValueGreen);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Draws the main mission window.
        /// Do not use currentMission.isDone or missionGoal.isDone(), use status instead!!!
        /// </summary>
        /// <param name="id">Identifier.</param>



        private void drawMainWindow(int id)
        {
            Status status = calculateStatus(currentMission, true, activeVessel);

            GUI.skin = HighLogic.Skin;
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current budget: ", styleValueYellow);
            GUILayout.Label(manager.budget + CurrencySuffix, (manager.budget < 0 ? styleValueRedBold : styleValueGreenBold));
            GUILayout.EndHorizontal();
            // Edits malkuth shows the modes that you have the plugin set to from settings .13 added the Borrowing Money mission deduction of %25
            if (settings.disablePlugin == true)
            {
                GUILayout.Label("PLUGIN IS DISABLED ", styleValueYellow);
            }
            if (settings.difficulty == 0)
            {
                GUILayout.Label("Test Flight Mode ", styleValueYellow);
            }
            if (settings.difficulty == 1)
            {
                GUILayout.Label("Flight Mode ", styleValueGreen);
            }
            if (manager.budget < 0)
            {
                GUILayout.Label("In Red, Borrowing Money", styleWarning);
            }
            if (settings.difficulty == 2)
            {
                GUILayout.Label("HardCore Mode", styleValueRed);
            }
            // Show only when the loaded scene is an editor or a vessel is available and its situation is PRELAUNCH

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            if (HighLogic.LoadedSceneIsEditor || status.onLaunchPad)
            {
                VesselResources res = new VesselResources(activeVessel);

                // .11 Edited malkuth shows only when in Testing Mode.  Plan to add things like Delta V stats and other Helpful testing info
                if (settings.difficulty == 0)
                {
                    GUILayout.Label("Flight Test Mode, No Missions, Cost Reduced to 6%", styleCaption);
                    showCostValue("Flight Testing Cost:", res.dry() * 6 / 100, (res.dry() * 6 / 100 > manager.budget ? styleValueRedBold : styleValueYellow));
                }
                else
                {
                    // .11 Edited malkuth shows only when in flight mode. New Edit for .12 values only show if Price is above 0.. Little GUI cleanup that I think works better. .12 Edit Added Oxegen and Modular Fuel Cost
                    GUILayout.Label("Flight Mode Selected, Vessel launch Full Price. Missions Available ", styleCaption);
                    if (res.pod() > (0))
                    {
                        showCostValue("Command Sections:", res.pod(), styleValueGreen);
                    }
                    showCostValue("Crew insurance (Launch Pad Only): ", res.crew(), styleValueGreen);
                    if (res.ctrl() > (0))
                    {
                        showCostValue("Avionics and Control:", res.ctrl(), styleValueGreen);
                    }                                                                                                  // NOT control surfaces. Those are AERO parts. These are SAS etc
                    if (res.util() > (0))
                    {
                        showCostValue("Utility Parts:", res.util(), styleValueGreen);
                    }
                    if (res.sci() > (0))
                    {
                        showCostValue("Science Parts:", res.sci(), styleValueGreen);
                    }
                    if (res.engine() > (0))
                    {
                        showCostValue("Engines And Cooling: ", res.engine(), styleValueGreen);
                    }
                    if (res.tank() > (0))
                    {
                        showCostValue("Fuel Tank Cost: ", res.tank(), styleValueGreen);
                    }
                    if (res.oxylife() > (0))
                    {
                        showCostValue("Oxygen Life Support: ", res.oxylife(), styleValueGreen);
                    }
                    if (res.LiquidOxy() > (0))
                    {
                        showCostValue("LiquidOxygen fuel costs:", res.LiquidOxy(), styleValueGreen);
                    }
                    if (res.LiquidH() > (0))
                    {
                        showCostValue("LiquidH2O:", res.LiquidH(), styleValueGreen);
                    }
                    if (res.liquid() > (0))
                    {
                        showCostValue("Liquid fuel costs:", res.liquid(), styleValueGreen);
                    }
                    if (res.oxidizer() > (0))
                    {
                        showCostValue("Oxidizer costs:", res.oxidizer(), styleValueGreen);
                    }
                    if (res.mono() > (0))
                    {
                        showCostValue("Monopropellant costs:", res.mono(), styleValueGreen);
                    }
                    if (res.solid() > (0))
                    {
                        showCostValue("Solid fuel costs:", res.solid(), styleValueGreen);
                    }
                    if (res.xenon() > (0))
                    {
                        showCostValue("Xenon gas costs:", res.xenon(), styleValueGreen);
                    }
                    if (res.stru() > (0))
                    {
                        showCostValue("Structural Cost:", res.stru(), styleValueGreen);
                    }
                    if (res.aero() > (0))
                    {
                        showCostValue("Aerodynamic Cost:", res.aero(), styleValueGreen);
                    }
                    if (res.wet() > (0))
                    {
                        showCostValue("(Total Cost Of Fuels):", res.wet(), styleCaption);
                    }
                    if (res.dry() > (0))
                    {
                        showCostValue("(Total Cost Of Parts):", res.dry(), styleCaption);
                    }
                    showCostValue("Total Cost Of Vessel With All:", res.sum(), (res.sum() > manager.budget ? styleValueRedBold : styleValueYellow));
                }
            }


            if (status.isClientControlled)
            {
                MissionStatus s = manager.getClientControlledMission(activeVessel);
                GUILayout.Label("This vessel is controlled by a client. Do not destroy this vessel! Fine: " + s.punishment + CurrencySuffix, styleWarning);
                GUILayout.Label("End of life in " + MathTools.formatTime(s.endOfLife - Planetarium.GetUniversalTime()));
            }
            else if (status.isOnPassiveMission)
            {
                MissionStatus s = manager.getPassiveMission(activeVessel);
                GUILayout.Label("This vessel is involved in a passive mission. Do not destroy this vessel! Fine: " + s.punishment + CurrencySuffix, styleWarning);
                GUILayout.Label("End of life in " + MathTools.formatTime(s.endOfLife - Planetarium.GetUniversalTime()));
            }

            ;

            if (currentMission != null)
            {
                drawMission(currentMission, status);
            }



            GUILayout.Space(30);
            GUILayout.EndScrollView();

            if (GUILayout.Button("Configure"))
            {
                settingsWindow(!showSettingsWindow);
                resetCount = 0;
            }

            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight && GUILayout.Button("Financing"))
            {
                financeWindow(!showFinanceWindow);
                resetCount = 0;
            }

            if (!HighLogic.LoadedSceneIsFlight && GUILayout.Button("KerbalNauts"))
            {
                kerbalNautsWindow(!showkerbalwindow);
                resetCount = 0;
            }


//            if (GUILayout.Button ("Draw landing area!", styleButton)) {
//                drawLandingArea = !drawLandingArea;
//            }

            if (GUILayout.Button("Select mission package"))
            {
                createFileBrowser("Select mission from package", selectMissionPackage);
            }

            if (currentPackage != null)
            {
                if (GUILayout.Button("Open browser window"))
                {
                    packageWindow(true);
                }
            }

            if (currentMission != null)
            {
                if (GUILayout.Button("Deselect mission"))
                {
                    currentMission = null;
                }
            }

            if (status.missionIsFinishable)
            {
                if (GUILayout.Button("Finish the mission!"))
                {
                    manager.finishMission(currentMission, activeVessel, status.events);
                    hiddenGoals    = new List <MissionGoal> ();
                    currentMission = null;
                }
            }
            // NK recycle from tracking station
            if (HighLogic.LoadedScene.Equals(GameScenes.TRACKSTATION) && pVessel != null && settings.difficulty != 0)
            {
                //print("*MC* In TS, pVessel not null");
                if (pVessel.situation.Equals(Vessel.Situations.LANDED) || pVessel.situation.Equals(Vessel.Situations.SPLASHED))
                {
                    VesselResources res = new VesselResources(pVessel.vesselRef);
                    showCostValue("Recyclable value: ", res.recyclable(pVessel.situation.Equals(Vessel.Situations.LANDED)), styleCaption);
                }
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Exemple #3
0
        /// <summary>
        /// Returns all values related to this mission goal
        /// </summary>
        /// <returns>The values.</returns>
        /// <param name="vessel">current vessel</param>
        public List <Value> getValues(Vessel vessel, GameEvent events)
        {
            List <Value> vs = values(vessel, events);

            if (crewCount != 0)
            {
                if (vessel == null)
                {
                    vs.Add(new Value("Crew count", "" + crewCount));
                }
                else
                {
                    vs.Add(new Value("Crew count", "" + crewCount, "" + vessel.GetCrewCount(),
                                     crewCount <= vessel.GetCrewCount()));
                }
            }

            if (minTotalMass != 0.0)
            {
                if (vessel == null)
                {
                    vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass)));
                }
                else
                {
                    vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass),
                                     String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
                                     vessel.GetTotalMass() >= minTotalMass));
                }
            }

            if (maxTotalMass != 0.0)
            {
                if (vessel == null)
                {
                    vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass)));
                }
                else
                {
                    vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass),
                                     String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
                                     vessel.GetTotalMass() <= maxTotalMass));
                }
            }

            bool done = true;

            foreach (Value v in vs)
            {
                done = done && v.done;
            }

            // If the mission goal is finished so far and we need to throttle down in order
            // to finish the mission goal, add another value if not throttled down
            if (vessel != null)
            {
                if (done && throttleDown && FlightInputHandler.state.mainThrottle != 0.0)
                {
                    vs.Add(new Value("Throttle down!", "true", "false", false));
                    done = false;
                }
            }

            if (done && timeStarted == -1.0 && minSeconds > 0.0)
            {
                timeStarted = Planetarium.GetUniversalTime();
            }

            if (minSeconds > 0.0 && !done)
            {
                timeStarted = -1.0;
            }

            if (minSeconds > 0.0)
            {
                if (vessel != null)
                {
                    double diff = (timeStarted == -1.0 ? 0 : Planetarium.GetUniversalTime() - timeStarted);
                    vs.Add(new Value("Minimal time", MathTools.formatTime(minSeconds), MathTools.formatTime(diff), diff > minSeconds));
                }
                else
                {
                    vs.Add(new Value("Minimal time", MathTools.formatTime(minSeconds)));
                }
            }

            return(vs);
        }
        /// <summary>
        /// Draws the main mission window.
        /// Do not use currentMission.isDone or missionGoal.isDone(), use status instead!!!
        /// </summary>
        /// <param name="id">Identifier.</param>
        private void drawMainWindow(int id)
        {
            Status status = calculateStatus(currentMission, true, activeVessel);

            GUI.skin = HighLogic.Skin;
            GUILayout.BeginVertical();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current budget: ", styleValueName);
            GUILayout.Label(manager.budget + CurrencySuffix, (manager.budget < 0 ? styleValueRed : styleValueGreen));
            GUILayout.EndHorizontal();

            // Show only when the loaded scene is an editor or a vessel is available and its situation is PRELAUNCH
            if (HighLogic.LoadedSceneIsEditor || status.onLaunchPad)
            {
                VesselResources res = vesselResources;
                showCostValue("Liquid fuel costs:", res.liquid(), styleValueGreen);
                showCostValue("Oxidizer costs:", res.oxidizer(), styleValueGreen);
                showCostValue("Monopropellant costs:", res.mono(), styleValueGreen);
                showCostValue("Solid fuel costs:", res.solid(), styleValueGreen);
                showCostValue("Xenon gas costs:", res.xenon(), styleValueGreen);
                showCostValue("Liquid engines: ", res.engine(), styleValueGreen);
                showCostValue("Crew insurance: ", res.crew(), styleValueGreen);
                showCostValue("Other resource costs:", res.materials(), styleValueGreen);
                showCostValue("Sum:", res.sum(), (res.sum() > manager.budget ? styleValueRed : styleValueGreen));
            }

            if (status.isClientControlled)
            {
                MissionStatus s = manager.getClientControlledMission(activeVessel);
                GUILayout.Label("This vessel is controlled by a client. Do not destroy this vessel! Fine: " + s.punishment + CurrencySuffix, styleWarning);
                GUILayout.Label("End of life in " + MathTools.formatTime(s.endOfLife - Planetarium.GetUniversalTime()));
            }
            else if (status.isOnPassiveMission)
            {
                MissionStatus s = manager.getPassiveMission(activeVessel);
                GUILayout.Label("This vessel is involved in a passive mission. Do not destroy this vessel! Fine: " + s.punishment + CurrencySuffix, styleWarning);
                GUILayout.Label("End of life in " + MathTools.formatTime(s.endOfLife - Planetarium.GetUniversalTime()));
            }

            GUILayout.Space(30);

            if (currentMission != null)
            {
                drawMission(currentMission, status);
            }
            else
            {
                drawPassiveMissions(manager.getActivePassiveMissions());

                if (GUILayout.Button("Configure"))
                {
                    settingsWindow(!showSettingsWindow);
                    resetCount = 0;
                }
            }

//            if (GUILayout.Button ("Draw landing area!", styleButton)) {
//                drawLandingArea = !drawLandingArea;
//            }

            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            if (GUILayout.Button("Select mission package"))
            {
                createFileBrowser("Select mission from package", selectMissionPackage);
            }

            if (currentPackage != null)
            {
                if (GUILayout.Button("Open browser window"))
                {
                    packageWindow(true);
                }
            }

            if (currentMission != null)
            {
                if (GUILayout.Button("Deselect mission"))
                {
                    currentMission = null;
                }
            }

            if (status.missionIsFinishable)
            {
                if (GUILayout.Button("Finish the mission!"))
                {
                    manager.finishMission(currentMission, activeVessel, status.events);
                    hiddenGoals    = new List <MissionGoal> ();
                    currentMission = null;
                }
            }
            else
            {
                if (status.recyclable)
                {
                    VesselResources res = vesselResources;
                    showCostValue("Recyclable value: ", res.recyclable(activeVessel.Landed), styleCaption);
                    if (GUILayout.Button("Recycle and end flight!"))
                    {
                        manager.recycleVessel(activeVessel, res.recyclable(activeVessel.Landed));
                        FlightDriver.TerminateCurrentFlight();
                        FlightResultsDialog.showExitControls = true;
                        FlightResultsDialog.Display("Vessel has been recycled!");
                        recycled = true;
                    }
                }
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Exemple #5
0
        protected override List <Value> values(Vessel vessel, GameEvent events)
        {
            List <Value> values = new List <Value> ();

            if (vessel == null)
            {
                values.Add(new Value("Landing Body", body));
            }
            else
            {
                values.Add(new Value("Landing Body", body, vessel.orbit.referenceBody.bodyName,
                                     vessel.orbit.referenceBody.bodyName.Equals(body) && (vessel.situation == Vessel.Situations.LANDED ||
                                                                                          (splashedValid ? vessel.situation == Vessel.Situations.SPLASHED : false))));
            }

            if (minLatitude != maxLatitude)
            {
                if (vessel == null)
                {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude)));
                }
                else
                {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude),
                                         vessel.latitude, MathTools.inMinMax(minLatitude, maxLatitude, vessel.latitude)));
                }
            }

            if (minLongitude != maxLongitude)
            {
                if (vessel == null)
                {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude)));
                }
                else
                {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude),
                                         MathTools.calculateLongitude(vessel.longitude),
                                         MathTools.inMinMax(minLongitude, maxLongitude, MathTools.calculateLongitude(vessel.longitude))));
                }
            }

            return(values);
        }