コード例 #1
0
 public void SetTrigger(FSM_LAYER_ID eLayer, TRANS_PARAM_ID paramID)
 {
     if (CurLayerCheck(eLayer))
     {
         curFSM_EachLayer[(int)eLayer].SetTrigger(paramID);
     }
 }
コード例 #2
0
 public void AddParamFloat(TRANS_PARAM_ID param_id, float value = 0.0f)
 {
     if (!dicFloatParam.ContainsKey(param_id))
     {
         dicFloatParam.Add(param_id, value);
     }
 }
コード例 #3
0
 public void SetFloat_NoCondChk(FSM_LAYER_ID eLayer, TRANS_PARAM_ID paramID, float value)
 {
     if (CurLayerCheck(eLayer))
     {
         curFSM_EachLayer[(int)eLayer].SetFloat_NoCondChk(paramID, value);
     }
 }
コード例 #4
0
 public void AddParamBool(TRANS_PARAM_ID param_id, bool value = false)
 {
     if (!dicBoolParam.ContainsKey(param_id))
     {
         dicBoolParam.Add(param_id, value);
     }
 }
コード例 #5
0
 public void AddParamInt(TRANS_PARAM_ID param_id, int value = 0)
 {
     if (!dicIntParam.ContainsKey(param_id))
     {
         dicIntParam.Add(param_id, value);
     }
 }
コード例 #6
0
 public void SetBool(FSM_LAYER_ID eLayer, TRANS_PARAM_ID paramID, bool value)
 {
     if (CurLayerCheck(eLayer))
     {
         curFSM_EachLayer[(int)eLayer].SetBool(paramID, value);
     }
 }
コード例 #7
0
        public void SetTrigger(TRANS_PARAM_ID param_id)
        {
            triggerID = param_id;

            RequestTransitionChk();

            triggerID = TRANS_PARAM_ID.TRIGGER_NONE;
        }
コード例 #8
0
 public bool GetBool(FSM_LAYER_ID eLayer, TRANS_PARAM_ID paramID)
 {
     if (!CurLayerCheck(eLayer))
     {
         return(false);
     }
     return(curFSM_EachLayer[(int)eLayer].GetParamBool(paramID));
 }
コード例 #9
0
 public float GetFloat(FSM_LAYER_ID eLayer, TRANS_PARAM_ID paramID)
 {
     if (!CurLayerCheck(eLayer))
     {
         return(0);
     }
     return(curFSM_EachLayer[(int)eLayer].GetParamFloat(paramID));
 }
コード例 #10
0
        public void SetParamID(TRANS_PARAM_ID _paramID)
        {
            m_uiParamID = _paramID;

            if (m_eTransType == TransitionType.TRIGGER)
            {
                M_TriggerID = _paramID;
            }
        }
コード例 #11
0
        bool TriggerTypeConditionChk(TRANS_PARAM_ID triggerID, FSM pFSM)
        {
            if (triggerID == pFSM.triggerID)
            {
                return(true);
            }

            return(false);
        }
コード例 #12
0
        public bool GetParamBool(TRANS_PARAM_ID param_id)
        {
            if (!dicBoolParam.TryGetValue(param_id, out bParamBuffer))
            {
                UDL.LogError(((FSM_ID)fsmID).ToString() + " not have given Transition parameter id. ", logOption, FSM.errorLoglv);
                return(false);
            }

            return(bParamBuffer);
        }
コード例 #13
0
        public float GetParamFloat(TRANS_PARAM_ID param_id)
        {
            if (!dicFloatParam.TryGetValue(param_id, out fParamBuffer))
            {
                UDL.LogError(((FSM_ID)fsmID).ToString() + " not have given Transition parameter id. ", logOption, FSM.errorLoglv);
                return(0);
            }

            return(fParamBuffer);
        }
コード例 #14
0
 public void SetBool_NoCondChk(TRANS_PARAM_ID param_id, bool value)
 {
     if (!dicBoolParam.TryGetValue(param_id, out bParamBuffer))
     {
         UDL.LogWarning(((FSM_ID)fsmID).ToString() + " not have given Transition parameter id. ", logOption, FSM.warningLoglv);
     }
     else
     {
         dicBoolParam[param_id] = value;
     }
 }
