public void RnDOpened(RDController controller) { if (unlockTechnology == TechnologyUnlock.UNLOCK) { UnlockTechnologies(); } else if (unlockTechnology == TechnologyUnlock.REVERT) { LockTechnologies(); } }
public void OnTreeSpawn(RDController controller) { if (TestFlightManagerScenario.Instance == null || controller.nodes == null) { return; } List <RDNode> nodes = controller.nodes; if (this.baseCost == null) { baseCost = new Dictionary <string, int>(); for (int i = 0; i < nodes.Count; i++) { RDNode node = nodes[i]; if (node != null && node.tech != null) { baseCost.Add(nodes[i].tech.techID, nodes[i].tech.scienceCost); } } } for (int n = 0; n < nodes.Count; n++) { RDNode node = nodes[n]; if (node != null && node.tech != null && !node.IsResearched && node.tech.partsAssigned != null) { float discount = 0f; List <AvailablePart> parts = node.tech.partsAssigned; for (int p = 0; p < parts.Count; p++) { if (parts[p] != null) { Part prefab = parts[p].partPrefab; TestFlightPartData partData = TestFlightManagerScenario.Instance.GetPartDataForPart(parts[p].name); if (partData != null && prefab != null) { TestFlightCore core = (TestFlightCore)prefab.Modules.OfType <TestFlightCore>().FirstOrDefault(); float flightData = partData.GetFloat("flightData"); if (core != null && flightData > core.startFlightData) { discount += (int)(((flightData - core.startFlightData) / (core.maxData - core.startFlightData)) * core.scienceDataValue); } } } } if (discount > 0) { node.tech.scienceCost = (int)Math.Max(0, baseCost[node.tech.techID] - discount); } } } }
public void RnDOpened(RDController controller) { //bool flag = this.unlockTechnology == TechnologyUnlock.UNLOCK; //if (flag) if (this.unlockTechnology == TechnologyUnlock.UNLOCK) { this.UnlockTechnologies(); } else { //bool flag2 = this.unlockTechnology == TechnologyUnlock.REVERT; //if (flag2) if (this.unlockTechnology == TechnologyUnlock.REVERT) { this.LockTechnologies(); } } }
private void processNewNodes(ConfigNode tree) { Debug.Log("processing all NEW_NODE items"); //RDController rdControl = GameObject.FindObjectOfType<RDController>(); List <RDNode> newRDNodes = new List <RDNode>(); try { foreach (ConfigNode cfgNodeNew in tree.GetNodes("NEW_NODE")) { //only create RDNodes that are not yet in the Techtree string newName = cfgNodeNew.GetValue("gameObjectName"); if (!Array.Exists <RDNode>(AssetBase.RnDTechTree.GetTreeNodes(), x => x.gameObject.name == newName)) { RDNode newNode = createNode(); if (newNode.tech == null) { Debug.Log("newNode.tech is null after createNode"); } //if (newNode.gameObject == null) // Debug.Log("newNode.gameObject is null after c-tor"); Debug.Log("calling newnode.setup"); newNode.Setup(); //This sets the anchor offsets if (newNode.gameObject == null) { Debug.Log("newNode.gameObject is still null after Setup"); } //Debug.Log("calling rdNode.Warmup()"); //newNode.Warmup(newTech); //Debug.Log("NEWNODE: after Setup(), startNode has " + findStartNode().children.Count() + " children"); Debug.Log("created node and tech, now setting basic tech parameters"); //setup all the basic parameters that are not handled in updatenode newNode.treeNode = true; newNode.gameObject.name = newName; newNode.name = newName.Substring(newName.IndexOf("_")); newNode.tech.techID = newNode.name; newNode.tech.hideIfNoParts = false; Debug.Log("updating node with cfgFile-parameters"); updateNode(newNode, cfgNodeNew); Debug.Log("created new RDNode " + newNode.gameObject.name + " with RDTech.title=" + newNode.tech.title + "(techId) =" + newNode.tech.techID); //Debug.Log("NEWNODE: after updateNode(), startNode has " + findStartNode().children.Count() + " children"); RDController rdControl = GameObject.FindObjectOfType <RDController>(); Debug.Log("NEWNODE: calling RegisterNode(), AssetBase.TechTree has " + AssetBase.RnDTechTree.GetTreeNodes().Count() + " entries"); rdControl.RegisterNode(newNode); //TODO maybe this needs to be done the other way around? Debug.Log("NEWNODE: after RegisterNode(), AssetBase.TechTree has " + AssetBase.RnDTechTree.GetTreeNodes().Count() + " entries"); //Debug.Log("Invoking rdController.registerNode"); //typeof(RDNode).GetMethod("InitializeArrows", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(newNode, new object[] { }); newRDNodes.Add(newNode); //addedNewNodes.Add(newName); } //endif tech not yet added } //endof all newnodes //AARRGG this is readonly, cannot add to this.... //Array.Resize<RDNode>(ref AssetBase.RnDTechTree.GetTreeNodes(), 60); //AssetBase.RnDTechTree.GetTreeNodes().Concat(newRDNodes); //AssetBase.RnDTechTree.GetTreeTechs().Concat(newRDTechs); } catch (Exception ex) { Debug.LogError("Exception in NEWNODE processing - " + ex.Message + " at " + ex.StackTrace); } } //end loadTree()