public static void NodeSetOwner(BaseSprite owner, NodeBase nodeBase) { Queue <NodeBase> queue = new Queue <NodeBase>(); queue.Enqueue(nodeBase); while (queue.Count > 0) { NodeBase node = queue.Dequeue(); if (null == node) { continue; } if (typeof(IBTActionOwner).IsAssignableFrom(node.GetType())) { IBTActionOwner bTActionOwner = node as IBTActionOwner; bTActionOwner.SetOwner(owner); } if (node.NodeType() == (int)NODE_TYPE.ACTION && node.NodeType() == (int)NODE_TYPE.CONDITION) { continue; } NodeComposite nodeComposite = node as NodeComposite; if (null == nodeComposite) { continue; } foreach (var childNode in nodeComposite.GetChilds()) { queue.Enqueue(childNode); } } }
private void InitNode(BaseSprite owner, NodeBase nodeBase) { if (nodeBase == null) { int a = 0; } if (nodeBase.NodeType == NODE_TYPE.ACTION) { ActionBase actionBase = nodeBase as ActionBase; if (null != actionBase) { actionBase.SetOwner(owner); } } else if (nodeBase.NodeType == NODE_TYPE.CONDITION) { ConditionBase conditionBase = nodeBase as ConditionBase; if (null != conditionBase) { conditionBase.SetOwner(owner); } } else { NodeComposite nodeComposite = nodeBase as NodeComposite; if (null == nodeComposite) { return; } foreach (var childNode in nodeComposite.GetChilds()) { InitNode(owner, childNode); } } }