예제 #1
0
    public void RefreshTree(SkillTree skillTree)
    {
        Skill[] tree = skillTree.tree;

        int maxLevel = skillTree.GetMaxHiarchyLevelOfTree();

        for (int j = 0; j < maxLevel + 1; j++)
        {
            if (j + 1 > allColumns.Count)
            {
                GameObject col = Instantiate(columnPrefab, transform);
                col.SetActive(true);
                allColumns.Add(col);
            }
        }



        if (tree.Length > allNodes.Count)
        {
            allNodes.AddRange(new GameObject[tree.Length - allNodes.Count]);
        }

        for (int i = 0; i < tree.Length; i++)
        {
            if (allNodes[i] == null)
            {
                allNodes[i] = InstantiateNodeObject(tree[i].Name);
            }

            allNodes[i].SetActive(true);
            SkillNode skillNode = allNodes[i].GetComponent <SkillNode>();
            skillNode.SetSkillTreeAndIndex(skillTree, i);
            skillNode.UpdateNode(i);

            allNodes[i].transform.SetParent(allColumns[skillTree.GetHiarchyLevelOfSkill(tree[i].Name)].transform);
        }
    }