コード例 #1
0
    public List <AbilityTreeNode> GetChildren()
    {
        List <AbilityTreeNode> children = new List <AbilityTreeNode>();

        if (LeftBranch != null)
        {
            children.Add(LeftBranch.GetRoot());
        }
        if (MiddleBranch != null)
        {
            children.Add(MiddleBranch.GetRoot());
        }
        if (RightBranch != null)
        {
            children.Add(RightBranch.GetRoot());
        }

        return(children);
    }
コード例 #2
0
ファイル: AbilityTreeUI.cs プロジェクト: DrDoak/GDS2
    void CreateTreeNodes()
    {
        GameObject              g;
        AbilityTreeNode         node  = tree.GetRoot();
        Queue <AbilityTreeNode> queue = new Queue <AbilityTreeNode>();

        queue.Enqueue(node);
        node = queue.Dequeue();

        //Foreach node, create a button
        while (node != null)
        {
            //Create UI Things
            g = Instantiate(NodePrefab);
            g.transform.SetParent(Canvas.transform);
            g.GetComponent <NodeUI>().treeNode = node;
            g.GetComponent <RectTransform>().anchoredPosition = RuntimeTransforms.GetVector(node.TreeDepth, RuntimeTransforms.GetBranchDirection(node.ability.AbilityClassification));
            //Attach new UI Thing to this script

            foreach (AbilityTreeNode n in node.tree.GetChildren())
            {
                queue.Enqueue(n);
            }
            if (queue.Count > 0)
            {
                node = queue.Dequeue();
            }
            else
            {
                node = null;
            }
        }

        //Attach visually to the parent

        created = true;
    }