// ÉèÖóõʼ״̬,»ò¸ÄÍøÂçÍæ¼Ò״̬£» public bool SetState(string statename, Event_FSM_EF_Event edata = null) { //if (m_CurState != null && m_CurState.GetGameObject() is NetPlayer) //{ // // Debug.Log("SetState" + statename); //} if (m_StateDic.ContainsKey(statename)) { if (m_CurState != null) { m_CurState.OnEnd(); } m_CurState = m_StateDic[statename]; m_CurState.OnBegin(edata); return(true); } else { Debug.LogWarning("SetCurState statename don't find!" + statename); } return(false); }
void OnEvent(GameEventData edata) { Event_FSM_EF_Event fsmEvent = (Event_FSM_EF_Event)edata; //Debug.Log(fsmEvent.m_FsmEventID); //if (m_CurState != null && m_CurState.GetGameObject() is NetPlayer) //{ // // Debug.Log(" mfs OnEvent" + ml2event.m_iEventID); //} if (m_CurState == null || edata == null) { Debug.LogWarning("Warning,BnBFsm is null!"); } switch (fsmEvent.m_FsmEventID) { case eFsmEvent.FE_ChangeState: { int stateid = ((Event_FSM_EF_Event)edata).GetUserData <int>(0); string statename = GetStateName(stateid); Debug.Log("FMS_EVENT_ChangeState==" + statename + "/stateid=" + stateid); if (statename != null) { SetState(statename, fsmEvent); } } break; case eFsmEvent.FE_StateDealData: { if (m_CurState != null) { m_CurState.OnEvent(fsmEvent); } } break; default: { if (fsmEvent.m_FsmEventID <= eFsmEvent.FE_Begin || fsmEvent.m_FsmEventID >= eFsmEvent.FE_End) { break; } // if //(((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.MainPlayer) //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.MasterMonster) //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.Pet) //|| (CharacterBase)m_ML2GameObject is UIPlayer //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.AutoPlayer)) { ClashFsmStateBase tempState = null; tempState = GetNextState(fsmEvent); if (tempState == null) { //if (IsDebug == true || ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.AutoPlayer)) // Debug.LogWarning("OnEvent() DestState==null; SourceState = " + m_CurState.GetStateName() + ";Event =" + fsmEvent.m_FsmEventID); return; } //Debug.Log("change from " + m_CurState.GetStateName() + " to " + fsmEvent.m_FsmEventID.ToString()); m_CurState.OnEnd(); m_CurState = tempState; m_CurState.OnBegin(fsmEvent); } } break; } }