Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 public void SetCompOperator(TransitionComparisonOperator eOp)
 {
     m_eCompOperator = eOp;
 }
Ejemplo n.º 3
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);
            }
        }
    }