Example #1
0
        public void Init()
        {
            //初始化入口节点
            GraphInfo graphInfo         = GraphInfo.GetRootAsGraphInfo(byteBuffer);
            int       entranceNodeCount = graphInfo.EntranceNodeIdsLength;

            for (int i = 0; i < entranceNodeCount; i++)
            {
                int nodeId = graphInfo.EntranceNodeIds(i);
                EntranceNodeBase entranceNode = DeserializeNode(nodeId) as EntranceNodeBase;
                if (entranceNode == null)
                {
                    Debug.LogError(string.Format("节点 {0} 不是入口节点", nodeId));
                    continue;
                }

                if (onClickNode == null)
                {
                    onClickNode = entranceNode as OnClickNode;
                }

                if (onJoyStickDragNode == null)
                {
                    onJoyStickDragNode = entranceNode as OnJoyStickDragNode;
                }

                if (onJoyStickDownNode == null)
                {
                    onJoyStickDownNode = entranceNode as OnJoyStickDownNode;
                }

                if (onJoyStickUpNode == null)
                {
                    onJoyStickUpNode = entranceNode as OnJoyStickUpNode;
                }
            }
        }
Example #2
0
        private static void InitOutputFuncsDictionary()
        {
            if (nodeOutputInitFuncDictionary != null)
            {
                return;
            }

            nodeOutputInitFuncDictionary = new Dictionary <Type, Action <NodeBase> >
            {
                {
                    typeof(OnJoyStickDragNode), nodeInstance =>
                    {
                        OnJoyStickDragNode onJoyStickDragNode = nodeInstance as OnJoyStickDragNode;
                        onJoyStickDragNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            onJoyStickDragNode.GetJoyStickInput,
                        };
                    }
                },
                {
                    typeof(OnJoyStickUpNode), nodeInstance =>
                    {
                        OnJoyStickUpNode onJoyStickUpNode = nodeInstance as OnJoyStickUpNode;
                        onJoyStickUpNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            onJoyStickUpNode.GetJoyStickInput,
                        };
                    }
                },
                {
                    typeof(IntComparerNode), nodeInstance =>
                    {
                        IntComparerNode intComparerNode = nodeInstance as IntComparerNode;
                        intComparerNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            intComparerNode.GetCompareResult,
                        };
                    }
                },
                {
                    typeof(InverseDirectionNode), nodeInstance =>
                    {
                        InverseDirectionNode inverseDirectionNode = nodeInstance as InverseDirectionNode;
                        inverseDirectionNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            inverseDirectionNode.GetInverseDirection,
                        };
                    }
                },
                {
                    typeof(JoyStickInputConvertNode), nodeInstance =>
                    {
                        JoyStickInputConvertNode joyStickInputConvertNode = nodeInstance as JoyStickInputConvertNode;
                        joyStickInputConvertNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            joyStickInputConvertNode.GetConvertedVector3,
                        };
                    }
                },
                {
                    typeof(NormalizeVectorNode), nodeInstance =>
                    {
                        NormalizeVectorNode normalizeVectorNode = nodeInstance as NormalizeVectorNode;
                        normalizeVectorNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            normalizeVectorNode.GetNormalizedVector2,
                            normalizeVectorNode.GetNormalizedVector3,
                        };
                    }
                },
                {
                    typeof(QuadraticBezierPathNode), nodeInstance =>
                    {
                        QuadraticBezierPathNode quadraticBezierPathNode = nodeInstance as QuadraticBezierPathNode;
                        quadraticBezierPathNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            quadraticBezierPathNode.GetPathResultPoints,
                        };
                    }
                },
                {
                    typeof(RandomFloatNode), nodeInstance =>
                    {
                        RandomFloatNode randomFloatNode = nodeInstance as RandomFloatNode;
                        randomFloatNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            randomFloatNode.GetRandomFloat,
                        };
                    }
                },
                {
                    typeof(VectorAddNode), nodeInstance =>
                    {
                        VectorAddNode vectorAddNode = nodeInstance as VectorAddNode;
                        vectorAddNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            vectorAddNode.GetResult,
                        };
                    }
                },
                {
                    typeof(VectorScalarNode), nodeInstance =>
                    {
                        VectorScalarNode vectorScalarNode = nodeInstance as VectorScalarNode;
                        vectorScalarNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            vectorScalarNode.GetScalarVector2,
                            vectorScalarNode.GetScalarVector3,
                        };
                    }
                },
                {
                    typeof(SetVector3ComponentNode), nodeInstance =>
                    {
                        SetVector3ComponentNode setVector3ComponentNode = nodeInstance as SetVector3ComponentNode;
                        setVector3ComponentNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            setVector3ComponentNode.GetVector3Result,
                        };
                    }
                },
                {
                    typeof(GetVariableNode), nodeInstance =>
                    {
                        GetVariableNode getVariableNode = nodeInstance as GetVariableNode;
                        getVariableNode.outputPortFuncs = new Func <NodeVariable>[]
                        {
                            getVariableNode.GetValue,
                        };
                    }
                },
            };
        }