yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using UnityEngine;
public class ScrollTip
{
    public static List<SystemHintData> m_Hints = new List<SystemHintData>();
    public static List<ScrollTipDetail> m_ActiveTips = new List<ScrollTipDetail>();
 
    private static GameObjectPoolManager.GameObjectPool pool = null;
 
    private static bool inited = false;
 
    public static float tipMoveTime = 0.2f;
 
    public static event Action OnTipReceiveEvent;
 
    
    public static void ShowTip(string tip, ArrayList infoList = null, int _order = 0)
    {
        if (string.IsNullOrWhiteSpace(tip))
            return;
 
        int range = Math.Min(m_Hints.Count, 10);
        int findCnt = 0;
        for (int i = 1; i <= range; i++)
        {
            if (m_Hints[m_Hints.Count - i].message == tip)
            {
                findCnt++;
                if (findCnt == 3)
                {
                    //列表内重复提示最多3次
                    return;
                }
            }
        }
 
        m_Hints.Add(new SystemHintData()
        {
            message = tip,
            extentionData = infoList == null ? infoList : new ArrayList(infoList),
            appendTime = DateTime.Now,
            order = _order
        });
 
        //m_Hints.Sort(SysNotifyMgr.Instance.Compare);
 
        if (OnTipReceiveEvent != null)
        {
            OnTipReceiveEvent();
        }
        //过滤不播放的情况
        if (!CanOpen())
        {
            m_Hints.Clear();
            return;
        }
 
        if (!UIManager.Instance.IsOpened<ScrollTipWin>())
        {
            UIManager.Instance.OpenWindowAsync<ScrollTipWin>().Forget();
        }
    }
 
    static bool CanOpen()
    {
 
        // if (HappyXBModel.Instance.isXBCoolTime)
        //     return false;
        return true;
    }
 
    public static async UniTask<ScrollTipDetail> Request()
    {
        ScrollTipDetail tip = null;
        if (pool == null)
        {
            var _prefab = await UILoader.LoadPrefabAsync("Tip");
            if (pool == null)
            {
                pool = GameObjectPoolManager.Instance.GetPool(_prefab);
            }
        }
        if (pool != null)
        {
            tip = pool.Request().AddMissingComponent<ScrollTipDetail>();
        }
        return tip;
    }
 
    public static async UniTask<ScrollTipDetail> RequestAsync()
    {
        ScrollTipDetail tip = null;
        if (pool == null)
        {
            var _prefab = await UILoader.LoadPrefabAsync("Tip");
            pool = GameObjectPoolManager.Instance.GetPool(_prefab);
        }
        if (pool != null)
        {
            tip = pool.Request().AddMissingComponent<ScrollTipDetail>();
        }
        return tip;
    }
 
    public static void Release(ScrollTipDetail tip, bool next = true)
    {
        if (m_ActiveTips.Contains(tip))
        {
            tip.presentState = ScrollTipState.None;
            m_ActiveTips.Remove(tip);
        }
        if (tip.gameObject != null && pool != null)
        {
            pool.Release(tip.gameObject);
        }
        if (m_ActiveTips.Count > 0 && next)
        {
            m_ActiveTips[0].Play(ScrollTipState.Hide);
        }
    }
 
    public static void ReleaseAll()
    {
        for (int i = 0; i < m_ActiveTips.Count; i++)
        {
            Release(m_ActiveTips[i]);
            i--;
        }
    }
 
    public static void OnTipComplete()
    {
        if (OnTipReceiveEvent != null) OnTipReceiveEvent();
    }
 
    public static void Close()
    {
        m_Hints.Clear();
    }
 
    //暂时保留 改用dotween
    public enum ScrollTipState
    {
        None,
        Idle,
        Move,
        Hide
    }
}