void Awake() { instance = this; }
/// <summary> /// 切换Area /// </summary> private void TryChangeArea(int areaIndex) { if (m_CurrentAreaController != null) { ulong lastAreaUid = GetCurrentAreaUid(); ulong newAreaUid = areaIndex != Constants.NOTSET_AREA_INDEX ? m_MapInfo.AreaInfos[areaIndex].Uid : Constants.NOTSET_AREA_UID; if (lastAreaUid != newAreaUid) { DebugUtility.Log(Constants.LOG_TAG, $"Begin change area from {lastAreaUid} to {newAreaUid}, {MapManager.GetInstance()._PlayerInfo}"); } } if (m_CurrentAreaController != null) { m_CurrentAreaController.RequestRelease(); m_ExpiredAreaControllers.Add(m_CurrentAreaController); m_CurrentAreaController = null; } if (areaIndex != Constants.NOTSET_AREA_INDEX) { AreaInfo targetAraeInfo = m_MapInfo.AreaInfos[areaIndex]; if (m_LimitChangeToAreaUid == Constants.NOT_LIMIT_AREA_UID || m_LimitChangeToAreaUid == targetAraeInfo.Uid) { m_State = State.ChangingArea; m_CurrentAreaController = new AreaController(); m_CurrentAreaController.RequestInitialize(this, m_MapInfo.AreaInfos[areaIndex]); DebugUtility.Log(Constants.LOG_TAG, "Begin invoke on changed area"); try { MapManager.GetInstance()._OnChangedArea?.Invoke(m_MapInfo.AreaInfos[areaIndex].Uid); DebugUtility.Log(Constants.LOG_TAG, "End invoke on changed area"); } catch (Exception e) { DebugUtility.LogError(Constants.LOG_TAG, string.Format("Invoke on changed area failed, Exception:\n{0}", e.ToString())); } } else { DebugUtility.LogVerbose(Constants.LOG_TAG, $"Cant change to area({targetAraeInfo.Uid}), because limit change to uid({m_LimitChangeToAreaUid})"); } } }
private void Awake() { instance = this; }