コード例 #1
0
 public void SwitchToState(int id, IMessage param)
 {
     if (m_CurState != null && m_CurState.Id != id)
     {
         m_CurState.OnExit();
     }
     m_CurState = GetState(id);
     m_CurState.OnEnter(param);
 }
コード例 #2
0
        public virtual void OnUpdate()
        {
            if (m_CurState == null)
            {
                m_CurState = m_DefaultState;
                m_CurState.OnEnter();
            }

            if (m_CurState != null)
            {
                int targetId = m_CurState.OnUpdate();
                if (targetId != m_CurState.Id)
                {
                    SwitchToState(targetId, null);
                }
            }
        }