コード例 #1
0
        public NodeBase GetNodeAlongThisAndParentSequeces(int nodeId)
        {
            NodeBase targetNode = null;
            //优先查找技能序列树中的节点
            NodeSequence sequence = this;

            while (sequence != null)
            {
                targetNode = sequence.GetNode(nodeId);

                if (targetNode != null)
                {
                    return(targetNode);
                }

                sequence = sequence.parentSequence;
            }

            //查找公共节点
            targetNode = GraphBehaviour.GetCommonNode(nodeId);

            if (targetNode == null)
            {
                Debug.LogErrorFormat("整个技能中找不到id为 {0} 的节点", nodeId);
            }
            return(targetNode);
        }
コード例 #2
0
        /// <summary>
        /// 创建NodeSequence,会共用传入的rootNode
        /// </summary>
        /// <param name="rootNode"></param>
        /// <param name="sequenceNodeIds"></param>
        /// <param name="graphBehaviour"></param>
        /// <param name="parentSequence"></param>
        public NodeSequence(NodeBase rootNode, int[] sequenceNodeIds, GraphBehaviour graphBehaviour, NodeSequence parentSequence)
        {
            GraphBehaviour      = graphBehaviour;
            RootNode            = rootNode;
            this.parentSequence = parentSequence;

            RootNode.SetGraphBehaviour(graphBehaviour);
            RootNode.SetNodeSequence(this);

            sequenceNodeDictionary = new Dictionary <int, NodeBase>();
            sequenceNodeDictionary.Add(RootNode.nodeId, RootNode);
            for (int i = 0; i < sequenceNodeIds.Length; i++)
            {
                NodeBase sequenceNode = graphBehaviour.DeserializeNode(sequenceNodeIds[i]);
                sequenceNode.SetNodeSequence(this);
                sequenceNode.SetGraphBehaviour(graphBehaviour);
                sequenceNodeDictionary.Add(sequenceNodeIds[i], sequenceNode);
            }

            runningNodeList       = new List <NodeBase>();
            executeFinishNodeList = new List <NodeBase>();

            runningChildSequenceList = new List <NodeSequence>();
        }
コード例 #3
0
 public void SetGraphBehaviour(GraphBehaviour graphBehaviour)
 {
     this.graphBehaviour = graphBehaviour;
 }