public void CompleteReview() { InstanceData Inst = StateFundingGlobal.fetch.GameInstance; if (Inst == null) { Log.Error("ReviewManager.CompleteReview, Inst is null"); return; } Review Rev = Inst.ActiveReview; Rev.touch(); // Closed for business Rev.closeReview(); // Move review to past review Inst.addReview(Rev); // Start a new review Inst.ActiveReview = new Review(); // Apply funds from Review Log.Info("Adding Funds: " + Rev.funds); Funding.Instance.AddFunds(Rev.funds, TransactionReasons.None); // Notify player that a review is available ReviewToastView Toast = new ReviewToastView(Rev); Log.Info("Generated Review"); }
public override void OnAwake() { if (data == null) data = new InstanceData(); if (ReviewMgr == null) ReviewMgr = new ReviewManager(); }
public static InstanceData getInstance() { if (instance == null) { instance = new InstanceData(); } return(instance); }
private void OnConfirm() { InstanceData Inst = InstanceData.getInstance(); Inst.Gov = SelectedGovernment; Inst.govName = SelectedGovernment.name; Inst.po = (int)SelectedGovernment.startingPO; Inst.sc = (int)SelectedGovernment.startingSC; ViewManager.removeView(this); OnCreateCallback(Inst); }
public void draw(View Vw, ViewWindow Window, Review review) { Window.title = "Space Stations"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubStationsView.draw, Inst is null"); return; } string Description = "Below is a list of existing Space Stations. Vessels that are Space Stations should be labeled as " + "such, be in orbit, and must be able to generate their own power. Space Stations increase State Confidence as well as Public Opinion." + "Space Stations are scored by the following criteria: Total Fuel (SC), Total Ore (SC), Crew (PO), Crew Capacity (SC), Docking " + "Port Count (SC), Docked Vessels (PO) and if it has a science lab (SC/PO). If the Station is landed on an asteroid it will also " + "get a bonus (PO). If you are on an asteroid you will also get a bonus for having a drill (SC/PO)."; ViewLabel DescriptionLabel = new ViewLabel(Description); DescriptionLabel.setRelativeTo(Window); DescriptionLabel.setLeft(140); DescriptionLabel.setTop(20); DescriptionLabel.setColor(Color.white); DescriptionLabel.setHeight(100); DescriptionLabel.setWidth(Window.getWidth() - 140); Vw.addComponent(DescriptionLabel); ViewLabel TotalStations = new ViewLabel("Total Stations: " + review.variables.SpaceStations.Length); TotalStations.setRelativeTo(Window); TotalStations.setLeft(140); TotalStations.setTop(130); TotalStations.setColor(Color.white); TotalStations.setHeight(30); TotalStations.setWidth(Window.getWidth() - 140); Vw.addComponent(TotalStations); ViewScroll StationsScroll = new ViewScroll(); StationsScroll.setRelativeTo(Window); StationsScroll.setWidth(Window.getWidth() - 140); StationsScroll.setHeight(Window.getHeight() - 160); StationsScroll.setLeft(140); StationsScroll.setTop(150); Vw.addComponent(StationsScroll); SpaceStationReport[] Stations = review.variables.SpaceStations; for (int i = 0; i < Stations.Length; i++) { drawItem(Stations[i], StationsScroll, i); } }
public Review LastReview() { InstanceData Inst = StateFundingGlobal.fetch.GameInstance; if (Inst == null) { Log.Error("ReviewManager.LastReview, Inst is null"); return(null); } Review[] Reviews = Inst.getReviews(); return(Reviews[Reviews.Length - 1]); }
public override void OnAwake() { if (data == null) { data = InstanceData.getInstance(); } if (ReviewMgr == null) { ReviewMgr = new ReviewManager(); } }
private void UpdateFunds() { Log.Info("Updating Funds"); InstanceData Inst = StateFundingGlobal.fetch.GameInstance; if (Inst == null) { Log.Error("Review.UpdateFunds, GameInstance is null"); return; } funds = (int)(((float)(finalPO + finalSC) / 10000) * (float)Inst.Gov.gdp * (float)Inst.Gov.budget); }
public static void draw(View Vw, ViewWindow Window) { Window.title = "Past Reviews"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubReviewsView.draw, Inst is null"); return; } curView = Vw; curWindow = Window; int buttonWidth = 180; int buttonHeight = 30; int buttonMargin = 10; // int xOffset = 0; int yOffset = 0; ViewScroll PastReviewsScroll = new ViewScroll(); PastReviewsScroll.setRelativeTo(Window); PastReviewsScroll.setWidth(Window.getWidth() - 140); PastReviewsScroll.setHeight(Window.getHeight() - 50); PastReviewsScroll.setLeft(140); PastReviewsScroll.setTop(40); Vw.addComponent(PastReviewsScroll); for (int i = GameInstance.getReviews().Length - 1; i >= 0; i--) { Review Rev = GameInstance.Reviews[i]; ViewReviewButton Btn = new ViewReviewButton(Rev, OnReviewClick); Btn.setRelativeTo(PastReviewsScroll); int left = 0; int top = yOffset * buttonMargin + yOffset * buttonHeight; Btn.setLeft(left); Btn.setTop(top); Btn.setWidth(buttonWidth); Btn.setHeight(buttonHeight); Btn.setColor(Color.white); yOffset++; PastReviewsScroll.Components.Add(Btn); } }
private void UpdatePOSC() { Log.Info("Updating POSC"); InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("Review.UpdatePOSC, GameInstance is null"); return; } po = GameInstance.po; sc = GameInstance.sc; }
public void addReview(Review R) { Review[] NewReviews = new Review[Reviews.Length + 1]; for (int i = 0; i < Reviews.Length; i++) { NewReviews[i] = Reviews[i]; } NewReviews[NewReviews.Length - 1] = R; InstanceData Inst = StateFundingGlobal.fetch.GameInstance; Inst.po = R.finalPO; Inst.sc = R.finalSC; Reviews = NewReviews; }
public void UpdateFinalSC() { Log.Info("Updating Final SC"); int tmpSC = sc; InstanceData Inst = StateFundingGlobal.fetch.GameInstance; if (Inst == null) { Log.Error("Review.UpdateFinalSC, GameInstance is null"); return; } foreach (Factor factor in factors) { tmpSC += factor.modSC; } finalSC = (int)Math.Ceiling(tmpSC * (1 - HighLogic.CurrentGame.Parameters.CustomParams <StateFundingSettings>().convergingRate)); }
public static void draw(View Vw, ViewWindow Window) { Window.title = "Current State"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubCurrentView.draw, Inst is null"); return; } Review Rev = GameInstance.ActiveReview; Rev.touch(); ViewTextArea TextArea = new ViewTextArea(GameInstance.ActiveReview.GetSummaryText()); TextArea.setRelativeTo(Window); TextArea.setTop(40); TextArea.setLeft(130); TextArea.setWidth(Window.getWidth() - 140); TextArea.setHeight(Window.getHeight() - 40); TextArea.setColor(Color.white); Vw.addComponent(TextArea); List <ViewSummaryRow> summaryRows = Rev.GetText(); for (int i = 0; i < summaryRows.Count; i++) { ViewSummaryRow row = summaryRows[i]; row.setRelativeTo(TextArea); row.setHeight(30); row.setPercentWidth(100); row.setTop(200 + 20 * i + 10); row.setColor(Color.white); Vw.addComponent(row); } }
public void draw(View Vw, ViewWindow Window, Review review) { Window.title = "Rovers"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubRoversView.draw, Inst is null"); return; } string Description = "Below is a list of existing Rovers. Having more Rovers increases Public Opinion." + "Vessels that are rovers should be labeled as a Rover. They should have at least 4 wheels but can have more." + "If any wheels on the rover are broken they must be repaired. Rovers must has energy and be landed on a body other " + "than the home planet (Kerbin in most cases) to count."; ViewLabel DescriptionLabel = new ViewLabel(Description); DescriptionLabel.setRelativeTo(Window); DescriptionLabel.setLeft(140); DescriptionLabel.setTop(20); DescriptionLabel.setColor(Color.white); DescriptionLabel.setHeight(100); DescriptionLabel.setWidth(Window.getWidth() - 140); Vw.addComponent(DescriptionLabel); ViewLabel TotalRovers = new ViewLabel("Total Rovers: " + review.variables.rovers); TotalRovers.setRelativeTo(Window); TotalRovers.setLeft(140); TotalRovers.setTop(130); TotalRovers.setColor(Color.white); TotalRovers.setHeight(30); TotalRovers.setWidth(Window.getWidth() - 140); Vw.addComponent(TotalRovers); ViewScroll RoversScroll = new ViewScroll(); RoversScroll.setRelativeTo(Window); RoversScroll.setWidth(Window.getWidth() - 140); RoversScroll.setHeight(Window.getHeight() - 160); RoversScroll.setLeft(140); RoversScroll.setTop(150); Vw.addComponent(RoversScroll); Vessel[] Rovers = VesselHelper.GetRovers(); int labelHeight = 20; for (int i = 0; i < Rovers.Length; i++) { Vessel Rover = Rovers[i]; //string target; string label = Rover.GetName() + " is Landed at " + Rover.mainBody.GetName(); ViewLabel RoverLabel = new ViewLabel(label); RoverLabel.setRelativeTo(RoversScroll); RoverLabel.setTop(labelHeight + (labelHeight + 5) * i); RoverLabel.setLeft(0); RoverLabel.setHeight(labelHeight); RoverLabel.setWidth(RoversScroll.getWidth() - 20); RoverLabel.setColor(Color.white); RoversScroll.Components.Add(RoverLabel); } }
//load scenario public override void OnLoad(ConfigNode node) { try { if (node.HasNode(CONFIG_NODENAME)) { //load Debug.Log("StateFundingScenario loading from persistence"); ConfigNode loadNode = node.GetNode(CONFIG_NODENAME); ConfigNode.LoadObjectFromConfig(data, loadNode); isInit = true; } else { Debug.Log("StateFundingScenario default init"); //default init var NewView = new NewInstanceConfigView (); NewView.OnCreate ((InstanceData Inst) => { data = Inst; ReviewMgr.CompleteReview (); }); isInit = true; } for (int i = 0; i < StateFundingGlobal.fetch.Governments.ToArray ().Length; i++) { Government Gov = StateFundingGlobal.fetch.Governments.ToArray () [i]; if (Gov.name == data.govName) { data.Gov = Gov; } } } catch { } }
public void OnDestroy() { _instance = null; data = null; ReviewMgr = null; }
public void draw(View Vw, ViewWindow Window, Review review) { Window.title = "Science Stations"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubLabView.draw, Inst is null"); return; } string Description = "Below is a list of existing Science Sations. Having more Science Stations increases State " + "Confidence. Landed stations on other Celestial Bodies counts higher than Orbiting Stations. " + "To have a qualified Science Station you must have an antenna, a science lab, be able to generate " + "power, and have at least one Kerbal on board."; ViewLabel DescriptionLabel = new ViewLabel(Description); DescriptionLabel.setRelativeTo(Window); DescriptionLabel.setLeft(140); DescriptionLabel.setTop(20); DescriptionLabel.setColor(Color.white); DescriptionLabel.setHeight(100); DescriptionLabel.setWidth(Window.getWidth() - 140); Vw.addComponent(DescriptionLabel); ViewLabel TotalCoverage = new ViewLabel("Orbiting Stations: " + (int)review.variables.orbitalScienceStations + ". " + "Landed Stations: " + (int)review.variables.planetaryScienceStations + "."); TotalCoverage.setRelativeTo(Window); TotalCoverage.setLeft(140); TotalCoverage.setTop(130); TotalCoverage.setColor(Color.white); TotalCoverage.setHeight(30); TotalCoverage.setWidth(Window.getWidth() - 140); Vw.addComponent(TotalCoverage); ViewScroll StationsScroll = new ViewScroll(); StationsScroll.setRelativeTo(Window); StationsScroll.setWidth(Window.getWidth() - 140); StationsScroll.setHeight(Window.getHeight() - 160); StationsScroll.setLeft(140); StationsScroll.setTop(150); Vw.addComponent(StationsScroll); Vessel[] ScienceStations = VesselHelper.GetScienceStations(); int labelHeight = 20; for (int i = 0; i < ScienceStations.Length; i++) { Vessel ScienceStation = ScienceStations[i]; string action; string target; if (ScienceStation.Landed) { action = "Landed At"; target = ScienceStation.mainBody.GetName(); } else { action = "Orbiting"; target = ScienceStation.GetOrbit().referenceBody.GetName(); } string label = ScienceStation.GetName() + " is " + action + " " + target; ViewLabel StationLabel = new ViewLabel(label); StationLabel.setRelativeTo(StationsScroll); StationLabel.setTop(labelHeight + (labelHeight + 5) * i); StationLabel.setLeft(0); StationLabel.setHeight(labelHeight); StationLabel.setWidth(StationsScroll.getWidth() - 20); StationLabel.setColor(Color.white); StationsScroll.Components.Add(StationLabel); } }
public void draw(View Vw, ViewWindow Window, Review review) { Window.title = "Mining Rigs"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubMiningView.draw, Inst is null"); return; } string Description = "Below is a list of existing Mining Rigs. Having more Mining Rigs increases State " + "Confidence. To have a qualified Mining Rig is must have an antenna, drill, be able to generate power, " + "and be Landed on a body other than Kerbin."; ViewLabel DescriptionLabel = new ViewLabel(Description); DescriptionLabel.setRelativeTo(Window); DescriptionLabel.setLeft(140); DescriptionLabel.setTop(20); DescriptionLabel.setColor(Color.white); DescriptionLabel.setHeight(100); DescriptionLabel.setWidth(Window.getWidth() - 140); Vw.addComponent(DescriptionLabel); ViewLabel TotalCoverage = new ViewLabel("Mining Rigs: " + review.variables.miningRigs); TotalCoverage.setRelativeTo(Window); TotalCoverage.setLeft(140); TotalCoverage.setTop(130); TotalCoverage.setColor(Color.white); TotalCoverage.setHeight(30); TotalCoverage.setWidth(Window.getWidth() - 140); Vw.addComponent(TotalCoverage); ViewScroll RigsScroll = new ViewScroll(); RigsScroll.setRelativeTo(Window); RigsScroll.setWidth(Window.getWidth() - 140); RigsScroll.setHeight(Window.getHeight() - 160); RigsScroll.setLeft(140); RigsScroll.setTop(150); Vw.addComponent(RigsScroll); Vessel[] MiningRigs = VesselHelper.GetMiningRigs(); int labelHeight = 20; for (int i = 0; i < MiningRigs.Length; i++) { Vessel MiningRig = MiningRigs[i]; string label = MiningRig.GetName() + " is Landed At " + MiningRig.mainBody.GetName();; ViewLabel MiningLabel = new ViewLabel(label); MiningLabel.setRelativeTo(RigsScroll); MiningLabel.setTop(labelHeight + (labelHeight + 5) * i); MiningLabel.setLeft(0); MiningLabel.setHeight(labelHeight); MiningLabel.setWidth(RigsScroll.getWidth() - 20); MiningLabel.setColor(Color.white); RigsScroll.Components.Add(MiningLabel); } }
public void draw(View Vw, ViewWindow Window, Review review) { Window.title = "Satellite Coverage"; InstanceData GameInstance = StateFundingGlobal.fetch.GameInstance; if (GameInstance == null) { Log.Error("StateFundingHubCoverageView.draw, Inst is null"); return; } string Description = "Below is your space programs satellite coverage. Satellite coverage increases State Confidence. " + "The number of satellites needed to provide full coverage veries depending on the size of the " + "celestial body. Kerbin needs 10 satelites to be fully covered while a small moon like Pol only " + "needs 1 and the massive Jool needs 100. Your total coverage is calculated on the coverage provided " + "to all celestial bodies. So even though Jool needs so many you can still get a high coverage " + "rating by covering the smaller bodies. So start with Kerbin, moons, and the near planets. To have " + "a qualified \"Surveyor Satellite\" it must have an antenna, an autonomous control system, and be " + "able to generate power."; ViewLabel DescriptionLabel = new ViewLabel(Description); DescriptionLabel.setRelativeTo(Window); DescriptionLabel.setLeft(140); DescriptionLabel.setTop(20); DescriptionLabel.setColor(Color.white); DescriptionLabel.setHeight(100); DescriptionLabel.setWidth(Window.getWidth() - 140); Vw.addComponent(DescriptionLabel); ViewLabel TotalCoverage = new ViewLabel("Total Coverage: " + Math.Round((double)review.variables.satelliteCoverage * 100) + "%"); TotalCoverage.setRelativeTo(Window); TotalCoverage.setLeft(140); TotalCoverage.setTop(130); TotalCoverage.setColor(Color.white); TotalCoverage.setHeight(30); TotalCoverage.setWidth(Window.getWidth() - 140); Vw.addComponent(TotalCoverage); ViewScroll CoverageScroll = new ViewScroll(); CoverageScroll.setRelativeTo(Window); CoverageScroll.setWidth(Window.getWidth() - 140); CoverageScroll.setHeight(Window.getHeight() - 160); CoverageScroll.setLeft(140); CoverageScroll.setTop(150); Vw.addComponent(CoverageScroll); CoverageReport[] Coverages = review.variables.Coverages; int labelHeight = 20; for (int i = 0; i < Coverages.Length; i++) { CoverageReport Coverage = Coverages[i]; string label = Coverage.entity + " : (" + Coverage.satCount + "/" + Coverage.satCountForFullCoverage + ") " + Math.Round(Coverage.coverage * 100) + "%"; ViewLabel CoverageLabel = new ViewLabel(label); CoverageLabel.setRelativeTo(CoverageScroll); CoverageLabel.setTop(labelHeight + (labelHeight + 5) * i); CoverageLabel.setLeft(0); CoverageLabel.setHeight(labelHeight); CoverageLabel.setWidth(CoverageScroll.getWidth() - 20); if (Coverage.coverage <= 0.25) { CoverageLabel.setColor(Color.white); } else if (Coverage.coverage <= .75) { CoverageLabel.setColor(Color.yellow); } else { CoverageLabel.setColor(Color.green); } CoverageScroll.Components.Add(CoverageLabel); } }
private void OnConfirm() { InstanceData Inst = new InstanceData (); Inst.Gov = SelectedGovernment; Inst.govName = SelectedGovernment.name; Inst.po = (int)SelectedGovernment.startingPO; Inst.sc = (int)SelectedGovernment.startingSC; ViewManager.removeView (this); OnCreateCallback (Inst); }