Exemplo n.º 1
0
        /// <summary>
        /// FSM事件
        /// </summary>
        /// <param name="fsmEvent"></param>
        public virtual void OnFSMEvent(CFSMEvent fsmEvent)
        {
#if BTDEBUG
            if (m_bOpenDebug == true && fsmEvent != null)
            {
                BTDebug.Log(string.Format("<BTFSM> FSM Receive Event:{0}", fsmEvent.GetEventId()));
            }
#endif
            if (m_ListenedEventList == null)
            {
                return;
            }
            m_ListenedEventList.Add(fsmEvent);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 执行FSM动作
        /// </summary>
        /// <param name="strActionName"></param>
        /// <param name="objParamArray"></param>
        /// <param name="rOutResultValue"></param>
        /// <returns></returns>
        public bool InvokeFSMAction(string strActionName, System.Object[] objParamArray, out System.Object rOutResultValue)
        {
            rOutResultValue = default(System.Object);
            if (m_Reflector == null)
            {
                return(false);
            }
            bool bRet = m_Reflector.InvokeMethod(strActionName, m_BindEntity, objParamArray, out rOutResultValue);

#if BTDEBUG
            BTDebug.Log(string.Format("<BTFSM> FSM Invoke Action:{0} {1}", strActionName, bRet ? "Success" : "Failed"));
#endif
            return(bRet);
        }
Exemplo n.º 3
0
        public bool Start()
        {
            BTDebug.Log("Game Client Start", "CLIENT");
            if (m_GameFSM == null)
            {
                return(false);
            }
#if UNITY_EDITOR
            m_GameFSM.SetOpenFSMDebug(true);
#endif
            UInt32 uStateIDUpdate = (UInt32)TGameStateType.enInstall;
            bool   bFSMStartRet   = m_GameFSM.Start(uStateIDUpdate);
            return(bFSMStartRet);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 切换到一个状态
        /// </summary>
        /// <param name="uNextState"></param>
        /// <param name="fsmEvent"></param>
        /// <returns></returns>
        public bool ChangeToState(UInt32 uNextState, CFSMEvent fsmEvent)
        {
            CFSMState nextFSMState = GetState(uNextState);

            if (nextFSMState == null)
            {
                BTDebug.Warning(string.Format("Found NO State With ID:{0}, Change State Failed", uNextState), "FSM");
                return(false);
            }

            if (m_CurrentState != null)
            {
                if (m_CurrentState.GetStateID() == uNextState)
                {
                    return(true);
                }

                if (m_CurrentState.OnExit(this, fsmEvent) == false)
                {
                    BTDebug.Warning(string.Format("State:{0} Exit Failed", m_CurrentState.GetStateName()), "FSM");
                }
            }

#if BTDEBUG
            if (m_bOpenDebug)
            {
                string strLog = string.Format("FSM Trans From:{0} To:{1}",
                                              m_CurrentState == null ? "NULL" : m_CurrentState.GetStateName(),
                                              nextFSMState.GetStateName());

                BTDebug.Log(strLog, "BTFSM");
            }
#endif

            m_CurrentState = nextFSMState;

            if (nextFSMState.OnEnter(this, fsmEvent) == false)
            {
                BTDebug.Warning(string.Format("State:{0} Enter Failed", nextFSMState.GetStateName()), "FSM");
            }

            return(true);
        }
Exemplo n.º 5
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(20, 20, 100, 40), "Test"))
        {
            //InstanceCacheManager.Instance.GetInstance("bl_00", (name, obj) =>
            //    {
            //        BTDebug.Warning("Load:" + name + " Type:" + obj.GetType());
            //    });
            string strDump = NS_GAME.DATA.Data_ConfigTree.DumpData();
            BTDebug.Log(strDump);
            strDump = NS_GAME.DATA.Data_EditorTextList.DumpData();
            BTDebug.Log(strDump);
            strDump = NS_GAME.DATA.Data_EditorObjectList.DumpData();
            BTDebug.Log(strDump);

            InstanceCacheManager.Instance.GetInstance("bl_00", (name, instance) =>
            {
            });
        }
    }
Exemplo n.º 6
0
        /// <summary>
        /// 切换到一个状态
        /// </summary>
        /// <param name="uNextState"></param>
        /// <param name="fsmEvent"></param>
        /// <returns></returns>
        public bool ChangeToState(UInt32 uNextState, CFSMEvent fsmEvent)
        {
            CFSMState nextFSMState = GetState(uNextState);

            if (nextFSMState == null)
            {
                return(false);
            }

            if (m_CurrentState != null)
            {
                if (m_CurrentState.GetStateID() == uNextState)
                {
                    return(true);
                }

                if (m_CurrentState.OnExit(this, fsmEvent) == false)
                {
                    BTDebug.Warning(string.Format("<BTFSM> State:{0} Exit Failed", m_CurrentState.GetStateName()));
                }
            }

#if BTDEBUG
            if (m_bOpenDebug)
            {
                BTDebug.Log(string.Format("<BTFSM> FSM Trans From:{0} To:{1}",
                                          m_CurrentState == null ? "NULL" : m_CurrentState.GetStateName(),
                                          nextFSMState.GetStateName()));
            }
#endif

            if (nextFSMState.OnEnter(this, fsmEvent) == false)
            {
                BTDebug.Warning(string.Format("<BTFSM> State:{0} Enter Failed", nextFSMState.GetStateName()));
            }

            m_CurrentState = nextFSMState;

            return(true);
        }