Пример #1
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);
        }
Пример #2
0
        public override void Execute(FSMBehaviour fsm)
        {
            if (Application.isEditor && Application.isPlaying == false)
            {
                return;
            }

            Graph_State graph_state = (Graph_State)graph;
            FloatVar    floatVar    = null;

            if (graph_state.TryGetFloatVar(varName, out floatVar, localType))
            {
                floatVar.value = GetInputValue <float>("inputValue", this.inputValue);
            }
        }
Пример #3
0
        public bool TryGetFloatVar(string varName, out FloatVar floatVar, GraphVarLocalType localType)
        {
            bool result = false;

            switch (localType)
            {
            case GraphVarLocalType.Local:
                result = last_fsm_executed.TryGetFloatValue(varName, out floatVar);
                break;

            case GraphVarLocalType.Global:
                result = settings.TryGetFloatVar(varName, out floatVar);
                break;

            default:
                floatVar = null;
                break;
            }

            return(result);
        }
Пример #4
0
 public bool TryGetFloatVar(string variable, out FloatVar floatVar)
 {
     return(floatVars.TryGetValue(variable, out floatVar));
 }