コード例 #15
0
        void TransitionStart(TRANS_ID transParamID, STATE_ID nextStateID)
        {
            triggerID = TRANS_PARAM_ID.TRIGGER_NONE;

            if (!IsActive)
            {
                UDL.Log(fsmID + " Refuse TransitionStart", logOption, FSM.logLv);
                return;
            }

            if (nextStateID == STATE_ID.HistoryBack)
            {
                HistoryBack();
                return;
            }

            if (!dicStateList.TryGetValue(nextStateID, out tStateBuffer))
            {
                UDL.LogError(nextStateID.ToString() + " 등록된 씬이 아님!", logOption, FSM.errorLoglv);
                return;
            }

            calldepth++;

            if (calldepth > 1)
            {
                UDL.LogWarning(fsmID + " FSM Call Depth is : " + calldepth
                               + " // 재귀호출구조가 되면서 EvnetStateChange callback이 현재 상태만을 매개변수로 역순으로 반복호출됩니다. ", logOption, FSM.warningLoglv);
            }

            UDL.Log(fsmID + " Transition Start// " + curState.eID + " -> "
                    + dicStateList[nextStateID].eID + " // " + transParamID, logOption, FSM.logLv);

            STATE_ID preStateID = curState.eID;

            curState.End(transParamID, nextStateID);

            if (!curState.NoHistory)
            {
                history.Push(curState.eID);
            }

            curState = dicStateList[nextStateID];

            curState.Start(transParamID, preStateID);

            if (EventStateChange != null)
            {
                EventStateChange(transParamID, curState.eID, preStateID);
            }

            calldepth--;
        }
コード例 #16
0
        public void SetFloat(TRANS_PARAM_ID param_id, float value)
        {
            if (!dicFloatParam.TryGetValue(param_id, out fParamBuffer))
            {
                UDL.LogWarning(((FSM_ID)fsmID).ToString() + " not have given Transition parameter id. ", logOption, FSM.warningLoglv);
                return;
            }

            dicFloatParam[param_id] = value;

            RequestTransitionChk();
        }
コード例 #17
0
        /// <summary>
        /// 해당 FSM이 가지고 있는 파라메터의 값들과 설정된 값을 비교해서 조건을 만족하는지 검사할 수 있다.
        /// </summary>
        /// <param name="_paramID">FSM이 가지고 있는 파라메터 ID를 입력한다. </param>
        public TransCondWithParam(TransitionType eT, TRANS_PARAM_ID _paramID = 0, object conditionValue = null, TransitionComparisonOperator eCompOp = TransitionComparisonOperator.EQUALS)
        {
            m_eTransType = eT;

            if (eT != TransitionType.TRIGGER && _paramID == 0)
            {
                UDL.LogError("파라메터 아이디를 설정해야 합니다!", FSM.logOption);
            }

            m_uiParamID = _paramID;

            if (eT != TransitionType.TRIGGER && conditionValue == null)
            {
                UDL.LogError("조건 변수를 설정해야 합니다. ", FSM.logOption);
            }

            switch (eT)
            {
            case TransitionType.BOOL:
                M_bConditionValue = (bool)conditionValue;
                break;

            case TransitionType.FLOAT:
                M_fConditionValue = (float)conditionValue;
                break;

            case TransitionType.INT:
                M_iConditionValue = (int)conditionValue;
                break;

            case TransitionType.TRIGGER:
                M_TriggerID = _paramID;
                break;
            }

            m_eCompOperator = eCompOp;
        }
