/* * As a player traverses their career, they will be presented with * multiple choices per level according to previous choices. * */ public static bool NodeIsActive(CareerNode node, List <CareerNode> nodes, int currentLevel, int lastNode) { if (node == null || nodes == null) { GD.Print("NodeIsActive: Invalid args " + node + "," + nodes); return(false); } int nodeLevel = GetLevel(node, nodes); if (node.IsLeaf() && currentLevel == -1) { return(true); } if (CareerNode.IsRoot(node, nodes) && currentLevel == 0) { GD.Print("Node " + node.nodeId + " is root and currentLevel is 0"); return(true); } if (node.HasChild(lastNode)) { return(true); } return(false); }
public static System.Collections.Generic.Dictionary <int, CareerNode[]> GetLevels(List <CareerNode> nodes) { System.Collections.Generic.Dictionary <int, CareerNode[]> ret; ret = new System.Collections.Generic.Dictionary <int, CareerNode[]>(); CareerNode root = Root(nodes); CareerNode[] rootRow = new CareerNode[1]; rootRow[0] = root; ret.Add(0, rootRow); if (root == null) { GD.Print("CareerNode.GetLevels Root node null"); return(null); } else if (root.IsLeaf()) { return(ret); } int level = 1; List <CareerNode> nextLevel = GetChildren(root, nodes); while (nextLevel.Count > 0) { ret.Add(level, nextLevel.ToArray()); level++; nextLevel = GetChildren(nextLevel, nodes); } return(ret); }