public progressInterval(ProgressType t, ProgressNode n, double r, double m, double ro, int i, string s = "") { pType = t; id = n.Id; totalIntervals = i; descriptor = s; currentRecord = r; max = m; round = ro; records = new List<int>(i + 1); rewards = new List<Vector3>(i + 1); for (int k = 0; k < i + 1; k++) { records.Add(0); rewards.Add(new Vector3()); } if (n.IsComplete) interval = totalIntervals + 1; else { interval = getNextInterval(); if (interval > totalIntervals + 1) interval = totalIntervals + 1; } for (int j = 1; j <= totalIntervals; j++) { calculateRewards(j); } }
public progressStandard(CelestialBody b, ProgressType t, ProgressNode n, string s = "", string g = "", string r = "", bool rewards = true) { if (b != null) body = b; pType = t; hasRewards = rewards; id = n.Id; descriptor = s; note = g; noteReference = r; if (t == ProgressType.POINTOFINTEREST) bodyName = ((PointOfInterest)n).body; try { time = (double)n.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } if (n.IsComplete) calculateRewards(b); }
private void onReach(ProgressNode node) { if (node == null) return; if (isIntervalType(node)) { progressInterval i = progressParser.getIntervalNode(node.Id); if (i != null) { double nodeRecord = getIntervalRecord(node); if (i.getRecord(i.Interval) >= nodeRecord) return; if (node.IsReached) { i.calculateRewards(i.Interval); i.Interval += 1; } } } progressParser.updateCompletionRecord(); }
private void OnProgressNodeAchieved(ProgressNode node) { RecordsAltitudeProbe recordsAltitude = node as RecordsAltitudeProbe; if (recordsAltitude != null) { if (recordsAltitude.record >= targetAltitude) { base.SetComplete(); } } }
public void AddNode(ProgressNode node) { if ((object)(ProgressTracking.Instance.achievementTree[node.Id]) == null) { ProgressTracking.Instance.achievementTree.AddNode(node); if (node.OnDeploy != null) node.OnDeploy(); Debug.Log("*RP-0* Added node " + node.Id); } else Debug.Log("*RP-0* Tree has node " + node.Id); }
public override bool MeetRequirements() { if (KourageousTouristsAddOn.noSkyDiving) { return(false); } ProgressNode buzz = ProgressTracking.Instance.FindNode("TowerBuzz"); if (buzz == null || !buzz.IsComplete) { KourageousTouristsAddOn.printDebug("buzz node node complete"); return(false); } return(true); }
private void OnProgressComplete(ProgressNode node) { // Reflection hack time. There is a member that is (sometimes) private that stores the celestial body. // Other times it's public, but this will catch that too. FieldInfo cbField = node.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance). Where(fi => fi.FieldType == typeof(CelestialBody)).FirstOrDefault(); if (cbField != null) { lastBody = (CelestialBody)cbField.GetValue(node); } else { lastBody = null; } }
private static ConfigNode ConvertAchievementToConfigNode(ProgressNode achievement) { var configNode = new ConfigNode(achievement.Id); try { achievement.Save(configNode); } catch (Exception e) { LunaLog.LogError($"[LMP]: Error while saving achievement: {e}"); return(null); } return(configNode); }
public void AddNode(ProgressNode node) { if ((object)(ProgressTracking.Instance.achievementTree[node.Id]) == null) { ProgressTracking.Instance.achievementTree.AddNode(node); if (node.OnDeploy != null) { node.OnDeploy(); } Debug.Log("*RP-0* Added node " + node.Id); } else { Debug.Log("*RP-0* Tree has node " + node.Id); } }
private static void addProgressInterval(ProgressType p, ProgressNode n, string d, string t, string u) { if (n == null) { return; } if (intervalNodes.Contains(n.Id)) { return; } progressInterval i = null; switch (p) { case ProgressType.ALTITUDERECORD: i = new progressInterval(ProgressType.ALTITUDERECORD, n, ((RecordsAltitude)n).record, getMaxAltitudeRecord, 500, ContractDefs.Progression.RecordSplit, d, t, u); altitude = i; break; case ProgressType.DEPTHRECORD: i = new progressInterval(ProgressType.DEPTHRECORD, n, ((RecordsDepth)n).record, ContractDefs.Progression.MaxDepthRecord, 10, ContractDefs.Progression.RecordSplit, d, t, u); depth = i; break; case ProgressType.DISTANCERECORD: i = new progressInterval(ProgressType.DISTANCERECORD, n, ((RecordsDistance)n).record, ContractDefs.Progression.MaxDistanceRecord, 1000, ContractDefs.Progression.RecordSplit, d, t, u); distance = i; break; case ProgressType.SPEEDRECORD: i = new progressInterval(ProgressType.SPEEDRECORD, n, ((RecordsSpeed)n).record, ContractDefs.Progression.MaxSpeedRecord, 5, ContractDefs.Progression.RecordSplit, d, t, u); speed = i; break; default: return; } if (i == null) { return; } intervalNodes.Add(n.Id, i); }
public void LoadFromAsset() { //ProgressTreeCanvas = GameObject.Instantiate(ProgressTreeCanvas); int tier = 0; int number = 0; foreach (ProgressNode node in nodesAssets) { ProgressNodeDetails details = node.Details; ProgressNode progressNode = Instantiate(node); progressNode.Init(); progressNode.Details = details; SetupNodes(progressNode, ref tier, ref number); } DrawHorizontalLinks(); }
private void PushPreviousNodes(ProgressNode newSelected) { foreach (ProgressNode prevNode in newSelected.PreviousNodes) { if (!prevNode.Unlocked) { requiredNodes.Push(prevNode); } } foreach (ProgressNode prevNode in newSelected.PreviousNodes) { if (!prevNode.Unlocked) { PushPreviousNodes(prevNode); } } }
public progressStandard(CelestialBody b, ProgressType t, ProgressNode n, string s = "", string g = "", string r = "", bool rewards = true) { if (b != null) { body = b; } pType = t; hasRewards = rewards; id = n.Id; descriptor = s; note = g; noteReference = r; if (t == ProgressType.POINTOFINTEREST) { string bodyN = ((PointOfInterest)n).body; for (int i = FlightGlobals.Bodies.Count - 1; i >= 0; i--) { CelestialBody bod = FlightGlobals.Bodies[i]; if (bod.bodyName != bodyN) { continue; } bodyName = bod.displayName.LocalizeBodyName(); break; } } try { time = (double)n.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } if (n.IsComplete) { calculateRewards(b); } }
private void OnProgressAchieved(ProgressNode node) { Vessel vessel = FlightGlobals.ActiveVessel; // records achieved while not in a vessel won't count if (vessel == null) { return; } // records achieved while on a launch pad won't count if (vessel.situation == Vessel.Situations.PRELAUNCH) { return; } // ok, now check the record CheckAchievementsForProgress(node); }
private static void addProgressStandard(ProgressType p, ProgressNode n, string id = "", string d = "", string g = "", string r = "") { if (n == null) { return; } if (standardNodes.Contains(n.Id)) { return; } progressStandard s = null; switch (p) { case ProgressType.CREWRECOVERY: s = new progressStandard(null, ProgressType.CREWRECOVERY, n, d, g, r); crewRecovery = s; standardNodes.Add(n.Id, s); break; case ProgressType.FIRSTLAUNCH: s = new progressStandard(null, ProgressType.FIRSTLAUNCH, n, d, r); firstLaunch = s; standardNodes.Add(n.Id, s); break; case ProgressType.REACHSPACE: s = new progressStandard(null, ProgressType.REACHSPACE, n, d, g, r); reachSpace = s; standardNodes.Add(n.Id, s); break; case ProgressType.STUNT: addStunt(n, d, id, g, r); break; case ProgressType.POINTOFINTEREST: addPointOfInterest(n, d, id, g, r); break; default: return; } }
private void DrawHorizontalLinks() { int i = 0; int count = allNodes.Count; for (i = 0; i < count; i++) { if (allNodes[i] != null) { if (allNodes[i].NextNodes != null && allNodes[i].NextNodes.Count > 0) { Image.Instantiate(link, allNodes[i].GraphicNode.transform.position + new Vector3(nodeButtonX / 2 + linkLength * 1.25f / 2, 0, 0), new Quaternion(), ProgressTreeCanvas.transform).transform.localScale += new Vector3(0.25f, 0, 0); if (allNodes[i].GraphicNode.transform.position.y > allNodes[i].NextNodes[0].GraphicNode.transform.position.y) { Image.Instantiate(corner, allNodes[i].GraphicNode.transform.position + new Vector3(nodeButtonX / 2 + linkLength - 2, -12 / 2 + 2, 0), new Quaternion(0, 0, 1, 0), ProgressTreeCanvas.transform); } if (allNodes[i].GraphicNode.transform.position.y < allNodes[i].NextNodes[allNodes[i].NextNodes.Count - 1].GraphicNode.transform.position.y) { Image.Instantiate(corner, allNodes[i].GraphicNode.transform.position + new Vector3(nodeButtonX / 2 + linkLength - 2, 12 / 2 - 2, 0), new Quaternion(0, 0, 1, 1), ProgressTreeCanvas.transform); } } if (allNodes[i].PreviousNodes.Count != 0) { Image.Instantiate(link, allNodes[i].GraphicNode.transform.position + new Vector3(-(nodeButtonX / 2 + linkLength * 0.75f / 2), 0, 0), new Quaternion(), ProgressTreeCanvas.transform).transform.localScale -= new Vector3(0.25f, 0, 0); } } else { allNodes.Remove(allNodes[i]); i--; count--; } } if (availableNodes.Count > 0) { selectedNode = availableNodes[0]; selectedNode.GraphicNode.GetComponentInChildren <Button>().image.color = colorSelected; } return; }
public static void LogAchievement(Achievement achievement, ProgressNode node) { Debug.Log("FF: ribbon achievement (progress node)"); LogAchievement(achievement); if (node != null) { Debug.Log(" - Type: " + node.GetType()); Debug.Log(" - IsComplete: " + node.IsComplete); Debug.Log(" - IsReached: " + node.IsReached); Debug.Log(" - IsCompleteManned: " + node.IsCompleteManned); Debug.Log(" - IsCompleteUnmanned: " + node.IsCompleteUnmanned); } else { Debug.Log(" - node is <null>"); } Debug.Log("+ - end -"); }
/// <summary> /// Checks if an anomaly has just been discovered and awards quirks to a random discoverer /// </summary> /// <param name="n"></param> public void OnProgressComplete(ProgressNode n) { Core.Log("OnProgressComplete(" + n.Id + ")"); if (n is KSPAchievements.PointOfInterest poi) { Core.Log("Reached anomaly: " + poi.Id + " on " + poi.body, Core.LogLevel.Important); if ((Core.rand.NextDouble() < HighLogic.CurrentGame.Parameters.CustomParams <KerbalHealthQuirkSettings>().AnomalyQuirkChance) && (FlightGlobals.ActiveVessel.GetCrewCount() > 0)) { List <ProtoCrewMember> crew = FlightGlobals.ActiveVessel.GetVesselCrew(); ProtoCrewMember pcm = crew[Core.rand.Next(crew.Count)]; Quirk q = Core.KerbalHealthList.Find(pcm).AddRandomQuirk(); if (q != null) { Core.Log(pcm.name + " was awarded " + q.Title + " quirk for discovering an anomaly.", Core.LogLevel.Important); } } } }
private void ActionSelect(ProgressNode newSelected) { if (!newSelected.Unlocked) { if (availableNodes.Contains(newSelected) && selectedNode != newSelected) { Debug.Log("selected new node"); selectedNode.GraphicNode.GetComponent <Image>().color = colorAvailable; newSelected.GraphicNode.GetComponent <Image>().color = colorSelected; selectedNode = newSelected; } else { SetRequiredNodes(newSelected); selectedNode.GraphicNode.GetComponent <Image>().color = colorAvailable; selectedNode = requiredNodes.Pop(); selectedNode.GraphicNode.GetComponent <Image>().color = colorSelected; } } }
public void UnlockNode(ProgressNode unlockedNode) { unlockedNode.SetUnlocked(colorUnlocked); if (unlockedNode.Details.unitAsset.Length != 0) { foreach (Player player in GameManager.Players) { player.UnlockUnit(unlockedNode.Details.unitAsset); } } foreach (ProgressNode nextNode in unlockedNode.NextNodes) { if (CheckPreviousNodes(nextNode)) { availableNodes.Add(nextNode); nextNode.Available = true; nextNode.GraphicNode.GetComponent <Image>().color = colorAvailable; } } availableNodes.Remove(unlockedNode); }
public progressInterval(ProgressType t, ProgressNode n, double r, double m, double ro, int i, string s, string l, string u) { pType = t; id = n.Id; totalIntervals = i; descriptor = s; title = l; units = u; currentRecord = r; max = m; round = ro; records = new List <int>(i + 1); rewards = new List <Vector3>(i + 1); for (int k = 0; k < i + 1; k++) { records.Add(0); rewards.Add(new Vector3()); } if (n.IsComplete) { interval = totalIntervals + 1; } else { interval = getNextInterval(); if (interval > totalIntervals + 1) { interval = totalIntervals + 1; } } for (int j = 1; j <= totalIntervals; j++) { calculateRewards(j); } }
public static bool isIntervalType(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) { return(true); } else if (t == typeof(RecordsDepth)) { return(true); } else if (t == typeof(RecordsDistance)) { return(true); } else if (t == typeof(RecordsSpeed)) { return(true); } return(false); }
private void OnProgressReached(ProgressNode data) { sendScenarios(); }
public static string crewNameFromNode(ProgressNode n) { CrewRef c = crewFromNode(n); if (c == null) return ""; if (c.Crews.Count <= 0) return ""; StringBuilder s = StringBuilderCache.Acquire(); for (int i = 0; i < c.Crews.Count; i++) { s.Append(c.Crews[i].name); if (i < c.Crews.Count - 2) s.Append(", "); else if (i == c.Crews.Count - 2) s.Append(", and "); } return s.ToStringAndRelease(); }
public void addProgressStandard(ProgressType p, CelestialBody b, ProgressNode n, string d = "", string g = "", string r = "") { if (n == null) return; if (bodyNodes.Contains(n.Id)) return; progressStandard s = null; switch (p) { case ProgressType.FLYBYRETURN: s = new progressStandard(b, ProgressType.FLYBYRETURN, n, d, g, r); flybyReturn = s; break; case ProgressType.LANDINGRETURN: s = new progressStandard(b, ProgressType.LANDINGRETURN, n, d, g, r); landingReturn = s; break; case ProgressType.ORBITRETURN: s = new progressStandard(b, ProgressType.ORBITRETURN, n, d, g, r); orbitReturn = s; break; case ProgressType.BASECONSTRUCTION: s = new progressStandard(b, ProgressType.BASECONSTRUCTION, n, d, g, r); baseConstruct = s; break; case ProgressType.CREWTRANSFER: s = new progressStandard(b, ProgressType.CREWTRANSFER, n, d, g, r); transfer = s; break; case ProgressType.DOCKING: s = new progressStandard(b, ProgressType.DOCKING, n, d, g, r); docking = s; break; case ProgressType.ESCAPE: s = new progressStandard(b, ProgressType.ESCAPE, n, d, g, r); escape = s; break; case ProgressType.FLAGPLANT: s = new progressStandard(b, ProgressType.FLAGPLANT, n, d, g, r); flag = s; break; case ProgressType.FLIGHT: s = new progressStandard(b, ProgressType.FLIGHT, n, d, g, r); flight = s; break; case ProgressType.FLYBY: s = new progressStandard(b, ProgressType.FLYBY, n, d, g, r); flyby = s; break; case ProgressType.LANDING: s = new progressStandard(b, ProgressType.LANDING, n, d, g, r); landing = s; break; case ProgressType.ORBIT: s = new progressStandard(b, ProgressType.ORBIT, n, d, g, r); orbit = s; break; case ProgressType.RENDEZVOUS: s = new progressStandard(b, ProgressType.RENDEZVOUS, n, d, g, r); rendezvous = s; break; case ProgressType.SCIENCE: s = new progressStandard(b, ProgressType.SCIENCE, n, d, g, r); science = s; break; case ProgressType.SPACEWALK: s = new progressStandard(b, ProgressType.SPACEWALK, n, d, g, r); spacewalk = s; break; case ProgressType.SPLASHDOWN: s = new progressStandard(b, ProgressType.SPLASHDOWN, n, d, g, r); splashdown = s; break; case ProgressType.STATIONCONSTRUCTION: s = new progressStandard(b, ProgressType.STATIONCONSTRUCTION, n, d, g, r); station = s; break; case ProgressType.SUBORBIT: s = new progressStandard(b, ProgressType.SUBORBIT, n, d, g, r); suborbit = s; break; case ProgressType.SURFACEEVA: s = new progressStandard(b, ProgressType.SURFACEEVA, n, d, g, r); surfaceEVA = s; break; default: return; } if (s == null) return; bodyNodes.Add(n.Id, s); }
public void SendAchievementsMessage(ProgressNode achievement) { SendAchievementsMessage(new[] { achievement }); }
void OnProgressReached(ProgressNode p) { // Reset the generation failures ResetGenerationFailure(); }
public static double getIntervalRecord(ProgressNode n) { string descr = ""; return(getIntervalRecord(n, ref descr)); }
public static CelestialBody getBodyFromType(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyEscape)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyFlight)) { return(((CelestialBodyFlight)n).body); } else if (t == typeof(CelestialBodyFlyby)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyLanding)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyOrbit)) { return(((CelestialBodyOrbit)n).body); } else if (t == typeof(CelestialBodySuborbit)) { return(((CelestialBodySuborbit)n).body); } else if (t == typeof(CelestialBodyReturn)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyScience)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodySplashdown)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyTransfer)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Docking)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(FlagPlant)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Rendezvous)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Spacewalk)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(StationConstruction)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(SurfaceEVA)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Celestial Body Reference\n" + e); } return(null); }
public static void addStunt(ProgressNode n, string d, string id, string note, string r = "") { progressStandard s = null; if (id == ProgressTracking.Instance.runwayLanding.Id) { s = new progressStandard(null, ProgressType.STUNT, n, d); runwayLanding = s; } else if (id == ProgressTracking.Instance.KSCLanding.Id) { s = new progressStandard(null, ProgressType.STUNT, n, d); launchpadLanding = s; } else if (id == ProgressTracking.Instance.launchpadLanding.Id) { s = new progressStandard(null, ProgressType.STUNT, n, d); } else if (id == ProgressTracking.Instance.towerBuzz.Id) { s = new progressStandard(null, ProgressType.STUNT, n, d, note, r); towerBuzz = s; } if (s == null) return; standardNodes.Add(n.Id, s); }
private void OnProgressAchieved(ProgressNode node) { //Log.Test("EventObserver::OnProgressAchieved"); }
private void SetRequiredNodes(ProgressNode newSelected) { requiredNodes = new Stack <ProgressNode>(); requiredNodes.Push(newSelected); PushPreviousNodes(newSelected); }
public static void addPointOfInterest(ProgressNode n, string d, string name, string note, string r = "") { if (pointsOfInterest.Contains(name)) return; progressStandard s = new progressStandard(null, ProgressType.POINTOFINTEREST, n, d, note, r); pointsOfInterest.Add(name, s); }
public static string vesselNameFromNode(ProgressNode n) { VesselRef v = vesselFromNode(n); if (v == null) return ""; return v.Name; }
public static VesselRef vesselFromNode(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CelestialBodyFlight)) return ((CelestialBodyFlight)n).firstVessel; else if (t == typeof(CelestialBodyLanding)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CelestialBodyOrbit)) return ((CelestialBodyOrbit)n).firstVessel; else if (t == typeof(CelestialBodySuborbit)) return ((CelestialBodySuborbit)n).firstVessel; else if (t == typeof(CelestialBodyReturn)) return ((CelestialBodyReturn)n).firstVessel; else if (t == typeof(CelestialBodyScience)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(StationConstruction)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(ReachSpace)) return ((ReachSpace)n).firstVessel; else if (t == typeof(PointOfInterest)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(TowerBuzz)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[3].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Vessel Reference\n" + e); } return null; }
private void onProgressAchieved(ProgressNode p) { stopPunishing(); }
private static void addProgressStandard(ProgressType p, ProgressNode n, string id = "", string d = "", string g = "", string r = "") { if (n == null) return; if (standardNodes.Contains(n.Id)) return; progressStandard s = null; switch (p) { case ProgressType.CREWRECOVERY: s = new progressStandard(null, ProgressType.CREWRECOVERY, n, d, g, r); crewRecovery = s; standardNodes.Add(n.Id, s); break; case ProgressType.FIRSTLAUNCH: s = new progressStandard(null, ProgressType.FIRSTLAUNCH, n, d, r); firstLaunch = s; standardNodes.Add(n.Id, s); break; case ProgressType.REACHSPACE: s= new progressStandard(null, ProgressType.REACHSPACE, n, d, g, r); reachSpace = s; standardNodes.Add(n.Id, s); break; case ProgressType.STUNT: addStunt(n, d, id, g, r); break; case ProgressType.POINTOFINTEREST: addPointOfInterest(n, d, id, g, r); break; default: return; } }
private double getIntervalRecord(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) return ((RecordsAltitude)n).record; else if (t == typeof(RecordsDepth)) return ((RecordsDepth)n).record; else if (t == typeof(RecordsDistance)) return ((RecordsDistance)n).record; else if (t == typeof(RecordsSpeed)) return ((RecordsSpeed)n).record; return 0; }
private void onComplete(ProgressNode node) { if (node == null) return; if (!node.IsComplete) return; if (!isIntervalType(node)) { if (isPOI(node)) { progressStandard s = progressParser.getPOINode(node.Id); if (s == null) { Debug.Log("[Progress Tracking Parser] POI Progress Node Not Found"); } else { s.calculateRewards(null); s.NoteReference = progressParser.vesselNameFromNode(node); try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } else { progressStandard s = progressParser.getStandardNode(node.Id); if (s != null) { s.calculateRewards(null); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) note = progressParser.vesselNameFromNode(node); s.NoteReference = note; try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } else { CelestialBody body = getBodyFromType(node); if (body == null) { Debug.Log("[Progress Tracking Parser] Body From Progress Node Null..."); } else { progressBodyCollection b = progressParser.getProgressBody(body); if (b != null) { progressStandard sb = b.getNode(node.Id); if (sb == null) { Debug.Log("[Progress Tracking Parser] Body Sub Progress Node Not Found"); } else { sb.calculateRewards(body); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) note = progressParser.vesselNameFromNode(node); sb.NoteReference = note; try { sb.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } } } } } else { progressInterval i = progressParser.getIntervalNode(node.Id); if (i == null) { Debug.Log("[Progress Tracking Parser] Interval Progress Node Not Found"); } else { if (node.IsReached) { i.calculateRewards(i.Interval); i.Interval += 1; } } } progressParser.updateCompletionRecord(); }
public void AchievementAchieved(ProgressNode progressNode) { //This event is triggered to often (always if some speed or distance record changes). //LunaLog.Log("Achievement achieved:" + progressNode.Id); }
private bool isIntervalType(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) return true; else if (t == typeof(RecordsDepth)) return true; else if (t == typeof(RecordsDistance)) return true; else if (t == typeof(RecordsSpeed)) return true; return false; }
public void addProgressStandard(ProgressType p, CelestialBody b, ProgressNode n, string d = "", string g = "", string r = "") { if (n == null) { return; } if (bodyNodes.Contains(n.Id)) { return; } progressStandard s = null; switch (p) { case ProgressType.FLYBYRETURN: s = new progressStandard(b, ProgressType.FLYBYRETURN, n, d, g, r); flybyReturn = s; break; case ProgressType.LANDINGRETURN: s = new progressStandard(b, ProgressType.LANDINGRETURN, n, d, g, r); landingReturn = s; break; case ProgressType.ORBITRETURN: s = new progressStandard(b, ProgressType.ORBITRETURN, n, d, g, r); orbitReturn = s; break; case ProgressType.BASECONSTRUCTION: s = new progressStandard(b, ProgressType.BASECONSTRUCTION, n, d, g, r); baseConstruct = s; break; case ProgressType.CREWTRANSFER: s = new progressStandard(b, ProgressType.CREWTRANSFER, n, d, g, r); transfer = s; break; case ProgressType.DOCKING: s = new progressStandard(b, ProgressType.DOCKING, n, d, g, r); docking = s; break; case ProgressType.ESCAPE: s = new progressStandard(b, ProgressType.ESCAPE, n, d, g, r); escape = s; break; case ProgressType.FLAGPLANT: s = new progressStandard(b, ProgressType.FLAGPLANT, n, d, g, r); flag = s; break; case ProgressType.FLIGHT: s = new progressStandard(b, ProgressType.FLIGHT, n, d, g, r); flight = s; break; case ProgressType.FLYBY: s = new progressStandard(b, ProgressType.FLYBY, n, d, g, r); flyby = s; break; case ProgressType.LANDING: s = new progressStandard(b, ProgressType.LANDING, n, d, g, r); landing = s; break; case ProgressType.ORBIT: s = new progressStandard(b, ProgressType.ORBIT, n, d, g, r); orbit = s; break; case ProgressType.RENDEZVOUS: s = new progressStandard(b, ProgressType.RENDEZVOUS, n, d, g, r); rendezvous = s; break; case ProgressType.SCIENCE: s = new progressStandard(b, ProgressType.SCIENCE, n, d, g, r); science = s; break; case ProgressType.SPACEWALK: s = new progressStandard(b, ProgressType.SPACEWALK, n, d, g, r); spacewalk = s; break; case ProgressType.SPLASHDOWN: s = new progressStandard(b, ProgressType.SPLASHDOWN, n, d, g, r); splashdown = s; break; case ProgressType.STATIONCONSTRUCTION: s = new progressStandard(b, ProgressType.STATIONCONSTRUCTION, n, d, g, r); station = s; break; case ProgressType.SUBORBIT: s = new progressStandard(b, ProgressType.SUBORBIT, n, d, g, r); suborbit = s; break; case ProgressType.SURFACEEVA: s = new progressStandard(b, ProgressType.SURFACEEVA, n, d, g, r); surfaceEVA = s; break; default: return; } if (s == null) { return; } bodyNodes.Add(n.Id, s); }
private bool isPOI(ProgressNode n) { if (n.GetType() == typeof(PointOfInterest)) return true; return false; }
private void onProgressComplete(ProgressNode p) { stopPunishing(); }
private CelestialBody getBodyFromType(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyEscape)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyFlight)) return ((CelestialBodyFlight)n).body; else if (t == typeof(CelestialBodyFlyby)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyLanding)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyOrbit)) return ((CelestialBodyOrbit)n).body; else if (t == typeof(CelestialBodySuborbit)) return ((CelestialBodySuborbit)n).body; else if (t == typeof(CelestialBodyReturn)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyScience)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodySplashdown)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyTransfer)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Docking)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(FlagPlant)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Rendezvous)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Spacewalk)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(StationConstruction)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(SurfaceEVA)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node Celestial Body Reference\n" + e); } return null; }
private void OnProgressReached(ProgressNode data) { try { sendScenarios(); } catch (Exception e) { Log.Debug("OnProgressReached threw exception: " + e); } }
private static void addProgressInterval(ProgressType p, ProgressNode n, string d = "") { if (n == null) return; if (intervalNodes.Contains(n.Id)) return; progressInterval i = null; switch (p) { case ProgressType.ALTITUDERECORD: i = new progressInterval(ProgressType.ALTITUDERECORD, n, ((RecordsAltitude)n).record, getMaxAltitudeRecord, 500, ContractDefs.Progression.RecordSplit, d); altitude = i; break; case ProgressType.DEPTHRECORD: i = new progressInterval(ProgressType.DEPTHRECORD, n, ((RecordsDepth)n).record, ContractDefs.Progression.MaxDepthRecord, 10, ContractDefs.Progression.RecordSplit, d); depth = i; break; case ProgressType.DISTANCERECORD: i = new progressInterval(ProgressType.DISTANCERECORD, n, ((RecordsDistance)n).record, ContractDefs.Progression.MaxDistanceRecord, 1000, ContractDefs.Progression.RecordSplit, d); distance = i; break; case ProgressType.SPEEDRECORD: i = new progressInterval(ProgressType.SPEEDRECORD, n, ((RecordsSpeed)n).record, ContractDefs.Progression.MaxSpeedRecord, 5, ContractDefs.Progression.RecordSplit, d); speed = i; break; default: return; } if (i == null) return; intervalNodes.Add(n.Id, i); }
private void OnProgressComplete(ProgressNode data) { sendScenarios(); }
private void onComplete(ProgressNode node) { if (node == null) { return; } if (!node.IsComplete) { return; } if (!progressParser.isIntervalType(node)) { if (progressParser.isPOI(node)) { progressStandard s = progressParser.getPOINode(node.Id); if (s == null) { Debug.Log("[Progress Tracking Parser] POI Progress Node Not Found"); } else { s.calculateRewards(null); s.NoteReference = progressParser.vesselNameFromNode(node); try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } else { progressStandard s = progressParser.getStandardNode(node.Id); if (s != null) { s.calculateRewards(null); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) { note = progressParser.vesselNameFromNode(node); } s.NoteReference = note; try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } else { CelestialBody body = progressParser.getBodyFromType(node); if (body == null) { Debug.Log("[Progress Tracking Parser] Body From Progress Node Null..."); } else { progressBodyCollection b = progressParser.getProgressBody(body); if (b != null) { progressStandard sb = b.getNode(node.Id); if (sb == null) { Debug.Log("[Progress Tracking Parser] Body Sub Progress Node Not Found"); } else { sb.calculateRewards(body); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) { note = progressParser.vesselNameFromNode(node); } sb.NoteReference = note; try { sb.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } } } } } else { progressInterval i = progressParser.getIntervalNode(node.Id); if (i == null) { Debug.Log("[Progress Tracking Parser] Interval Progress Node Not Found"); } else { if (node.IsReached) { i.calculateRewards(i.Interval); i.Interval += 1; } } } progressParser.updateCompletionRecord(); }
public static CrewRef crewFromNode(ProgressNode n) { Type t = n.GetType(); try { //if (t == typeof(FlagPlant)) // return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); if (t == typeof(Spacewalk)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(SurfaceEVA)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CrewRecovery)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node Crew Reference\n" + e); } return null; }
private void SetupNodes(ProgressNode progressNode, ref int tier, ref int number) { if (progressNode.Details.Name == null) { allNodes.Add(null); number++; return; } if (tier != progressNode.Details.Tier) { tier = progressNode.Details.Tier; number = 0; } progressNode.GraphicNode = Button.Instantiate(techNodePrefab, new Vector3(startCordinates.x + tier * (2 * linkLength + 2 * nodeButtonX / 2), startCordinates.y + number * (linkLength + nodeButtonY - 10), 0), new Quaternion(), ProgressTreeCanvas.transform) as TechNodeBehaviour; progressNode.GraphicNode.name = "node_" + tier + "_" + number; progressNode.GraphicNode.GetComponentInChildren <Text>().text = progressNode.Details.Name; progressNode.GraphicNode.GetComponent <Image>().color = colorNotAvailable; progressNode.GraphicNode.onClick.AddListener(delegate { ActionSelect(progressNode); }); progressNode.GraphicNode.Node = progressNode; // required for TechNodeBehaviour Node to display info on pointer enter if (progressNode.Details.Tier == 0) { progressNode.Available = true; progressNode.GraphicNode.GetComponent <Image>().color = colorAvailable; availableNodes.Add(progressNode); } if (progressNode.Details.Previous != null) { int k = 0; progressNode.PreviousNodes = new List <ProgressNode>(); for (int j = allNodes.Count - 1; j > -1; j--) { if (allNodes[j] != null) { int i = 1; foreach (int Id in progressNode.Details.Previous) { if (allNodes[j].Details.Id == Id) { progressNode.PreviousNodes.Add(allNodes[j]); allNodes[j].NextNodes.Add(progressNode); k++; Vector3 distance = progressNode.GraphicNode.transform.position - allNodes[j].GraphicNode.transform.position; int y = -(int)Math.Ceiling((float)distance.y / (float)60.0); int sign = 1; if (y != 0) { Quaternion quaternion = new Quaternion(); Vector3 additionalScale = new Vector3(); float localLinkLength = linkLength; if (y > 0) { sign = -1; quaternion = new Quaternion(0, 0, 0, 0); } else { sign = 1; quaternion = new Quaternion(0, 0, -1, 1); } if (y == 1 || y == -1) { localLinkLength = linkLength; additionalScale = new Vector3(0, 0, 0); } else { localLinkLength = linkLength * 1.5f; additionalScale = new Vector3(0.5f, 0, 0); Vector3 vector = new Vector3(nodeButtonX / 2 + linkLength + 2, sign * (10 + linkLength + localLinkLength / 2 + (-sign * (y + 1) - 2) * localLinkLength), 0); Image.Instantiate(link, allNodes[j].GraphicNode.transform.position + vector, new Quaternion(0, 0, 1, 1), ProgressTreeCanvas.transform).transform.localScale += additionalScale; } Vector3 vector1 = new Vector3(nodeButtonX / 2 + linkLength + 2, sign * (10 + linkLength + localLinkLength / 2 + (-sign * y - 2) * localLinkLength), 0); Image.Instantiate(link, allNodes[j].GraphicNode.transform.position + vector1, new Quaternion(0, 0, 1, 1), ProgressTreeCanvas.transform).transform.localScale += additionalScale; Vector3 vector2 = new Vector3(nodeButtonX / 2 + linkLength + 12 / 2, -y * (linkLength + 12 + 12 - 4) + sign * (-4), 0); Image.Instantiate(corner, allNodes[j].GraphicNode.transform.position + vector2, quaternion, ProgressTreeCanvas.transform); //last = progressNode.GraphicNode.transform.position; } } i++; } } if (k >= progressNode.Details.Previous.Length) { break; } } } number++; allNodes.Add(progressNode); }