コード例 #1
0
    public void CreatureTraverseParentTree(Creature_V2 parent, int colorIndex, string indent)
    {
        List <Creature_V2> children = parent.GetChildren();


        if (children.Count > 0)
        {
            for (int i = 0; i < children.Count; i++)
            {
                TreeData treeData = new TreeData();

                if (children[i].IsAlive())
                {
                    treeData.name = indent + children[i].GetName();
                }
                else
                {
                    treeData.name = indent + children[i].GetName() + " [DEAD]";
                }

                if (colorIndex == colors.Length)
                {
                    colorIndex = 0;
                }

                treeData.color = colors[colorIndex];

                treeDataList.Add(treeData);

                CreatureTraverseParentTree(children[i], colorIndex + 1, indent + "  ");
            }
        }
    }
コード例 #2
0
    //DEBUG ONLY
    public string CreatureTraverseRecursive(Creature_V2 parent)
    {
        string             add      = "";
        List <Creature_V2> children = parent.GetChildren();

        if (children.Count == 0)
        {
            add = parent.GetID() + "::" + parent.GetName() + "__";
            return(add);
        }

        for (int i = 0; i < children.Count; i++)
        {
            add += CreatureTraverseRecursive(children[i]);
        }

        return(parent.GetID() + "::" + parent.GetName() + "==>" + add);
    }