private static BTreeNode CreateSelectorNode(SelectorNodeType _subType, BTreeNode _parent, string _nodeName, params int[] _param) { BTreeNode _node = null; switch (_subType) { case SelectorNodeType.BTreeNodeParallel: _node = CreateParallelNode(_parent, _nodeName, (BTreeParallelFinishCondition)_param[0]); break; case SelectorNodeType.BTreeNodePrioritySelector: _node = CreatePrioritySelectorNode(_parent, _nodeName); break; case SelectorNodeType.BTreeNodeNonePrioritySelector: _node = CreateNonePrioritySelectorNode(_parent, _nodeName); break; case SelectorNodeType.BTreeNodeSequence: _node = CreateSequenceNode(_parent, _nodeName); break; case SelectorNodeType.BTreeNodeLoop: _node = CreateLoopNode(_parent, _nodeName, _param[0]); break; default: break; } return(_node); }
private static BTreeNode CreateTreeNode(ref BTreeNode[] _nodes, TreeNodeConfig[] _nodeConfigs, int index) { TreeNodeConfig _nodeConfig = _nodeConfigs[index]; if (_nodeConfig.m_ParentIndex >= 0 && _nodes[_nodeConfig.m_ParentIndex] == null) { _nodes[_nodeConfig.m_ParentIndex] = CreateTreeNode(ref _nodes, _nodeConfigs, _nodeConfig.m_ParentIndex); } BTreeNode parent = null; if (_nodeConfig.m_ParentIndex >= 0) { parent = _nodes[_nodeConfig.m_ParentIndex]; } NodeType type = (NodeType)_nodeConfig.m_NodeType; BTreeNode _node = null; switch (type) { case NodeType.SelectorNode: SelectorNodeType subType = (SelectorNodeType)_nodeConfig.m_NodeSubType; _node = CreateSelectorNode(subType, parent, _nodeConfig.m_NodeName, _nodeConfig.m_OtherParams); break; case NodeType.ActionNode: _node = CreateActionNode(parent, _nodeConfig.m_NodeName, ActionTypeDic[_nodeConfig.m_ActionNodeName]); break; default: break; } _node.m_Index = index; return(_node); }
private static int[] GetOtherParamsFromBTreeNode(BTreeNode _node, NodeType _nodeType, SelectorNodeType _subType) { int[] _otherParams = null; switch (_nodeType) { case NodeType.SelectorNode: switch (_subType) { case SelectorNodeType.BTreeNodeParallel: _otherParams = new int[1]; _otherParams[0] = (int)((BTreeNodeParallel)_node).m_FinishCondition; break; case SelectorNodeType.BTreeNodeLoop: _otherParams = new int[1]; _otherParams[0] = ((BTreeNodeLoop)_node).GetLoopCount(); break; default: break; } break; case NodeType.ActionNode: _otherParams = null; break; default: break; } return(_otherParams); }