Beispiel #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);
        }
Beispiel #2
0
        protected T GetInputValue <T>(NodeInputVariable <T> inputVariable)
        {
            if (inputVariable == null)
            {
                return(default(T));
            }

            if (inputVariable.targetNodeId < 0 && inputVariable.targetPortId < 0)
            {
                return(inputVariable.value);
            }

            NodeBase targetNode = null;

            //NodeSequence为null 说明是公共节点
            if (nodeSequence == null)
            {
                targetNode = graphBehaviour.GetCommonNode(inputVariable.targetNodeId);
            }
            else
            {
                targetNode = nodeSequence.GetNodeAlongThisAndParentSequeces(inputVariable.targetNodeId);
            }

            if (targetNode == null)
            {
                return(default(T));
            }

            NodeVariable     nodeVariable   = targetNode.GetOutputPortValue(inputVariable.targetPortId);
            NodeVariable <T> resultVariable = nodeVariable as NodeVariable <T>;

            if (resultVariable == null)
            {
                Debug.LogErrorFormat("获取节点 {0} 的输出端口 {1} 的值发生错误,类型不匹配", inputVariable.targetNodeId, inputVariable.targetPortId);
                return(default(T));
            }

            return(resultVariable.value);
        }