コード例 #18
0
    private void TransCondParamEdit(State state, int countInList, int TransCondParam_Max)
    {
        if (TransCondParam_Max != state.arrTransitionList[countInList].arrTransParam.Count)
        {
            buffer_arrTransParam = new TransCondWithParam[state.arrTransitionList[countInList].arrTransParam.Count];
            int k = 0;
            foreach (TransCondWithParam t in state.arrTransitionList[countInList].arrTransParam)
            {
                buffer_arrTransParam[k] = t;
                k++;
            }

            state.arrTransitionList[countInList].arrTransParam.Clear();

            for (int j = 0; j < TransCondParam_Max; j++)
            {
                if (buffer_arrTransParam.Length > j)
                {
                    if (buffer_arrTransParam[j] != null)
                    {
                        state.arrTransitionList[countInList].arrTransParam.Add(buffer_arrTransParam[j]);
                    }
                    else
                    {
                        state.arrTransitionList[countInList].arrTransParam.Add(
                            new TransCondWithParam(TransitionType.TRIGGER, 0, TRANS_PARAM_ID.TRIGGER_NONE));
                    }
                }
                else
                {
                    state.arrTransitionList[countInList].arrTransParam.Add(
                        new TransCondWithParam(TransitionType.TRIGGER, 0, TRANS_PARAM_ID.TRIGGER_NONE));
                }
            }
        }

        if (state.arrTransitionList[countInList].arrTransParam.Count > 0)
        {
            foreach (TransCondWithParam cond in state.arrTransitionList[countInList].arrTransParam)
            {
                GUILayout.BeginHorizontal();
                TransitionType e = (TransitionType)EditorGUILayout.EnumPopup(cond.m_eTransType);
                if (e != cond.m_eTransType)
                {
                    cond.SetTransitionType(e);
                }

                TRANS_PARAM_ID eParam = (TRANS_PARAM_ID)EditorGUILayout.EnumPopup((TRANS_PARAM_ID)cond.m_uiParamID);
                if (eParam != (TRANS_PARAM_ID)cond.m_uiParamID)
                {
                    cond.SetParamID(eParam);
                }

                switch (e)
                {
                case TransitionType.BOOL:
                    bool tb = EditorGUILayout.Toggle(cond.M_bConditionValue);
                    if (tb != cond.M_bConditionValue)
                    {
                        cond.SetConditionValue(tb);
                    }
                    break;

                case TransitionType.FLOAT:
                    float tf = EditorGUILayout.FloatField(cond.M_fConditionValue);
                    if (tf != cond.M_fConditionValue)
                    {
                        cond.SetConditionValue(tf);
                    }
                    break;

                case TransitionType.INT:
                    int ti = EditorGUILayout.IntField(cond.M_iConditionValue);
                    if (ti != cond.M_iConditionValue)
                    {
                        cond.SetConditionValue(ti);
                    }
                    break;
                }

                TransitionComparisonOperator eOp = TransitionComparisonOperator.EQUALS;
                if (e != TransitionType.TRIGGER)
                {
                    eOp = (TransitionComparisonOperator)EditorGUILayout.EnumPopup(cond.m_eCompOperator);
                }

                if (eOp != cond.m_eCompOperator)
                {
                    cond.SetCompOperator(eOp);
                }

                GUILayout.EndHorizontal();
                GUILayout.Space(5);
            }
        }
    }
コード例 #19
0
    private void Edit_Int_Param <T>(ref Dictionary <TRANS_PARAM_ID, T> dic, ref bool isShow, ref TRANS_PARAM_ID param_id)
    {
        System.TypeCode typecode = System.Type.GetTypeCode(typeof(T));

        EditorGUILayout.BeginHorizontal("box");

        if (GUILayout.Button(isShow ? "-":"+", GUILayout.Width(50)))
        {
            isShow = !isShow;
        }

        if (dic != null)
        {
            GUILayout.Label(typecode.ToString() + " Param (" + dic.Count + ")");
        }

        EditorGUILayout.EndHorizontal();

        if (!isShow)
        {
            return;
        }

        EditorGUILayout.BeginHorizontal();

        param_id = (TRANS_PARAM_ID)EditorGUILayout.EnumPopup(param_id, GUILayout.Width(250));
        if (GUILayout.Button("추가", GUILayout.Width(50)))
        {
            switch (typecode)
            {
            case System.TypeCode.Int32:
                curFSM.AddParamInt(param_id);
                break;

            case System.TypeCode.Single:
                curFSM.AddParamFloat(param_id);
                break;

            case System.TypeCode.Boolean:
                curFSM.AddParamBool(param_id);
                break;
            }
        }

        EditorGUILayout.EndHorizontal();

        //int 파라메터 키/초기화값
        if (dic != null)
        {
            TRANS_PARAM_ID[] keys = new TRANS_PARAM_ID[dic.Count];
            dic.Keys.CopyTo(keys, 0);

            foreach (TRANS_PARAM_ID key in keys)
            {
                EditorGUILayout.BeginHorizontal();

                GUILayout.Label(key.ToString(), GUILayout.Width(250));
                switch (typecode)
                {
                case System.TypeCode.Int32:
                    dic[key] = (T)(object)EditorGUILayout.IntField((int)(object)dic[key], GUILayout.Width(100));
                    break;

                case System.TypeCode.Single:
                    dic[key] = (T)(object)EditorGUILayout.FloatField((float)(object)dic[key], GUILayout.Width(100));
                    break;

                case System.TypeCode.Boolean:
                    dic[key] = (T)(object)EditorGUILayout.Toggle((bool)(object)dic[key], GUILayout.Width(100));
                    break;
                }

                if (GUILayout.Button("삭제", GUILayout.Width(50)))
                {
                    dic.Remove(key);
                }

                EditorGUILayout.EndHorizontal();
            }
        }
    }