Beispiel #1
0
    private void OnDestroy()
    {
        if (SceneChecker.IS_NOT_USING_FSM_SCENE)
        {
            return;
        }

        State pState;

        for (int idx = 0; idx < arrSwitch.Length; idx++)
        {
            pState = FSM_Layer.Inst.GetState(arrSwitch[idx].layer, arrSwitch[idx].fsm, arrSwitch[idx].state);

#if UNITY_EDITOR
            if (pState == null)
            {
                UDL.LogError(gameObject.name + " // " + arrSwitch[idx].state, nLogOption);
            }
#endif

            pState.EventStart_Before -= OnStartBefore;
            pState.EventStart        -= OnStart;
            pState.EventStart_After1 -= OnStartAfter1;
            pState.EventStart_After2 -= OnStartAfter2;
            pState.EventEnd_Before   -= OnEndBefore;
            pState.EventEnd          -= OnEnd;
            pState.EventEnd_After    -= OnEndAfter;
            pState.EventPause        -= OnPause;
            pState.EventResume       -= OnResume;
        }
    }
        bool BoolTypeConditionChk(bool value, FSM pFSM)
        {
            if (!pFSM.dicBoolParam.TryGetValue(m_uiParamID, out bParamBuffer))
            {
                UDL.LogError(m_uiParamID.ToString() + ". 등록되지 않은 Trans_Param_ID 입니다. ", FSM.logOption, FSM.errorLoglv);
            }

            switch (m_eCompOperator)
            {
            case TransitionComparisonOperator.LESS:
            case TransitionComparisonOperator.GREATER:
            case TransitionComparisonOperator.OVER:
            case TransitionComparisonOperator.UNDER:
                UDL.LogWarning("bool 변수에 잘못된 조건연산자를 지정했음", FSM.logOption, FSM.warningLoglv);
                return(false);

            case TransitionComparisonOperator.EQUALS:
                if (bParamBuffer == value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.NOTEQUAL:
                if (bParamBuffer != value)
                {
                    return(true);
                }
                break;
            }

            return(false);
        }
        bool FloatTypeCondtionChk(float value, FSM pFSM)
        {
            if (!pFSM.dicFloatParam.TryGetValue(m_uiParamID, out fParamBuffer))
            {
                UDL.LogError(m_uiParamID.ToString() + ". 등록되지 않은 Trans_Param_ID 입니다. ", FSM.logOption, FSM.errorLoglv);
            }

            switch (m_eCompOperator)
            {
            case TransitionComparisonOperator.EQUALS:

                UDL.LogWarning("float 변수는 Equal 조건을 만족시키지 못 할 위험이 있습니다. ", FSM.logOption, FSM.warningLoglv);

                if (fParamBuffer == value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.NOTEQUAL:
                UDL.LogWarning("float 변수는 NotEqual 조건을 사용하면 정확하지 않을 위험이 있습니다. ", FSM.logOption, FSM.warningLoglv);

                if (fParamBuffer != value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.GREATER:
                if (fParamBuffer >= value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.LESS:
                if (fParamBuffer <= value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.OVER:
                if (fParamBuffer > value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.UNDER:
                if (fParamBuffer < value)
                {
                    return(true);
                }
                break;
            }

            return(false);
        }
Beispiel #4
0
    /// <param name="args">0:titleText, 1:contentText, 2:btnType, 3:callback</param>
    void OnPopup(params object[] args)
    {
        if (args == null || args.Length < 2)
        {
            UDL.LogError("No Title Msg. No content Msg");
            return;
        }

        if (args[0].GetType() != typeof(string))
        {
            UDL.LogError("0 argument must string");
            return;
        }
        if (args[1].GetType() != typeof(string))
        {
            UDL.LogError("1 argument must string");
            return;
        }

        title.text = (string)args[0];
        msg.text   = (string)args[1];

        int btnType = 0;

        if (args.Length >= 3)
        {
            if (args[2].GetType() != typeof(int))
            {
                UDL.LogError("2 argument must int");
                return;
            }

            btnType = (int)args[2];

            if (btnType < 0 || btnType > 1)
            {
                UDL.LogError("2 argument range 0 < btnType < 2");
                return;
            }

            SetBtnType(btnType);

            if (args.Length > 3)
            {
                if (args[3].GetType() != typeof(Action <bool>))
                {
                    UDL.LogError("3 argument must Action<bool>");
                    return;
                }

                callback = (Action <bool>)args[3];
            }
        }

        gameObject.SetActive(true);
    }
        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);
        }
        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);
        }
        bool IntTypeCondtionChk(int value, FSM pFSM)
        {
            if (!pFSM.dicIntParam.TryGetValue(m_uiParamID, out nParamBuffer))
            {
                UDL.LogError(m_uiParamID.ToString() + ". 등록되지 않은 Trans_Param_ID 입니다. ", FSM.logOption, FSM.errorLoglv);
            }

            switch (m_eCompOperator)
            {
            case TransitionComparisonOperator.EQUALS:
                if (nParamBuffer == value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.NOTEQUAL:
                if (nParamBuffer != value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.GREATER:
                if (nParamBuffer >= value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.LESS:
                if (nParamBuffer <= value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.OVER:
                if (nParamBuffer > value)
                {
                    return(true);
                }
                break;

            case TransitionComparisonOperator.UNDER:
                if (nParamBuffer < value)
                {
                    return(true);
                }
                break;
            }

            return(false);
        }
        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--;
        }
        public State GetState(STATE_ID stateID)
        {
            UDL.Log("GetState : " + stateID.ToString() + " / dicStateList.Count : " + dicStateList.Count.ToString(), logOption, FSM.logLv);

            if (dicStateList.TryGetValue(stateID, out tStateBuffer))
            {
                return(tStateBuffer);
            }

            UDL.LogError("등록되지 않은 상태를 호출했음 " + stateID, logOption, FSM.errorLoglv);
            return(null);
        }
Beispiel #10
0
    void OnMsgShow(params object[] args)
    {
        //파라메터 체크

        if (args == null || args.Length == 0)
        {
            UDL.LogError("No Msg");
            return;
        }

        string msg = (string)args[0];

        StartCoroutine(ScaleShow(msg));
    }
        public void AddState(State newState)
        {
            if (newState.eID == STATE_ID.AnyState)
            {
                UDL.LogWarning("AnyState(Code_AnyState) 는 이미 생성되어 있습니다. ", logOption, FSM.warningLoglv);
            }

            if (dicStateList.ContainsKey(newState.eID))
            {
                UDL.LogError("ID가 겹침 " + newState.eID.ToString());
                return;
            }

            dicStateList.Add(newState.eID, newState);
        }
Beispiel #12
0
        public void AddFSM(FSM_LAYER_ID eLayer, FSM newFSM, FSM_ID id = FSM_ID.NONE)
        {
            layerNum = (int)eLayer;
            if (dicFSM_EachLayer.Length <= layerNum)
            {
                UDL.LogError("할당되지 않은 레이어를 호출하고 있습니다 Layer 및 iMaxLayer를 확인해주세요", nLogOption, errorLoglv);
                return;
            }

            if (dicFSM_EachLayer[layerNum] == null)
            {
                dicFSM_EachLayer[layerNum] = new Dictionary <FSM_ID, FSM>();
            }

            if (id != FSM_ID.NONE)
            {
                if (dicFSM_EachLayer[layerNum].ContainsKey(id))
                {
                    UDL.LogWarning("동일 레이어에 중복된 FSM ID 를 등록하려함!", nLogOption, warningLoglv);
                }
                else
                {
                    newFSM.SetFSMID(id);
                }
            }

            dicFSM_EachLayer[layerNum].Add(newFSM.fsmID, newFSM);

            UDL.Log(eLayer + " // add : " + newFSM.fsmID, nLogOption, logLv);

            if (curFSM_EachLayer[layerNum] == null)
            {
                curFSM_EachLayer[layerNum] = newFSM;

                RegisterToFSM_ChangeLayerState(eLayer);

                curFSM_EachLayer[layerNum].Resume();
            }
            else
            {
                ChangeFSM(eLayer, newFSM.fsmID);
            }
        }
Beispiel #13
0
        public State GetState(FSM_LAYER_ID eLayer, FSM_ID fsmID, STATE_ID stateID)
        {
            layerNum = (int)eLayer;
            if (dicFSM_EachLayer == null)
            {
                return(null);
            }

            if (dicFSM_EachLayer[layerNum] == null)
            {
                UDL.LogError("지정한 레이어에 FSM이 지정되 있지 않음 ", nLogOption, errorLoglv);
                return(null);
            }

            if (!dicFSM_EachLayer[layerNum].TryGetValue(fsmID, out tFSMBuffer))
            {
                UDL.LogError(fsmID.ToString() + " FSM 이 등록되어 있지 않음", nLogOption, errorLoglv);
                return(null);
            }

            return(tFSMBuffer.GetState(stateID));
        }
Beispiel #14
0
        public void RegisterEventChangeLayerState(FSM_LAYER_ID eLayer, deleStateTransEvent _deleFunc)
        {
            layerNum = (int)eLayer;
            if (layerNum >= iMaxLayer)
            {
                UDL.LogError("할당 되지 않은 레이어를 호출했습니다", nLogOption, errorLoglv);
                return;
            }

            if (!dicLayerChangeState.ContainsKey(eLayer))
            {
                dicLayerChangeState.Add(eLayer, new List <deleStateTransEvent>());
            }

            dicLayerChangeState[eLayer].Add(_deleFunc);

            int result = RegisterToFSM_ChangeLayerState(eLayer);

            if (result == 1)
            {
                UDL.LogWarning(eLayer + " " + errMsgAbout_Register_ChangeLayerState[result] + " // 이 후 해당 레이어에 ChangeFSM이 호출 될 때 반영될 수 있습니다. ", nLogOption, warningLoglv);
            }
        }
        /// <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;
        }
Beispiel #16
0
    private void Initialize()
    {
        if (bIsInitialze)
        {
            return;
        }

        bIsInitialze = true;

        if (hideFirstFrame)
        {
            transform.localScale = Vector3.zero;
        }

        UDL.Log(gameObject.name + " RegistEvent", nLogOption, isDebug, nLogLevel);

        if (iReaction == null)
        {
            iReaction = this;
        }

        State pState;

        for (int idx = 0; idx < arrSwitch.Length; idx++)
        {
            pState = FSM_Layer.Inst.GetState(arrSwitch[idx].layer, arrSwitch[idx].fsm, arrSwitch[idx].state);

            if (pState == null)
            {
                UDL.LogError(gameObject.name + " // " + arrSwitch[idx].state, nLogOption);
                return;
            }

            pState.EventStart_Before += OnStartBefore;
            pState.EventStart        += OnStart;
            pState.EventStart_After1 += OnStartAfter1;
            pState.EventStart_After2 += OnStartAfter2;
            pState.EventEnd_Before   += OnEndBefore;
            pState.EventEnd          += OnEnd;
            pState.EventEnd_After    += OnEndAfter;
            pState.EventPause        += OnPause;
            pState.EventResume       += OnResume;

#if UNITY_EDITOR
            try
            {
                dicIndex.Add(arrSwitch[idx].state, arrSwitch[idx]);
            }
            catch
            {
                UDL.LogError(gameObject.name + " overlap state " + arrSwitch[idx].state, nLogOption);
            }
#else
            dicIndex.Add(arrSwitch[idx].state, arrSwitch[idx]);
#endif
        }

        Reaction_Expand p = GetComponent <Reaction_Expand>();
        if (p)
        {
            p.Initialize();
        }

        gameObject.SetActive(false);
    }