Exemplo n.º 1
0
        /// <summary>
        /// Finishes the given mission with the given vessel.
        /// Rewards the space program with the missions reward.
        /// </summary>
        /// <param name="m">mission</param>
        /// <param name="vessel">vessel</param>
        public void finishMission(Mission m, Vessel vessel, GameEvent events)
        {
            if (!isMissionAlreadyFinished(m, vessel) && m.isDone(vessel, events))
            {
                MissionStatus status = new MissionStatus(m.name, vessel.id.ToString());

                status.repeatable           = m.repeatable;
                status.repeatableSameVessel = m.repeatableSameVessel;

                if (m.passiveMission)
                {
                    status.endOfLife             = Planetarium.GetUniversalTime() + m.lifetime;
                    status.passiveReward         = m.passiveReward;
                    status.lastPassiveRewardTime = Planetarium.GetUniversalTime();
                }

                if (m.clientControlled)
                {
                    status.endOfLife = Planetarium.GetUniversalTime() + m.lifetime;
                }

                status.clientControlled = m.clientControlled;

                currentProgram.add(status);
                reward(m.reward);

                // finish unfinished goals
                foreach (MissionGoal goal in m.goals)
                {
                    finishMissionGoal(goal, vessel, events);
                }

                // If this mission is randomized, we will discard the mission
                if (m.randomized)
                {
                    discardRandomMission(m);
                    m = reloadMission(m, vessel);
                }
            }
        }
 public void add(MissionStatus m)
 {
     completedMissions.Add(m);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Removes an mission status
 /// </summary>
 /// <param name="s">S.</param>
 public void removeMission(MissionStatus s)
 {
     currentProgram.completedMissions.Remove (s);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Finishes the given mission with the given vessel.
        /// Rewards the space program with the missions reward.
        /// </summary>
        /// <param name="m">mission</param>
        /// <param name="vessel">vessel</param>
        public void finishMission(Mission m, Vessel vessel, GameEvent events)
        {
            if (!isMissionAlreadyFinished (m, vessel) && m.isDone(vessel, events)) {
                MissionStatus status = new MissionStatus (m.name, vessel.id.ToString ());

                status.repeatable = m.repeatable;
                status.repeatableSameVessel = m.repeatableSameVessel;

                if (m.passiveMission) {
                    status.endOfLife = Planetarium.GetUniversalTime () + m.lifetime;
                    status.passiveReward = m.passiveReward;
                    status.lastPassiveRewardTime = Planetarium.GetUniversalTime ();
                }

                if(m.clientControlled) {
                    status.endOfLife = Planetarium.GetUniversalTime () + m.lifetime;
                }

                status.clientControlled = m.clientControlled;

                currentProgram.add(status);
                reward (m.reward);

                // finish unfinished goals
                foreach(MissionGoal goal in m.goals) {
                    finishMissionGoal(goal, vessel, events);
                }

                // If this mission is randomized, we will discard the mission
                if (m.randomized) {
                    discardRandomMission (m);
                    m = reloadMission (m, vessel);
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Removes an mission status
 /// </summary>
 /// <param name="s">S.</param>
 public void removeMission(MissionStatus s)
 {
     currentProgram.completedMissions.Remove(s);
 }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
 public void add(MissionStatus m)
 {
     completedMissions.Add(m);
 }
        /// <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();
        }