private void drawMiniContractsGoals(Mission mission, Status s) { int index = 1; foreach (MissionGoal c in mission.goals) { if (hiddenGoals.Contains(c)) { index++; continue; } List<Value> values = c.getValues(activeVessel, s.events); foreach (Value v in values) { GUILayout.BeginHorizontal(); GUILayout.Label(v.name, styleValueName); GUILayout.Label(v.shouldBe + " : " + v.currentlyIs, (v.done ? styleValueGreen : styleValueRed)); GUILayout.EndHorizontal(); } if (activeVessel != null) { if (s.finishableGoals.ContainsKey(c.id) && s.finishableGoals[c.id]) { hiddenGoals.Add(c); } } } }
/// <summary> /// Draws the mission package browser window /// </summary> /// <param name="id">Identifier.</param> private void drawPackageWindow(int id) { GUI.skin = HighLogic.Skin; GUILayout.BeginHorizontal (); GUILayout.BeginVertical (GUILayout.Width(530)); if (GUILayout.Button(sortStrings[currentSort], styleGreenButton, GUILayout.Width(500))) { nextSort (); Mission.Sort(currentPackage.Missions, currentSort); } // Geckgo mission filter GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(260)); showFinishedMissions = GUILayout.Toggle(showFinishedMissions, "Show Finished"); GUILayout.EndVertical(); GUILayout.BeginVertical(); showUnavailableMissions = GUILayout.Toggle(showUnavailableMissions, "Show Unavailable"); GUILayout.EndVertical(); GUILayout.EndHorizontal(); packageScrollPosition = GUILayout.BeginScrollView (packageScrollPosition); foreach (Mission m in currentPackage.Missions) { Status s = calculateStatus (m, false, null); double payoutTotal = m.reward * PayoutLeveles.TechPayout; GUIStyle style = styleButton; if (s.requiresAnotherMission) { if (!showUnavailableMissions) continue; else style = styleRedButton; } if (s.missionAlreadyFinished && !showFinishedMissions) continue; if (m == currentPreviewMission) { style = styleGreenButton; } GUILayout.BeginHorizontal(GUILayout.Width(450)); if (m.scienceReward != 0) { if (GUILayout.Button(m.name + "\n" + CurrencySuffix + payoutTotal.ToString("N2") + " : " + m.scienceReward + " sp", style, GUILayout.Width(350))) { currentPreviewMission = manager.reloadMission(m, activeVessel); } } else if (GUILayout.Button(m.name + "\n" + CurrencySuffix + payoutTotal.ToString("N2"), style, GUILayout.Width(350))) { currentPreviewMission = manager.reloadMission(m, activeVessel); } if (s.missionAlreadyFinished) { GUILayout.Label(iconFinished, GUILayout.MaxWidth (50), GUILayout.MaxHeight (50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } else { foreach (Mission.Category c in iconDictionary.Keys) { if(m.category.Has(c)) { GUILayout.Label (iconDictionary[c], GUILayout.MaxWidth (50), GUILayout.MaxHeight (50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } } } GUILayout.EndHorizontal (); } GUILayout.EndScrollView (); GUILayout.EndVertical (); GUILayout.BeginVertical (); previewMissionScrollPosition = GUILayout.BeginScrollView (previewMissionScrollPosition); // Show the description text if no mission is currently selected if (currentPreviewMission == null) { GUILayout.Label (currentPackage.description, styleText); } else { // otherwise draw the mission parameters drawMission (currentPreviewMission, calculateStatus (currentPreviewMission, false, activeVessel)); } GUILayout.EndScrollView (); GUILayout.BeginHorizontal (); if (currentPreviewMission != null) { if (GUILayout.Button ("Select mission")) { // we also reset the hiddenGoals field hiddenGoals = new List<MissionGoal> (); currentMission = currentPreviewMission; currentPreviewMission = null; showMissionPackageBrowser = false; } if (currentPreviewMission != null && currentPreviewMission.randomized && GUILayout.Button ("New Random Mission")) { manager.discardRandomMission (currentPreviewMission); currentPreviewMission = manager.reloadMission (currentPreviewMission, activeVessel); } } if (GUILayout.Button ("Close")) { showMissionPackageBrowser = false; } GUILayout.EndHorizontal (); GUILayout.EndVertical (); GUILayout.EndHorizontal (); if (!Input.GetMouseButtonDown(1)) { GUI.DragWindow(); } }
public RandomMission findRandomMission(Mission m) { foreach (RandomMission rm in randomMissions) { if (rm.missionName.Equals(m.name)) { // The random mission has been loaded already. so we need to reload it with the given seed return rm; } } return null; }
/// <summary> /// Calculates the mission status. Some fields are not set by this method unless the passed mission /// is the currently selected mission1!! /// </summary> /// <returns>The status.</returns> /// <param name="mission">Mission.</param> private Status calculateStatus(Mission mission, bool fullCheck = false, Vessel vessel = null) { Status s = new Status(); // Fill the mission status fields if (mission != null) { s.requiresAnotherMission = (mission.requiresMission.Length != 0 && !manager.isMissionAlreadyFinished(mission.requiresMission)); s.missionAlreadyFinished = (manager.isMissionAlreadyFinished(mission, vessel) || (!mission.repeatable && manager.isMissionAlreadyFinished(mission.name))); } // Fill the vessel fields, that are not dependant on the current mission if (vessel != null) { s.onLaunchPad = (vessel.situation == Vessel.Situations.PRELAUNCH); s.recyclable = ((vessel.Landed || vessel.Splashed) && !s.onLaunchPad && !vessel.isEVA && vessel.orbit.referenceBody.name.Equals("Kerbin") && !recycled); s.vesselCanFinishMissions = true; s.isClientControlled = manager.isClientControlled(vessel); s.isOnPassiveMission = manager.isOnPassiveMission(vessel); } // for all other fields we need both: a mission and a vessel if (vessel == null || mission == null) { return(s); } // edited malkuth to add that setting must be set to flight mode to save missons!! s.canFinishMission = s.vesselCanFinishMissions && !s.requiresAnotherMission && !settings.disablePlugin && settings.difficulty != 0; bool orderOk = true; // Only the selected mission is tracked and finishable. A preview Mission is *NOT* finishable. // We calculate the events only for the selected mission, because we might need to reset them. if (fullCheck) { if (eventFlags.Has(EventFlags.CRASHED)) { eventFlags = eventFlags.Remove(EventFlags.CRASHED); s.events.isCrashed = true; } if (eventFlags.Has(EventFlags.DOCKED)) { eventFlags = eventFlags.Remove(EventFlags.DOCKED); s.events.docked = true; } eventFlags = EventFlags.NONE; } foreach (MissionGoal g in mission.goals) { s.finishableGoals[g.id] = false; if (fullCheck && orderOk && g.isDone(vessel, s.events)) { if (g.nonPermanent && (s.canFinishMission || manager.isMissionGoalAlreadyFinished(g, vessel))) { s.finishableGoals[g.id] = true; // Let the manager handle the already finished goals... manager.finishMissionGoal(g, vessel, s.events); } } else { if (mission.inOrder) { orderOk = false; } } } if (s.canFinishMission && fullCheck) { s.missionIsFinishable = (!manager.isMissionAlreadyFinished(mission, vessel) && mission.isDone(vessel, s.events)); } else { s.missionIsFinishable = false; } return(s); }
/// <summary> /// Discards the given random mission. /// Removed it from the random missions list /// </summary> /// <param name="m">M.</param> public void discardRandomMission(Mission m) { if (m.randomized) { RandomMission rm = currentProgram.findRandomMission (m); if(rm != null) { currentProgram.randomMissions.Remove (rm); } } }
public static int SortByReward(Mission x, Mission y) { return x.reward.CompareTo(y.reward); }
/// <summary> /// Draws the mission package browser window /// </summary> /// <param name="id">Identifier.</param> private void drawPackageWindow(int id) { GUI.skin = HighLogic.Skin; GUILayout.BeginHorizontal (); GUILayout.BeginVertical (GUILayout.Width(530)); if (GUILayout.Button (sortStrings[currentSort], styleButton, GUILayout.Width(500))) { nextSort (); Mission.Sort(currentPackage.Missions, currentSort); } packageScrollPosition = GUILayout.BeginScrollView (packageScrollPosition, GUILayout.Width(500)); foreach (Mission m in currentPackage.Missions) { Status s = calculateStatus (m, false, null); GUILayout.BeginHorizontal (GUILayout.Width(450)); GUIStyle style = styleButton; if (s.requiresAnotherMission) { style = styleRedButton; } if (m == currentPreviewMission) { style = styleGreenButton; } if (GUILayout.Button (m.name + "\n" + m.reward + CurrencySuffix, style, GUILayout.Width(350))) { currentPreviewMission = manager.reloadMission(m, activeVessel); } if (s.missionAlreadyFinished) { GUILayout.Label(iconFinished, GUILayout.MaxWidth (50), GUILayout.MaxHeight (50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } else { foreach (Mission.Category c in iconDictionary.Keys) { if(m.category.Has(c)) { GUILayout.Label (iconDictionary[c], GUILayout.MaxWidth (50), GUILayout.MaxHeight (50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } } } GUILayout.EndHorizontal (); } GUILayout.EndScrollView (); GUILayout.EndVertical (); GUILayout.BeginVertical (); previewMissionScrollPosition = GUILayout.BeginScrollView (previewMissionScrollPosition); // Show the description text if no mission is currently selected if (currentPreviewMission == null) { GUILayout.Label (currentPackage.description, styleText); } else { // otherwise draw the mission parameters drawMission (currentPreviewMission, calculateStatus (currentPreviewMission, false, activeVessel)); } GUILayout.EndScrollView (); GUILayout.BeginHorizontal (); if (currentPreviewMission != null) { if (GUILayout.Button ("Select mission")) { // we also reset the hiddenGoals field hiddenGoals = new List<MissionGoal> (); currentMission = currentPreviewMission; currentPreviewMission = null; packageWindow (false); } if (currentPreviewMission.randomized && GUILayout.Button ("Discard")) { manager.discardRandomMission (currentPreviewMission); currentPreviewMission = manager.reloadMission (currentPreviewMission, activeVessel); } } if (GUILayout.Button ("Close")) { packageWindow (false); } GUILayout.EndHorizontal (); GUILayout.EndVertical (); GUILayout.EndHorizontal (); GUI.DragWindow (); }
private void drawContractsWindow(int id) { GUI.skin = HighLogic.Skin; GUILayout.BeginVertical(); if (manager.Getrandomcontractsfreeze != false) { GUILayout.Box("You contrtact is locked, the random time check has been stoped until contract done, or canceled.", StyleBoxYellow); } contractScrollPosition = GUILayout.BeginScrollView(contractScrollPosition); foreach (Mission m in currentPackage.Missions) { Status s = calculateStatus(m, false, null); double payoutTotal = m.reward * PayoutLeveles.TechPayout; GUIStyle style = styleButton; if (m == currentPreviewMission2) { style = styleGreenButton; } GUILayout.BeginHorizontal(); if (m.contractAvailable == manager.GetCurrentContract && s.missionAlreadyFinished == false && s.requiresAnotherMission == false) { if (GUILayout.Button(m.name, style, GUILayout.Width(325), GUILayout.Height(45))) { currentPreviewMission2 = manager.reloadMission(m, activeVessel); if (manager.Getrandomcontractsfreeze != true && vrLock != true) { manager.findVeselWithRepairPart(); manager.clearVesselRepairFromList(); vrLock = true; } } if (currentPreviewMission2 != null) { if (GUILayout.Button("Accept Contract", GUILayout.Height(45))) { // we also reset the hiddenGoals field manager.SetCurrentContract1(0); manager.SetCurrentContract2(0); hiddenGoals = new List<MissionGoal>(); currentMission = currentPreviewMission2; currentPreviewMission2 = null; showMissionPackageBrowser = false; showContractSelection = false; manager.Setrandomcontractfreeze(true); vrLock = false; } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (m.contractAvailable == manager.GetCurrentContract1) { if (GUILayout.Button(m.name, style, GUILayout.Width(325), GUILayout.Height(45))) { currentPreviewMission2 = manager.reloadMission(m, activeVessel); } if (currentPreviewMission2 != null) { if (GUILayout.Button("Accept Contract", GUILayout.Height(45))) { // we also reset the hiddenGoals field manager.SetCurrentContract(0); manager.SetCurrentContract2(0); hiddenGoals = new List<MissionGoal>(); currentMission = currentPreviewMission2; currentPreviewMission2 = null; showMissionPackageBrowser = false; showContractSelection = false; manager.Setrandomcontractfreeze(true); } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (m.contractAvailable == manager.GetCurrentContract2) { if (GUILayout.Button(m.name, style, GUILayout.Width(325), GUILayout.Height(45))) { currentPreviewMission2 = manager.reloadMission(m, activeVessel); if (manager.Getrandomcontractsfreeze != true && asLock != true) { manager.clearAsteroidFindList(); manager.findAsteriodCapture(); asLock = true; } } if (currentPreviewMission2 != null) { if (GUILayout.Button("Accept Contract", GUILayout.Height(45))) { // we also reset the hiddenGoals field manager.SetCurrentContract1(0); manager.SetCurrentContract(0); hiddenGoals = new List<MissionGoal>(); currentMission = currentPreviewMission2; currentPreviewMission2 = null; showMissionPackageBrowser = false; showContractSelection = false; manager.Setrandomcontractfreeze(true); asLock = false; } } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); previewContractScrollPosition = GUILayout.BeginScrollView(previewContractScrollPosition); // Show the description text if no mission is currently selected if (currentPreviewMission2 == null) { GUILayout.Label(currentPackage.description, styleText); } else { // otherwise draw the mission parameters drawContracts(currentPreviewMission2, calculateStatus(currentPreviewMission2, false, activeVessel)); } GUILayout.EndScrollView(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Exit Contracts", styleButtonWordWrap)) { showContractSelection = false; } if (manager.GetCurrentContract != 0 || manager.GetCurrentContract1 != 0 || manager.GetCurrentContract2 != 0) { if (GUILayout.Button("Decline Current Contract", styleButtonWordWrap)) { manager.SetCurrentContract(0); manager.SetCurrentContract1(0); manager.SetCurrentContract2(0); showContractSelection = false; currentMission = null; currentPreviewMission2 = null; manager.Setrandomcontractfreeze(false); Debug.Log("MCE*** CurrentContract Reset to 0: " + manager.GetCurrentContract); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (!Input.GetMouseButtonDown(1)) { GUI.DragWindow(); } }
private void drawUserContractWindow(int id) { PlanetInfo splanet = dictplanetinfo[body]; GoalInfo sgoal = dictGoalInfo[goal]; int sgoalamount = sgoal.Gamount; int splanetamount = splanet.Gamount; int maxastcount = manager.asteroidCapture.Count; AsteriodCapture tempasteroid = manager.asteroidCapture[astcount]; GUI.skin = HighLogic.Skin; GUILayout.BeginVertical(); GUILayout.BeginVertical(GUILayout.Height(250)); GUILayout.BeginHorizontal(); GUILayout.Box("Mission Name",GUILayout.Width(150), GUILayout.Height(30)); usercontracts.name = GUILayout.TextField(usercontracts.name,30); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Box("Mission Description", GUILayout.Width(150), GUILayout.Height(30)); usercontracts.description = GUILayout.TextField(usercontracts.description,52); GUILayout.EndHorizontal(); if (iscrewselected != true) { GUILayout.Label("If Vessel Has Crew Or Not, this makes a difference with Payouts", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("true", styleButtonWordWrap, GUILayout.Width(50))) { ucNoCrewGoal = true; } if (GUILayout.Button("false", styleButtonWordWrap, GUILayout.Width(50))) { ucNoCrewGoal = false; } GUILayout.Box("Does Vessel Have A Crew?", GUILayout.Width(175), GUILayout.Height(30)); GUILayout.Box("" + ucNoCrewGoal, GUILayout.Width(100), GUILayout.Height(30)); if (GUILayout.Button("Set Goal", styleButtonWordWrap, GUILayout.Width(120))) { if (ucNoCrewGoal != true) { usercontracts.noneCrew.Add(new NoneCrew("Vessel Has No Crew")); } if (ucNoCrewGoal != false) { //Debug.Log("Old Current Reward = " + usercontracts.reward); TotalPayout = (ucHasCrew * TotalCrewCount) + usercontracts.reward; //Debug.Log("Total Crew =: " + TotalCrewCount + " X 10,000 = current reward: " + usercontracts.reward); usercontracts.reward = TotalPayout; TotalPayout = 0; } iscrewselected = true; managUserContracts.saveUserContracts(); } GUILayout.EndHorizontal(); GUILayout.Space(5); if (ucNoCrewGoal == true) { GUILayout.BeginHorizontal(); if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { TotalCrewCount--; if (TotalCrewCount < 0) { TotalCrewCount = 0; } } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) {TotalCrewCount++;} GUILayout.Box("How many Crew?", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + TotalCrewCount, GUILayout.Width(150), GUILayout.Height(30)); GUILayout.EndHorizontal(); } } else { GUILayout.Space(5); GUILayout.Label("Set The type of Goal, Some goals are dependent On others! For right now only 1 goal each can be set for each Contract.", styleText); GUILayout.BeginHorizontal(); if (goal != 2 && goal != 3 && goal != 5) { body = 1; } if (goal == 1 || body == 1) { orbitApA = 0; orbitPeA = 0; } if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { goal--; if (goal < 1) { goal = 1; } } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) { goal++; if (goal > 6) { goal = 1; } } GUILayout.Box("Goal Type? ", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + sgoal.Gname, GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Space(5); if (goal == 2 && body != 1 && IsOrbit != 2 && isasteroid != true) { if (GUILayout.Button("Set OrbitGoal", styleButtonWordWrap, GUILayout.Width(120))) { //Debug.Log("Old Current Reward = " + usercontracts.reward); goalpayment = splanetamount + sgoalamount; TotalPayout = goalpayment + usercontracts.reward; //Debug.Log("planet amount = " + splanetamount + "GoalAmount = " + sgoalamount); usercontracts.reward = TotalPayout; //Debug.Log("Total Payout = " + TotalPayout); //Debug.Log("Current Reward = " + usercontracts.reward); usercontracts.ucOrbitGoal.Add(new UCOrbitGoal(TotalCrewCount,splanet.Planet.ToString(), orbitApA, orbitApA, orbitPeA, orbitPeA, isVesselIndy)); goalpayment = 0; TotalPayout = 0; goal = 1; IsOrbit++; managUserContracts.saveUserContracts(); isVesselIndy = false; } } if (goal == 3 && body != 1 && islanding != true) { if (GUILayout.Button("Set LadingGoal", styleButtonWordWrap, GUILayout.Width(120))) { //Debug.Log("Old Current Reward = " + usercontracts.reward); goalpayment = sgoal.Gamount; TotalPayout = goalpayment + usercontracts.reward; //Debug.Log("planet amount = " + splanetamount + "GoalAmount = " + sgoalamount); usercontracts.reward = TotalPayout; //Debug.Log("Total Payout = " + TotalPayout); usercontracts.ucLandingGoal.Add(new UCLandingGoal(splanet.Planet.ToString(),isVesselIndy)); goalpayment = 0; TotalPayout = 0; goal = 1; islanding = true; managUserContracts.saveUserContracts(); isVesselIndy = false; } } if (goal == 4 && isdocking != true && IsOrbit != 0 && isasteroid != true) { if (GUILayout.Button("Set DockingGoal", styleButtonWordWrap, GUILayout.Width(120))) { //Debug.Log("Old Current Reward before Docking = " + usercontracts.reward); goalpayment = sgoal.Gamount; TotalPayout = goalpayment + usercontracts.reward; usercontracts.reward = TotalPayout; //Debug.Log("Current Reward After Docking = " + usercontracts.reward); usercontracts.ucDockingGoal.Add(new UCDockingGoal("Dock At Vessel")); goalpayment = 0; TotalPayout = 0; goal = 1; isdocking = true; managUserContracts.saveUserContracts(); } } if (goal == 5 && isCrashing != true && ucNoCrewGoal == false && isasteroid != true) { if (GUILayout.Button("Set CrashGoal", styleButtonWordWrap, GUILayout.Width(120))) { //Debug.Log("Old Current Reward before CrashGoal = " + usercontracts.reward); goalpayment = sgoal.Gamount; TotalPayout = goalpayment + usercontracts.reward; usercontracts.scienceReward = sgoal.GSciAmount; usercontracts.reward = TotalPayout; //Debug.Log("Current Reward After CrashGoal = " + usercontracts.reward); usercontracts.ucCrashGoal.Add(new UCCrashGoal("This vessel is tasked with crashing into selected body" , splanet.Planet.ToString())); goalpayment = 0; TotalPayout = 0; goal = 1; isCrashing = true; managUserContracts.saveUserContracts(); } } if (goal == 6 && !HighLogic.LoadedSceneIsFlight && isasteroid != true) { if (GUILayout.Button("Set ARM", styleButtonWordWrap, GUILayout.Width(120))) { manager.SetCurrentAsteroidCustomName(tempasteroid.asName); usercontracts.ucArmGoal.Add(new UCArmGoal(true)); goalpayment = sgoal.Gamount; TotalPayout = goalpayment + usercontracts.reward; usercontracts.scienceReward = sgoal.GSciAmount; usercontracts.reward = TotalPayout; isasteroid = true; goal = 1; managUserContracts.saveUserContracts(); } } GUILayout.EndHorizontal(); GUILayout.Space(5); if (goal == 2 || goal == 3 || goal == 5) { GUILayout.Label("What body to set goal to? Please note only 1 goal type per Mission", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { body--; if (body < 1) { body = 1; } } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) { body++; if (body > 17) { body = 1; } } GUILayout.Box("Body Name?", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + splanet.Planet, GUILayout.Width(150), GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); if (goal == 2 && body != 1) { if (orbitApA == 0) { orbitApA = splanet.MinOrb; } if (orbitApA <= splanet.MinOrb) { orbitApA = splanet.MinOrb; } if (orbitApA >= splanet.MaxOrb) { orbitApA = splanet.MinOrb; } if (orbitPeA == 0) { orbitPeA = splanet.MinOrb; } if (orbitPeA <= splanet.MinOrb) { orbitPeA = splanet.MinOrb; } if (orbitPeA > orbitApA) { orbitPeA = splanet.MinOrb; } GUILayout.Label("Set the High Point for Orbit, Has to be Above PeA", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { orbitApA -= 1000; } if (GUILayout.Button("--", styleButtonWordWrap, GUILayout.Width(25))) { orbitApA -= 10000; } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) { orbitApA += 1000; } if (GUILayout.Button("++", styleButtonWordWrap, GUILayout.Width(25))) { orbitApA += 10000; } GUILayout.Box("Apoapsis(MAX): ", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + orbitApA, GUILayout.Width(150), GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Label("Set The Lowpoint for Orbit, This has to be under ApA", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { orbitPeA -= 1000; } if (GUILayout.Button("--", styleButtonWordWrap, GUILayout.Width(25))) { orbitPeA -= 10000; } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) { orbitPeA += 1000; } if (GUILayout.Button("++", styleButtonWordWrap, GUILayout.Width(25))) { orbitPeA += 10000; } GUILayout.Box("Periapsis(MIN): ", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + orbitPeA, GUILayout.Width(150), GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); } } if (goal == 2 || goal == 3) { GUILayout.Label("Set for Goals you might use separate vessel.IE Lander on Landing Goal!", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("True", GUILayout.Width(50))) { isVesselIndy = true; } if (GUILayout.Button("False", GUILayout.Width(50))) { isVesselIndy = false; } GUILayout.Box("Vessel Independent Set To", GUILayout.Width(200), GUILayout.Height(30)); GUILayout.Box("" + isVesselIndy, GUILayout.Width(50), GUILayout.Height(30)); GUILayout.EndHorizontal(); } if (goal == 6) { GUILayout.Label("Choose Available Asteroid To Capture", styleText); GUILayout.BeginHorizontal(); if (GUILayout.Button("-", styleButtonWordWrap, GUILayout.Width(25))) { astcount--; if (astcount < 0) { astcount = 0; } } if (GUILayout.Button("+", styleButtonWordWrap, GUILayout.Width(25))) { astcount++; if (astcount >= maxastcount) { astcount = 0; } } GUILayout.Box("Name Asteroid: ", GUILayout.Width(150), GUILayout.Height(30)); GUILayout.Box("" + tempasteroid.asName, GUILayout.Width(250), GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); } } GUILayout.Space(5); GUILayout.Label("You must reload contract after every change to see changes!"); GUILayout.BeginHorizontal(); if (GUILayout.Button("Load User Contract", styleButtonWordWrap)) { LoadUserContranct(); currentPreviewMission3 = currentMission; } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.BeginHorizontal(); previewContractScrollPosition2 = GUILayout.BeginScrollView(previewContractScrollPosition2, GUILayout.MaxWidth(500)); if (currentPreviewMission3 == null) { GUILayout.Label(contractdesctext, styleText); } else { drawContractsPreview(currentPreviewMission3, calculateStatus(currentPreviewMission3, false, activeVessel)); } GUILayout.EndScrollView(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Reset Contract", styleButtonWordWrap, GUILayout.Width(125))) { usercontracts.resetUserContracts(); IsOrbit = 0; islanding = false; isdocking = false; iscrewselected = false; isCrashing = false; isasteroid = false; TotalCrewCount = 0; managUserContracts.saveUserContracts(); } if (GUILayout.Button("Send Contract For Bidding", styleButtonWordWrap, GUILayout.Width(175))) { manager.StartCompanyRandomizer(); manager.setUserContractCompany(); usercontracts.IsUserContract = true; usercontracts.IsContract = true; managUserContracts.saveUserContracts(); messageEvent = ("Contract Sent out for Bidding. Press \"Load User Contract\" to Load into Contract Screen"); showEventWindow = true; } if (GUILayout.Button("Save Contract", styleButtonWordWrap, GUILayout.Width(125))) { managUserContracts.saveUserContracts(); } if (GUILayout.Button("Exit", styleButtonWordWrap, GUILayout.Width(60))) { showUserContractWindowStatus = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (!Input.GetMouseButtonDown(1)){GUI.DragWindow();} }
/// <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); } } } }
/// <summary> /// Draws the mission goals /// </summary> /// <param name="mission">Mission.</param> private void drawMissionGoals(Mission mission, Status s) { int index = 1; foreach (MissionGoal c in mission.goals) { if (hiddenGoals.Contains(c)) { index++; continue; } if (c is SubMissionGoal) { GUILayout.Label((index++) + ". Mission goal: " + (c.optional ? " (optional)" : ""), styleValueGreenBold); } else { GUILayout.Label((index++) + ". Mission goal: " + c.getType() + (c.optional ? " (optional)" : ""), styleValueGreenBold); } if (c.description.Length != 0) { GUILayout.Label("Description: ", styleCaption); GUILayout.Label(c.description, styleText); } if (c.nonPermanent && c.reward != 0) { GUILayout.BeginHorizontal(); GUILayout.Label("Reward:", styleValueGreenBold); GUILayout.Label(c.reward + CurrencySuffix, styleValueYellow); GUILayout.EndHorizontal(); } List <Value> values = c.getValues(activeVessel, s.events); foreach (Value v in values) { GUILayout.BeginHorizontal(); GUILayout.Label(v.name, styleValueName); if (v.currentlyIs.Length == 0) { GUILayout.Label(v.shouldBe, styleValueGreen); } else { GUILayout.Label(v.shouldBe + " : " + v.currentlyIs, (v.done ? styleValueGreen : styleValueRed)); } GUILayout.EndHorizontal(); } if (activeVessel != null) { if (s.finishableGoals.ContainsKey(c.id) && s.finishableGoals[c.id]) { if (GUILayout.Button("Hide finished goal")) { hiddenGoals.Add(c); } } else { if (c.optional) { if (GUILayout.Button("Hide optional goal")) { hiddenGoals.Add(c); } } } } } }
/// <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(); }
/// <summary> /// Draws the mission package browser window /// </summary> /// <param name="id">Identifier.</param> private void drawPackageWindow(int id) { GUI.skin = HighLogic.Skin; GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(530)); if (GUILayout.Button(sortStrings[currentSort], styleButton, GUILayout.Width(500))) { nextSort(); Mission.Sort(currentPackage.Missions, currentSort); } packageScrollPosition = GUILayout.BeginScrollView(packageScrollPosition, GUILayout.Width(500)); foreach (Mission m in currentPackage.Missions) { Status s = calculateStatus(m, false, null); GUILayout.BeginHorizontal(GUILayout.Width(450)); GUIStyle style = styleButton; if (s.requiresAnotherMission) { style = styleRedButton; } if (m == currentPreviewMission) { style = styleGreenButton; } if (GUILayout.Button(m.name + "\n" + m.reward + CurrencySuffix, style, GUILayout.Width(350))) { currentPreviewMission = manager.reloadMission(m, activeVessel); } if (s.missionAlreadyFinished) { GUILayout.Label(iconFinished, GUILayout.MaxWidth(50), GUILayout.MaxHeight(50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } else { foreach (Mission.Category c in iconDictionary.Keys) { if (m.category.Has(c)) { GUILayout.Label(iconDictionary[c], GUILayout.MaxWidth(50), GUILayout.MaxHeight(50), GUILayout.ExpandWidth(false), GUILayout.Width(50), GUILayout.Height(50)); } } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(); previewMissionScrollPosition = GUILayout.BeginScrollView(previewMissionScrollPosition); // Show the description text if no mission is currently selected if (currentPreviewMission == null) { GUILayout.Label(currentPackage.description, styleText); } else { // otherwise draw the mission parameters drawMission(currentPreviewMission, calculateStatus(currentPreviewMission, false, activeVessel)); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); if (currentPreviewMission != null) { if (GUILayout.Button("Select mission")) { // we also reset the hiddenGoals field hiddenGoals = new List <MissionGoal> (); currentMission = currentPreviewMission; currentPreviewMission = null; packageWindow(false); } if (currentPreviewMission.randomized && GUILayout.Button("New Random Mission", styleButtonYellow)) { manager.discardRandomMission(currentPreviewMission); currentPreviewMission = manager.reloadMission(currentPreviewMission, activeVessel); } } if (GUILayout.Button("Close")) { packageWindow(false); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUI.DragWindow(); }
/// <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(); }
public static int SortByName(Mission x, Mission y) { return x.name.CompareTo(y.name); }
/// <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 static int SortByPackageOrder(Mission x, Mission y) { return x.packageOrder.CompareTo(y.packageOrder); }
/// <summary> /// Returns true, if the given mission has been finished with the given vessel. /// </summary> /// <returns><c>true</c>, if mission already finished, <c>false</c> otherwise.</returns> /// <param name="m">mission</param> /// <param name="v">vessel</param> public bool isMissionAlreadyFinished(Mission m, Vessel v) { if (v == null) { return false; } foreach (MissionStatus s in currentProgram.completedMissions) { if(s.missionName.Equals(m.name)) { if(m.repeatable) { if(s.vesselGuid.Equals(v.id.ToString())) { return true; } } else { return true; } } } return false; }
/// <summary> /// Calculates the mission status. Some fields are not set by this method unless the passed mission /// is the currently selected mission1!! /// </summary> /// <returns>The status.</returns> /// <param name="mission">Mission.</param> private Status calculateStatus(Mission mission, bool fullCheck = false, Vessel vessel = null) { Status s = new Status (); // Fill the mission status fields if (mission != null) { s.requiresAnotherMission = (mission.requiresMission.Length != 0 && !manager.isMissionAlreadyFinished (mission.requiresMission)); s.missionAlreadyFinished = (manager.isMissionAlreadyFinished (mission, vessel) || (!mission.repeatable && manager.isMissionAlreadyFinished(mission.name))); } // Fill the vessel fields, that are not dependant on the current mission if (vessel != null) { s.onLaunchPad = (vessel.situation == Vessel.Situations.PRELAUNCH); s.recyclable = ((vessel.Landed || vessel.Splashed) && !s.onLaunchPad && !vessel.isEVA && vessel.orbit.referenceBody.name.Equals("Kerbin") && !recycled); s.vesselCanFinishMissions = true; s.isClientControlled = manager.isClientControlled (vessel); s.isOnPassiveMission = manager.isOnPassiveMission (vessel); } // for all other fields we need both: a mission and a vessel if (vessel == null || mission == null) { return s; } s.canFinishMission = s.vesselCanFinishMissions && !s.requiresAnotherMission && !settings.disablePlugin; bool orderOk = true; // Only the selected mission is tracked and finishable. A preview Mission is *NOT* finishable. // We calculate the events only for the selected mission, because we might need to reset them. if (fullCheck) { if(eventFlags.Has(EventFlags.CRASHED)) { eventFlags = eventFlags.Remove (EventFlags.CRASHED); s.events.isCrashed = true; } if(eventFlags.Has (EventFlags.DOCKED)) { eventFlags = eventFlags.Remove (EventFlags.DOCKED); s.events.docked = true; } eventFlags = EventFlags.NONE; } foreach (MissionGoal g in mission.goals) { s.finishableGoals [g.id] = false; if (fullCheck && orderOk && g.isDone (vessel, s.events)) { if (g.nonPermanent && (s.canFinishMission || manager.isMissionGoalAlreadyFinished (g, vessel))) { s.finishableGoals [g.id] = true; // Let the manager handle the already finished goals... manager.finishMissionGoal (g, vessel, s.events); } } else { if (mission.inOrder) { orderOk = false; } } } if (s.canFinishMission && fullCheck) { s.missionIsFinishable = (!manager.isMissionAlreadyFinished(mission, vessel) && mission.isDone (vessel, s.events)); } else { s.missionIsFinishable = false; } return s; }
/// <summary> /// Reloads the given mission for the given vessel. Checks for already finished mission goals /// and reexecutes the instructions. /// </summary> /// <returns>reloaded mission</returns> /// <param name="m">mission</param> /// <param name="vessel">vessel</param> public Mission reloadMission(Mission m, Vessel vessel) { int count = 1; if (m.randomized) { RandomMission rm = currentProgram.findRandomMission (m); System.Random random = null; if (rm == null) { rm = new RandomMission (); rm.seed = new System.Random ().Next (); rm.missionName = m.name; currentProgram.add (rm); } random = new System.Random (rm.seed); m.executeInstructions (random); } else { // Maybe there are some instructions. We have to execute them!!! m.executeInstructions (new System.Random()); } foreach(MissionGoal c in m.goals) { c.id = m.name + "__PART" + (count++); c.repeatable = m.repeatable; c.doneOnce = false; } if (vessel != null) { foreach (MissionGoal g in m.goals) { if(isMissionGoalAlreadyFinished(g, vessel) && g.nonPermanent) { g.doneOnce = true; } } } return m; }
/// <summary> /// This is the Research Tree where Players Pick and Buy Research in the GUI /// </summary> /// <param name="id"></param> private void drawResearchTree(int id) { ConstructionMode CM = new ConstructionMode(); SpaceProgram sp = new SpaceProgram(); Mission ms = new Mission(); PayoutLeveles PL = new PayoutLeveles(); GUI.skin = HighLogic.Skin; GUILayout.BeginVertical(); if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { GUILayout.Label("Research Not Available In SandboxMode"); } else { GUILayout.BeginHorizontal(); GUILayout.Box("Current Science", GUILayout.Width(250), GUILayout.Height(40)); GUILayout.Box((int)CM.Science + " Science", GUILayout.Width(250), GUILayout.Height(40)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Box(" MC TechTree", styleValueGreenBold, GUILayout.Width(160), GUILayout.Height(30)); GUILayout.Box(" Purchase Cost", styleValueGreenBold, GUILayout.Width(160), GUILayout.Height(30)); GUILayout.Box(" Research Status", styleValueGreenBold, GUILayout.Width(160), GUILayout.Height(30)); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Box("Vessel Recycling", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("300 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 300 && !manager.ResearchRecycle) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(300); manager.SetResearchRecycle(); } } else { if (manager.ResearchRecycle != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Someone decided that maybe its a good idea to add lots of parachutes to Spent stages and maybe resuse them?"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Box("Rocket Assisted Auto Landing", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("600 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 600 && !manager.GetRocketAutoLand && manager.ResearchRecycle) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(600); manager.SetRocketAutoLand(); } } else { if (manager.ResearchRecycle != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Jeb said \"why don't we use the engines on a returning rocket to land the staged rockets?\"\n\n Then the engineer said \"it can't be done!\"\n\n Jeb then" + " strapped the engineer to an old rocket and launched it into the air. He used a new Prototype remote control thing to land the rocket kinda intact on the ground. \n\nAfter" + " the hospital visit the engineer decided it was possible to land a spent stage via rocket engine! \n\nYou must have 1000 Delta V Left in rocket and 1.5 TWR. You need to research Recyling First!"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Box("Efficient Fuels", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box(" 500 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 500 && manager.ResearchFuels != true) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(500); manager.SetResearchFuels(); manager.SetFuels(); } } else { if (manager.ResearchFuels != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Someone accidently dumped some strange fluid in a Liquid Fuel tank. It seems that adding this new fluid gives you more volume of fuel per unit without many ill effects. And it’s cheap to!"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Box("Construction 1", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("120 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 120 && manager.ResearchConstruction1 != true) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(120); manager.SetResearchConstruction1(); manager.SetConstruction(1); } } else { if (manager.ResearchConstruction1 != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Jeb has figured out that if you find something on the side of the road it's much cheaper to use than new stuff!"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Box("Construction 2", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("500 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 500 && manager.ResearchConstruction2 != true && manager.ResearchConstruction1 != false) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(500); manager.SetResearchConstruction2(); manager.SetConstruction(2); } } else { if (manager.ResearchConstruction2 != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Bill and bob found a new way to construct ships! It's even more creative then Jeb's roadside junk! Jeb has no comment."; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Box("Mission Payouts 2", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("800 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 800 && manager.MissionLevel2 != true) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(800); manager.SetCurrentPayoutLevel(1); manager.SetMissionLevel2(); } } else { if (manager.MissionLevel2 != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Jeb had a talk with some of the contract companies! Now all payouts have been increased and come with a note that says sorry? Jeb, what did you do?"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Box("Mission Payouts 3", GUILayout.Width(160), GUILayout.Height(40)); GUILayout.Box("1,600 Science", GUILayout.Width(160), GUILayout.Height(40)); if (CM.Science >= 1600 && manager.MissionLevel3 != true && manager.MissionLevel2 != false) { if (GUILayout.Button("Purchase", GUILayout.Width(150), GUILayout.Height(40))) { CM.DeductScience(1600); manager.SetCurrentPayoutLevel(2); manager.SetMissionLevel3(); } } else { if (manager.MissionLevel3 != false) { GUILayout.Box("Researched", GUILayout.Width(140), GUILayout.Height(40)); } else { GUILayout.Box("NOT AVAILABLE", GUILayout.Width(140), GUILayout.Height(40)); } } if (GUILayout.Button("i", GUILayout.Width(25), GUILayout.Height(25))) { messageEvent = "Jeb won a game of poker against Bill, now all payouts for missions are even better! Yay Jeb. Bill now complains he has no money"; showEventWindow = true; } GUILayout.EndHorizontal(); GUILayout.Space(5); } if (GUILayout.Button("Exit Window")) { //Difficulty.init(settings.difficulty); SettingsManager.Manager.saveSettings(); FuelMode.fuelinit(manager.GetFuels); ConstructionMode.constructinit(manager.GetConstruction); PayoutLeveles.payoutlevels(manager.GetCurrentPayoutLevel); manager.saveProgram(); ScienceResearch.TexturePath = mcetbState6 ? "MissionController/icons/research" : "MissionController/icons/researchr"; mcetbState6 = !mcetbState6; researchWindow(!showResearchTreeWindow); } GUILayout.EndVertical(); if (!Input.GetMouseButtonDown(1)) { GUI.DragWindow(); } }
public void add(Mission m) { missions.Add (m); }