示例#1
0
 public void resetTree()
 {
     foreach (var item in RItems)
     {
         item.Init();
     }
     researchTree = new ResearchTreeNode(ResearchBase).createTree();
 }
示例#2
0
    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);
    }
示例#3
0
    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);
    }
示例#4
0
    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);
    }
示例#5
0
    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);
            }
        }
    }
示例#6
0
    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);
    }
示例#7
0
 private GameObject createTreeGameObject(ResearchTreeNode node)
 {
     return(createTreeGameObject(node, 0, new Dictionary <int, GameObject>()));
 }
示例#8
0
 public void addParent(ResearchTreeNode node)
 {
     prerequisites.Add(node);
 }
示例#9
0
 private bool prerequisitesResearched(ResearchTreeNode item)
 {
     return(item.researched);
 }