public static void ClosePopup(Define.PopupType type, System.Action callback = null) { if (instance == null) { return; } if (instance.popupDic.ContainsKey(type)) { instance.JustClosePopup(type, () => { openPopupStack.Pop(); nowOpenPopup = openPopupStack.Peek(); if (nowOpenPopup != Define.PopupType.None) { instance.JustOpenPopup(nowOpenPopup, null); } else { instance.popupBlinder.SetActive(false); } if (callback != null) { callback(); } }); } }
public static T GetPopup <T>(Define.PopupType type) where T : IPopup { if (instance == null) { return(null); } if (instance.popupDic.ContainsKey(type)) { return(instance.popupDic[type] as T); } return(null); }
private void JustClosePopup(Define.PopupType popupType, System.Action callback) { if (popupDic.ContainsKey(popupType)) { popupDic[popupType].ClosePopup(() => { if (callback != null) { callback(); } }); } }
private void JustOpenPopup(Define.PopupType popupType, System.Action callback) { if (popupDic.ContainsKey(popupType)) { popupBlinder.SetActive(true); popupDic[popupType].OpenPopup(() => { if (callback != null) { callback(); } }); } }
public static void OpenPopup(Define.PopupType type, System.Action callback = null) { if (instance == null) { return; } if (instance.popupDic.ContainsKey(type)) { if (nowOpenPopup != Define.PopupType.None) { instance.JustClosePopup(nowOpenPopup, () => { instance.JustOpenPopup(type, () => { if (callback != null) { callback(); } openPopupStack.Push(type); nowOpenPopup = type; }); }); } else { instance.JustOpenPopup(type, () => { if (callback != null) { callback(); } openPopupStack.Push(type); nowOpenPopup = type; }); } } }
public override void InitSystem() { openPopupStack.Clear(); openPopupStack.Push(Define.PopupType.None); nowOpenPopup = Define.PopupType.None; popupBlinder.SetActive(false); instance = this; popupDic.Clear(); for (int i = 0, max = popupList.Count; i < max; i++) { Define.PopupType type = popupList[i].GetPopupType(); if (!popupDic.ContainsKey(type)) { popupDic.Add(type, popupList[i]); popupList[i].Init(); } else { Debug.Log("something is wrong"); } } }
public static bool IsOpened(Define.PopupType popup) { return(nowOpenPopup == popup); }