Esempio n. 1
0
        public override NodeGraph Copy()
        {
            Graph_State cp = (Graph_State)base.Copy();

            int indexOfRoot    = nodes.IndexOf(RootState);
            int indexOfCurrent = nodes.IndexOf(CurrentState);

            //Confirmando os nos current e root, pois por algum motivos eles perdem a referencia quando sao instanciados
            cp._currentState = (NodeBase_State)cp.nodes[indexOfRoot];
            cp._rootState    = (NodeBase_State)cp.nodes[indexOfCurrent];


            //Troca a referencia dos estados que são referencia nos nós de JUMP STATE.
            List <Node> jumps = cp.nodes.FindAll(r => r is Node_StateJump);

            foreach (Node j in jumps)
            {
                Node_StateJump nj = (Node_StateJump)j;
                nj.goToState = (NodeBase_State)cp.nodes[nodes.IndexOf(nj.goToState)];
            }

            //Renomeia os nos instanciados pois por algum motivo eles perdem o nome quando sao instanciado
            for (int i = 0; i < cp.nodes.Count; i++)
            {
                cp.nodes[i].name = nodes[i].name;
            }

            return(cp);
        }
Esempio n. 2
0
        public virtual T GetVariableValue()
        {
            T           result     = default(T);
            Graph_State graphState = (Graph_State)graph;

            if (string.IsNullOrEmpty(variableName) || variableName == FSMGUtility.StringTag_Undefined)
            {
                return(result);
            }

            if (Application.isEditor && Application.isPlaying == false && localType == GraphVarLocalType.Local)
            {
                return(result);
            }

            switch (GetGraphVarType())
            {
            case GraphVarType.Boolean:
                BoolVar boolVar = null;
                if (graphState.TryGetBoolVar(variableName, out boolVar, localType))
                {
                    result = (T)Convert.ChangeType(boolVar.value, typeof(T));
                }
                break;

            case GraphVarType.Double:
                DoubleVar doubleVar = null;
                if (graphState.TryGetDoubeVar(variableName, out doubleVar, localType))
                {
                    result = (T)Convert.ChangeType(doubleVar.value, typeof(T));
                }
                break;

            case GraphVarType.Float:
                FloatVar floatVar = null;
                if (graphState.TryGetFloatVar(variableName, out floatVar, localType))
                {
                    result = (T)Convert.ChangeType(floatVar.value, typeof(T));
                }
                break;

            case GraphVarType.Integer:
                IntVar intVar = null;
                if (graphState.TryGetIntVar(variableName, out intVar, localType))
                {
                    result = (T)Convert.ChangeType(intVar.value, typeof(T));
                }
                break;
            }

            return(result);
        }
Esempio n. 3
0
        public override void Execute(FSMBehaviour fsm)
        {
            if (Application.isEditor && Application.isPlaying == false)
            {
                return;
            }

            Graph_State graph_state = (Graph_State)graph;
            IntVar      intvar      = null;

            if (graph_state.TryGetIntVar(varName, out intvar, localType))
            {
                intvar.value = GetInputValue <int>("inputValue", this.inputValue);
            }
        }
Esempio n. 4
0
 protected virtual void OnGraphChangeInEditor(Graph_State old, Graph_State newg)
 {
 }
Esempio n. 5
0
        public List <string> GeVariableNames()
        {
            Graph_State graph_state = (Graph_State)graph;

            return(graph_state.GetVariablesName(GraphVarType.Integer, localType));
        }
Esempio n. 6
0
        public override List <string> GetVariableNames()
        {
            Graph_State graphState = (Graph_State)graph;

            return(graphState.GetVariablesName(GetGraphVarType(), LocalType));
        }