Exemplo n.º 1
0
        /// <summary>
        /// 获取流程。
        /// </summary>
        /// <typeparam name="T">要获取的流程类型。</typeparam>
        /// <returns>要获取的流程。</returns>
        public ProcedureBase GetProcedure <T>() where T : ProcedureBase
        {
            if (m_ProcedureFsm == null)
            {
                throw new GameFrameworkException("You must initialize procedure first.");
            }

            return(m_ProcedureFsm.GetState <T>());
        }
        /// <summary>
        /// 获取状态
        /// </summary>
        /// <returns>获取的状态.</returns>
        /// <typeparam name="T">要获取的状态类型.</typeparam>
        public CharacterStateBase GetState <T>() where T : CharacterStateBase
        {
            if (m_StateFsm == null)
            {
                throw new GameFrameworkException("You must initialize states first.");
            }

            return(m_StateFsm.GetState <T> ());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取流程。
        /// </summary>
        /// <typeparam name="T">要获取的流程类型。</typeparam>
        /// <returns>要获取的流程。</returns>
        public T Get <T>() where T : StageBase
        {
            if (_stageFsm == null)
            {
                throw new GameException("You must initialize procedure first.");
            }

            return(_stageFsm.GetState <T>());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取流程。
        /// </summary>
        /// <typeparam name="T">要获取的流程类型。</typeparam>
        /// <returns>要获取的流程。</returns>
        public ProcedureBase GetProcedure <T>() where T : ProcedureBase
        {
            if (m_ProcedureFsm == null)
            {
                Logger.LogError("You must initialize procedure first.");
            }

            return(m_ProcedureFsm.GetState <T>());
        }
Exemplo n.º 5
0
 public override void ChangeAIState <T>(AIStateType stateType)
 {
     if (AIStateType != stateType)
     {
         AIStateType = stateType;
         ActorFsmStateBase state = m_Fsm.GetState <T>();
         state.ChangeState <T>();
     }
 }
Exemplo n.º 6
0
        public virtual void ChangeState <T>(ICommand command = null) where T : ActorFsmStateBase
        {
            if (m_ActorFsm == null)
            {
                Log.Error("Please set ActorFsm first");
                return;
            }

            if (!m_ActorFsm.HasState <T>())
            {
                Log.Error("Can no find state" + typeof(T));
                return;
            }

            ActorFsmStateBase state = m_ActorFsm.GetState <T>();

            if (CurFsmStateType == ActorFsmStateType.FSM_DEAD && state.StateType != ActorFsmStateType.FSM_REBORN)
            {
                return;
            }

            m_ActorFsm.GetState <T>().SetCommand(command);
            state.ChangeState <T>();
        }
Exemplo n.º 7
0
        private void SetupDefaultState(StateData defaultState, IFsm fsm)
        {
            if (_stateData.Count == 0)
            {
                return;
            }

            if (defaultState == null)
            {
                defaultState = _stateData[0];
            }

            fsm.DefaultState = fsm.GetState(defaultState.id);
            fsm.SetState(fsm.DefaultState.Id);
        }
Exemplo n.º 8
0
 /// <summary>
 /// 获取操作状态
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public OperateStateBase GetOperate <T>() where T : OperateStateBase
 {
     return(fsm.GetState <T>());
 }
Exemplo n.º 9
0
 /// <summary>
 /// 获取流程。
 /// </summary>
 /// <typeparam name="T">要获取的流程类型。</typeparam>
 /// <returns>要获取的流程。</returns>
 public ProcedureBase GetProcedure <T>() where T : ProcedureBase
 {
     return(fsm.GetState <T>());
 }