| | |
| | | /// </summary> |
| | | /// <param name="name">窗口名称</param> |
| | | /// <param name="functionId">功能ID,用于指定窗口的具体功能或显示模式</param> |
| | | public void Add(string name, bool isNeedHomeWin = true, int functionId = 0) |
| | | public void Add(string name, bool isNeedHomeWin = true, string battleFieldName = "", int functionId = 0) |
| | | { |
| | | var popupWindow = new PopupWindow() |
| | | { |
| | | window = name, |
| | | isNeedHomeWin = isNeedHomeWin, |
| | | battleFieldName = battleFieldName, |
| | | functionId = functionId, |
| | | }; |
| | | |
| | |
| | | } |
| | | |
| | | popupWindowQueue.Add(popupWindow); |
| | | popupWindowQueue.Sort((x, y) => y.isNeedHomeWin.CompareTo(x.isNeedHomeWin)); |
| | | popupWindowQueue.Sort((x, y) => |
| | | { |
| | | // 1. 首先按 isNeedHomeWin 排序 (true 排在前面) |
| | | int homeWinCompare = y.isNeedHomeWin.CompareTo(x.isNeedHomeWin); |
| | | if (homeWinCompare != 0) |
| | | return homeWinCompare; |
| | | |
| | | // 2. 获取各自的 WinOrder (通过 WinName 查找配置表) |
| | | int xOrder = GetWinOrder(x.window); |
| | | int yOrder = GetWinOrder(y.window); |
| | | int orderCompare = xOrder.CompareTo(yOrder); |
| | | if (orderCompare != 0) |
| | | return orderCompare; |
| | | |
| | | // 3. WinOrder 相同时,按 ID 排序 (ID 小的排前面) |
| | | return x.functionId.CompareTo(y.functionId); |
| | | }); |
| | | } |
| | | |
| | | private int GetWinOrder(string winName) |
| | | { |
| | | var allConfigs = PopWinOrderConfig.GetValues(); |
| | | foreach (var config in allConfigs) |
| | | { |
| | | if (config.WinName == winName) |
| | | { |
| | | return config.WinOrder; |
| | | } |
| | | } |
| | | return int.MinValue; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (UIManager.Instance.IsOpened<LoadingWin>()) |
| | | return; |
| | | |
| | | if (!UIManager.Instance.IsOpened<HomeWin>() && popupWindowQueue[0].isNeedHomeWin) |
| | | return; |
| | | |
| | | // 进入游戏第一次推送做延迟处理 |
| | | if (!homeWinFirstOpened) |
| | | { |
| | |
| | | // 等待x秒 |
| | | if (Time.realtimeSinceStartup - firstTime < stayTime) |
| | | return; |
| | | |
| | | // 只在“没有战斗”和“主线战斗”时允许弹窗 |
| | | |
| | | // 只在“没有战斗”和“主线战斗”和“自己的战场”时允许弹窗 |
| | | string activeBattleName = BattleManager.Instance.GetActiveBattleName(); |
| | | if (activeBattleName != "" && activeBattleName != "StoryBattleField") |
| | | // 查找队列中第一个可以弹出的弹窗 |
| | | PopupWindow targetPopup = null; |
| | | int targetIndex = -1; |
| | | for (int i = 0; i < popupWindowQueue.Count; i++) |
| | | { |
| | | var popup = popupWindowQueue[i]; |
| | | if (activeBattleName == "" || activeBattleName == "StoryBattleField" || activeBattleName == popup.battleFieldName) |
| | | { |
| | | if (popup.isNeedHomeWin && !UIManager.Instance.IsOpened<HomeWin>()) |
| | | continue; |
| | | targetPopup = popup; |
| | | targetIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (targetPopup == null) |
| | | return; |
| | | |
| | | if (UIManager.Instance.IsOpened(popupWindowQueue[0].window)) |
| | | if (UIManager.Instance.IsOpened(targetPopup.window)) |
| | | { |
| | | //当前模式可以打开多个相同窗口,增加防范 |
| | | return; |
| | | } |
| | | |
| | | if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(popupWindowQueue[0].window)) |
| | | if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(targetPopup.window)) |
| | | return; |
| | | |
| | | if (currentWindow != null && currentWindow.window != null) |
| | |
| | | return; |
| | | } |
| | | |
| | | currentWindow = popupWindowQueue[0]; |
| | | popupWindowQueue.RemoveAt(0); |
| | | currentWindow = targetPopup; |
| | | popupWindowQueue.RemoveAt(targetIndex); |
| | | UIManager.Instance.OpenWindow(currentWindow.window, currentWindow.functionId); |
| | | Debug.LogFormat("推送窗口 " + currentWindow.window); |
| | | |
| | |
| | | public int functionId; |
| | | |
| | | public bool isNeedHomeWin; |
| | | public string battleFieldName; |
| | | } |
| | | |
| | | } |