yyl
5 天以前 c124d98bdf9659cf764bebb799bee42c30eb152f
Main/Component/UI/Common/PopupWindowsProcessor.cs
@@ -1,22 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 弹窗处理器 - 负责管理游戏中的弹窗队列,按顺序显示弹窗窗口
/// 避免多个窗口同时弹出造成界面混乱
/// 只有在homewin打开的情况下才触发
/// </summary>
public class PopupWindowsProcessor : SingletonMonobehaviour<PopupWindowsProcessor>
{
    // 弹窗队列,存储待处理的弹窗请求
    List<PopupWindow> popupWindowQueue = new List<PopupWindow>();
    // 当前正在显示的弹窗
    PopupWindow currentWindow;
    float firstTime = 0; //打开HomeWin时的时间
    float stayTime;
    bool homeWinFirstOpened = false; //HomeWin是否第一次打开
    // 上次弹窗时间,用于控制弹窗之间的间隔
    float lastTime = 0; //上次弹窗时间
    /// <summary>
    /// 添加一个弹窗到处理队列
    /// </summary>
@@ -57,6 +62,7 @@
        }
    }
    /// <summary>
    /// LateUpdate中处理弹窗队列,确保在所有其他逻辑处理完毕后才显示弹窗
    /// </summary>
@@ -77,11 +83,10 @@
        }
        // 检查是否在新手引导中
        // 注意:NewBieCenter在当前代码库中不存在,暂时注释掉相关检查
        // if (NewBieCenter.Instance.inGuiding)
        // {
        //     return;
        // }
        if (NewBieCenter.Instance.inGuiding)
        {
            return;
        }
        if (popupWindowQueue.Count == 0)
        {
@@ -92,10 +97,31 @@
        if (UIManager.Instance.IsOpened<LoadingWin>())
            return;
        // 检查是否存在全屏或遮罩窗口
        // 注意:ExistAnyFullScreenOrMaskWin方法在当前UIManager中不存在,暂时注释掉相关检查
        // if (UIManager.Instance.ExistAnyFullScreenOrMaskWin())
        //     return;
        if (!UIManager.Instance.IsOpened<HomeWin>())
            return;
        // 第一次打开HomeWin时记录时间
        if (!homeWinFirstOpened)
        {
            firstTime = Time.realtimeSinceStartup;
            homeWinFirstOpened = true;
            stayTime = float.Parse(FuncConfigConfig.Get("PopWin").Numerical1);
            return;
        }
        // 等待x秒
        if (Time.realtimeSinceStartup - firstTime < stayTime)
            return;
        if (UIManager.Instance.IsOpened(popupWindowQueue[0].window))
        {
            //当前模式可以打开多个相同窗口,增加防范
            return;
        }
        if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(popupWindowQueue[0].window))
            return;
        if (currentWindow.window != null)
        {
@@ -104,18 +130,13 @@
            if (ui != null && ui.IsActive())
                return;
            currentWindow = popupWindowQueue[0];
            popupWindowQueue.RemoveAt(0);
            UIManager.Instance.OpenWindow(currentWindow.window, currentWindow.functionId);
            Debug.LogFormat("推送窗口 " + currentWindow.window);
        }
        else
        {
            currentWindow = popupWindowQueue[0];
            popupWindowQueue.RemoveAt(0);
            UIManager.Instance.OpenWindow(currentWindow.window, currentWindow.functionId);
            Debug.LogFormat("推送窗口 " + currentWindow.window);
        }
        currentWindow = popupWindowQueue[0];
        popupWindowQueue.RemoveAt(0);
        UIManager.Instance.OpenWindow(currentWindow.window, currentWindow.functionId);
        Debug.LogFormat("推送窗口 " + currentWindow.window);
        lastTime = Time.realtimeSinceStartup;
    }
@@ -127,7 +148,7 @@
    {
        // 窗口名称
        public string window;
        // 功能ID,用于指定窗口的具体功能或显示模式
        public int functionId;