| | |
| | | /// </summary> |
| | | /// <param name="name">窗口名称</param> |
| | | /// <param name="functionId">功能ID,用于指定窗口的具体功能或显示模式</param> |
| | | public void Add(string name, int functionId = 0) |
| | | public void Add(string name, bool isNeedHomeWin = true, int functionId = 0) |
| | | { |
| | | var popupWindow = new PopupWindow() |
| | | { |
| | | window = name, |
| | | isNeedHomeWin = isNeedHomeWin, |
| | | functionId = functionId, |
| | | }; |
| | | |
| | |
| | | } |
| | | |
| | | popupWindowQueue.Add(popupWindow); |
| | | popupWindowQueue.Sort((x, y) => y.isNeedHomeWin.CompareTo(x.isNeedHomeWin)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="name">窗口名称</param> |
| | | /// <param name="functionId">功能ID</param> |
| | | public void Remove(string name, int functionId = 0) |
| | | public void Remove(string name, bool isNeedHomeWin = true, int functionId = 0) |
| | | { |
| | | var popupWindow = new PopupWindow() |
| | | { |
| | | window = name, |
| | | isNeedHomeWin = isNeedHomeWin, |
| | | functionId = functionId, |
| | | }; |
| | | |
| | |
| | | if (UIManager.Instance.IsOpened<LoadingWin>()) |
| | | return; |
| | | |
| | | if (!UIManager.Instance.IsOpened<HomeWin>()) |
| | | if (!UIManager.Instance.IsOpened<HomeWin>() && popupWindowQueue[0].isNeedHomeWin) |
| | | return; |
| | | |
| | | // 第一次打开HomeWin时记录时间 |
| | | // 进入游戏第一次推送做延迟处理 |
| | | if (!homeWinFirstOpened) |
| | | { |
| | | firstTime = Time.realtimeSinceStartup; |
| | |
| | | } |
| | | // 等待x秒 |
| | | if (Time.realtimeSinceStartup - firstTime < stayTime) |
| | | return; |
| | | |
| | | // 只在“没有战斗”和“主线战斗”时允许弹窗 |
| | | string activeBattleName = BattleManager.Instance.GetActiveBattleName(); |
| | | if (activeBattleName != "" && activeBattleName != "StoryBattleField") |
| | | return; |
| | | |
| | | if (UIManager.Instance.IsOpened(popupWindowQueue[0].window)) |
| | |
| | | if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(popupWindowQueue[0].window)) |
| | | return; |
| | | |
| | | |
| | | |
| | | if (currentWindow.window != null) |
| | | if (currentWindow != null && currentWindow.window != null) |
| | | { |
| | | //判断上一个推送是否关闭 |
| | | UIBase ui = UIManager.Instance.GetUI(currentWindow.window); |
| | | if (ui != null && ui.IsActive()) |
| | | return; |
| | | |
| | | } |
| | | |
| | | currentWindow = popupWindowQueue[0]; |
| | |
| | | /// 弹窗结构体,用于表示一个待处理的弹窗请求 |
| | | /// 包含窗口名称和功能ID,通过这两个字段可以唯一标识一个弹窗请求 |
| | | /// </summary> |
| | | public struct PopupWindow |
| | | public class PopupWindow |
| | | { |
| | | // 窗口名称 |
| | | public string window; |
| | |
| | | // 功能ID,用于指定窗口的具体功能或显示模式 |
| | | public int functionId; |
| | | |
| | | public static bool operator ==(PopupWindow lhs, PopupWindow rhs) |
| | | { |
| | | return lhs.window == rhs.window && lhs.functionId == rhs.functionId; |
| | | } |
| | | |
| | | public static bool operator !=(PopupWindow lhs, PopupWindow rhs) |
| | | { |
| | | return lhs.window != rhs.window || lhs.functionId != rhs.functionId; |
| | | } |
| | | |
| | | // 添加GetHashCode和Equals方法以确保结构体可以正确比较 |
| | | public override bool Equals(object obj) |
| | | { |
| | | if (obj is PopupWindow) |
| | | { |
| | | PopupWindow other = (PopupWindow)obj; |
| | | return this.window == other.window && this.functionId == other.functionId; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public override int GetHashCode() |
| | | { |
| | | return window.GetHashCode() ^ functionId.GetHashCode(); |
| | | } |
| | | public bool isNeedHomeWin; |
| | | } |
| | | |
| | | } |