public void resetTree() { foreach (var item in RItems) { item.Init(); } researchTree = new ResearchTreeNode(ResearchBase).createTree(); }
private ResearchButton createButton(ResearchTreeNode node, Transform parent) { ResearchButton button = Instantiate(researchButtonPrefab, parent); node.button = button; button.setResearchText(node.researchName); button.setCostText(node.xpCost); button.setItem(node.Item); button.setCost(node.xpCost); return(button); }
public ResearchTreeNode createTree() { foreach (var child in item.getChilds()) { var node = new ResearchTreeNode(child); if (!childs.Contains(node)) { this.childs.Add(node); node.addParent(this); node.createTree(); } } return(this); }
private GameObject createTreeGameObject(ResearchTreeNode node, int depth, Dictionary <int, GameObject> levels) { if (!levels.ContainsKey(depth)) { var o = Instantiate(TreeLevel); o.transform.SetParent(TreeRoot.transform); levels.Add(depth, o); } var b = createButton(node, levels[depth].transform); foreach (var child in node.Childs) { var trans = createTreeGameObject(child, depth + 1, levels); } return(b.gameObject); }
public void setNodeData(ResearchTreeNode node) { var n = node.FindNode(researchText.text); if (n != null) { nodeData = n; nodeData.button = this; if (nodeData.researched) { setResearched(); } else { GetComponent <Button>().interactable = nodeData.prerequisites.ToList().TrueForAll(prerequisitesResearched); } } }
void Start() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } researchRoot = ResearchController.instance.getResearchTreeRoot(); UIController.Instance.CreateTurretButtons(researchRoot.getResearchedTurrets().ToList()); UIController.Instance.CreateStructureBlockButtons(researchRoot.getResearchedSB().ToList()); // fortBase = new GameObject("FortBase"); fortBase.tag = "FortBase"; // DontDestroyOnLoad(gameObject); }
private GameObject createTreeGameObject(ResearchTreeNode node) { return(createTreeGameObject(node, 0, new Dictionary <int, GameObject>())); }
public void addParent(ResearchTreeNode node) { prerequisites.Add(node); }
private bool prerequisitesResearched(ResearchTreeNode item) { return(item.researched); }