void OnChangeUserStory(TRANS_ID transId, STATE_ID stateId, STATE_ID preStateId) { UDL.Log("UserStory current State : " + stateId); curUSState.Value = stateId.ToString(); FSM_Layer.Inst.SetInt_NoCondChk(FSM_LAYER_ID.MainUI, TRANS_PARAM_ID.INT_USERSTORY_STATE, (int)stateId); FSM_Layer.Inst.SetInt_NoCondChk(FSM_LAYER_ID.MainUI, TRANS_PARAM_ID.INT_USERSTORY_PRE_STATE, (int)preStateId); FSM_Layer.Inst.SetTrigger(FSM_LAYER_ID.MainUI, TRANS_PARAM_ID.TRIGGER_CHECK_ANY_CONDITION); switch (stateId) { case STATE_ID.USMain_BtnSample: FSM_Layer.Inst.ChangeFSM(FSM_LAYER_ID.UserStory, FSM_ID.USBtn); break; case STATE_ID.USMain_ScrollSample: FSM_Layer.Inst.ChangeFSM(FSM_LAYER_ID.UserStory, FSM_ID.USScroll); break; case STATE_ID.USMain_TimeSample: FSM_Layer.Inst.ChangeFSM(FSM_LAYER_ID.UserStory, FSM_ID.USTime); break; case STATE_ID.USMain_ExitConfirm: ExitConfirm(); break; default: break; } UserDataManager.Inst.AddExp(); }
public void ChangeFSM(FSM_LAYER_ID eLayer, FSM_ID fsmID) { layerNum = (int)eLayer; if (!CurLayerCheck(eLayer)) { UDL.LogWarning("Fail Change Layer : " + eLayer, nLogOption, warningLoglv); return; } if (!dicFSM_EachLayer[layerNum].TryGetValue(fsmID, out tFSMBuffer)) { UDL.LogWarning(eLayer + " 에 " + fsmID + " 가 등록되어 있지 않습니다", nLogOption, warningLoglv); return; } if (CurLayerCheck(eLayer)) { layerFSM_Buffer[layerNum] = curFSM_EachLayer[layerNum].fsmID; curFSM_EachLayer[layerNum].Pause(); UnRegisterToFSM_ChangeLayerState(eLayer); curFSM_EachLayer[layerNum] = dicFSM_EachLayer[layerNum][fsmID]; RegisterToFSM_ChangeLayerState(eLayer); curFSM_EachLayer[layerNum].Resume(); } UDL.Log("(ChangeFSM) curFSM : " + curFSM_EachLayer[layerNum].fsmID.ToString(), nLogOption, logLv); }
bool CurStateTransitionChk() { UDL.Log(fsmID + " CurStateTransitionChk", logOption, FSM.logLv); if (curState.arrTransitionList == null || curState.arrTransitionList.Length == 0) { UDL.LogWarning(fsmID + " No Transition List in curState", logOption, FSM.warningLoglv); } if (curState.arrTransitionList != null) { for (int idx = 0; idx < curState.arrTransitionList.Length; idx++) { if (curState.arrTransitionList[idx].ConditionCheck(this)) { UDL.Log(fsmID + " ConditionCheck Pass : "******"/ " + curState.eID, logOption, FSM.logLv); TransitionStart(curState.arrTransitionList[idx].eTransID, curState.arrTransitionList[idx].nextStateID); return(true); } } } return(false); }
void ReactionProcess(ReactionID ss, int excuteId) { if (ss != ReactionID.None) { UDL.Log(gameObject.name + " ReactionProcess : " + ss + " // " + excuteId, nLogOption, isDebug, nLogLevel); } switch (ss) { case ReactionID.None: break; case ReactionID.Show: iReaction.Show(); break; case ReactionID.Hide: iReaction.Hide(); break; case ReactionID.Excute: iReaction.Excute(excuteId); break; case ReactionID.Change: iReaction.Change(); break; } }
public override void Show() { if (!gameObject.activeSelf) { gameObject.SetActive(true); } UDL.Log(gameObject.name + " Show after activeSelf : " + gameObject.activeSelf, nLogOption, bIsDebug, nLogLevel); }
private void OnDisable() { if (hideFirstFrame) { transform.localScale = Vector3.zero; } UDL.Log(gameObject.name + " Disable", nLogOption, isDebug, nLogLevel); }
private void OnEnable() { if (hideFirstFrame) { StartCoroutine(DelayOneFrame()); } UDL.Log(gameObject.name + " OnEnable", nLogOption, isDebug, nLogLevel); }
public void SetOwnerState(State OwnerState) { UDL.Log("SetOwnerState : " + OwnerState.eID + " / " + this.GetHashCode(), FSM.logOption, FSM.logLv); OwnerState.EventStart += OwnerStart; OwnerState.EventEnd += OwnerEnd; OwnerState.EventPause += OwnerPause; OwnerState.EventResume += OwnerResume; }
void OnChangePopupUI(TRANS_ID transId, STATE_ID stateId, STATE_ID preStateId) { UDL.Log("PopupUI current State : " + stateId); switch (stateId) { default: break; } }
public void OnBeforeDisable() { UDL.Log(gameObject.name + " OnBeforeDisable ", nLogOption, bIsDebug, nLogLevel); if (uAnim != null) { aniStateBuffer = uAnim.GetCurrentAnimatorStateInfo(0).shortNameHash; LogCurAnimInfo("OnBeforeDisable"); } }
public override void Hide() { BroadcastMessage("OnBeforeDisable", SendMessageOptions.DontRequireReceiver); if (gameObject.activeSelf) { gameObject.SetActive(false); } UDL.Log(gameObject.name + " Hide after activeSelf : " + gameObject.activeSelf, nLogOption, bIsDebug, nLogLevel); }
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); }
///child node내의 동일 클래스 RegistEvent를 보장하기 위해 하위노드를 검색해서 모두 호출해준다. private void Initialize_withChild() { UDL.Log(gameObject.name + " Initialize", nLogOption, isDebug, nLogLevel); Initialize(); //초기화 후 스스로 비활성화되기 때문에 직접 하위 노드 초기화 함수를 호출시켜준다. ReactionByState[] arrChild = GetComponentsInChildren <ReactionByState>(); for (int idx = 0; idx < arrChild.Length; idx++) { arrChild[idx].Initialize(); } }
///Awake가 호출되지 않으면 작동하지 않기 때문에 반드시 Scene상에서 해당 오브젝트가 Active 상태여야 한다. ///Start 시점에서는 FSM이 실행되기 때문에 반드시 Awake시점에서 Initailize 과정이 완료되어야 한다. private void Awake() { if (SceneChecker.IS_NOT_USING_FSM_SCENE) { return; } UDL.Log(gameObject.name + " Awake // self : " + gameObject.activeSelf + " hierarchy : " + gameObject.activeInHierarchy, nLogOption, isDebug, nLogLevel); //상위 노드에 의해 초기화 되지 않았다면 초기화를 시작한다. if (!bIsInitialze) { Initialize_withChild(); } }
public void HistoryBack() { STATE_ID preStateID = curState.eID; STATE_ID nextStateID = history.Pop(); UDL.Log(fsmID + " Transition Start// " + curState.eID + " -> " + nextStateID, logOption, FSM.logLv); curState.End(TRANS_ID.HISTORY_BACK, nextStateID); curState = dicStateList[nextStateID]; curState.Start(TRANS_ID.HISTORY_BACK, preStateID); if (EventStateChange != null) { EventStateChange(TRANS_ID.HISTORY_BACK, curState.eID, preStateID); } }
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); } }
void AnyStateTransitionChk() { UDL.Log(fsmID + " AnyStateTransitionChk", logOption, FSM.logLv); if (anyState.arrTransitionList == null || anyState.arrTransitionList.Length == 0) { UDL.LogWarning(fsmID + " No Transition List in AnyState", logOption, FSM.errorLoglv); } else { for (int idx = 0; idx < anyState.arrTransitionList.Length; idx++) { if (anyState.arrTransitionList[idx].ConditionCheck(this)) { TransitionStart(anyState.arrTransitionList[idx].eTransID, anyState.arrTransitionList[idx].nextStateID); break; } } } }
void OnEnable() { UDL.Log(gameObject.name + " OnEnable ", nLogOption, bIsDebug, nLogLevel); StartCoroutine(RecoverAnimatorState()); }
public TransCondWithTime(float condTime) { UDL.Log(" TransConWithTime " + this.GetHashCode(), FSM.logOption, FSM.logLv); m_fConditionTimeValue = condTime; }
public override void Change() { UDL.Log(gameObject.name + " Change : "); }
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); }
private void OnDisable() { UDL.Log(gameObject.name + " OnDisable ", nLogOption, bIsDebug, nLogLevel); }
private void OnEndAfter(TRANS_ID transID, STATE_ID stateID, STATE_ID preStateID) { ReactionProcess(dicIndex[preStateID].onEndAfter, dicIndex[preStateID].onEndAfterExcuteId); UDL.Log(gameObject.name + " OnEndAfter : " + preStateID, nLogOption, isDebug, nLogLevel); }
private void OnStartBefore(TRANS_ID transID, STATE_ID stateID, STATE_ID preStateID) { ReactionProcess(dicIndex[stateID].onStartBefore, dicIndex[stateID].onStartBeforeExcuteId); UDL.Log(gameObject.name + " OnStartBefore : " + stateID, nLogOption, isDebug, nLogLevel); }
/// <summary> /// Awake 시점에서 호출해야 한다. /// Start 에서 지정할 경우 gameobject가 다시 active 될 때까지 Start가 미뤄져서 최초 이벤트를 받지 못한다. /// </summary> /// <param name="target"></param> public void SetReaction(iStateReaction target) { UDL.Log(gameObject.name + " SetReaction. // " + gameObject.activeSelf, nLogOption, isDebug, nLogLevel); iReaction = target; }
private void OnPause(STATE_ID stateID) { ReactionProcess(dicIndex[stateID].onPause, dicIndex[stateID].onPauseExcuteId); UDL.Log(gameObject.name + " OnPause : " + stateID, nLogOption, isDebug, nLogLevel); }
private void OnStart(TRANS_ID transID, STATE_ID stateID, STATE_ID preStateID) { ReactionProcess(dicIndex[stateID].onStart, dicIndex[stateID].onStartExcuteId); UDL.Log(gameObject.name + " OnStart : " + stateID + " // after active : " + gameObject.activeSelf, nLogOption, isDebug, nLogLevel); }