NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/SubSystems/ScrollNoticeManager.cs

81 lines
1.8 KiB
C#

using DG.Tweening;
using PhxhSDK;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScrollNoticeManager : Singlenton<ScrollNoticeManager>
{
private bool allowNotice = true;
private bool isShow = false;
private Queue<string> receives = new Queue<string>();
void ShowNotice()
{
if (receives.Count > 0 && allowNotice && !isShow)
{
string notice = receives.Dequeue();
isShow = true;
DebugUtil.Log("展示滚动公告:" + notice);
// TODO Action(notice);
//*临时代码
DebugUtil.Log("这里是临时代码,需要替换为实际的滚动公告展示代码");
Sequence sequence = DOTween.Sequence();
sequence.AppendInterval(5f);
sequence.AppendCallback(() =>
{
ShowFinished();
});
//*/
}
}
#region public
/// <summary>
/// 设置当前是否允许显示滚动公告
/// </summary>
/// <param name="allow"></param>
public void SetAllowNotice(bool allow)
{
allowNotice = allow;
if (allowNotice)
{
ShowNotice();
}
}
/// <summary>
/// 添加滚动公告
/// </summary>
/// <param name="notice"></param>
public void AddNotice(string notice)
{
receives.Enqueue(notice);
DebugUtil.Log("添加滚动公告:" + notice);
if(!isShow && allowNotice)
{
ShowNotice();
}
}
/// <summary>
/// 当前滚动公告显示完成
/// </summary>
public void ShowFinished()
{
isShow = false;
ShowNotice();
}
/// <summary>
/// 清空滚动公告
/// </summary>
public void ClearNotice()
{
receives.Clear();
}
#endregion
}