75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System.Collections.Generic;
|
||
using Cysharp.Threading.Tasks;
|
||
using Framework;
|
||
using Gameplay;
|
||
using PhxhSDK;
|
||
using Constants = PhxhSDK.Constants;
|
||
|
||
public class SignUpManager: Singlenton<SignUpManager>, IInitable
|
||
{
|
||
private Dictionary<int, SignObjAccumulate> _accumulateDic;
|
||
|
||
public void Init()
|
||
{
|
||
_Init();
|
||
EventManager.Instance.Register(EventManager.EventName.CheckNeedShowSignUp, _OnCheckShowSignUp);
|
||
}
|
||
|
||
public void Release()
|
||
{
|
||
EventManager.Instance.Unregister(EventManager.EventName.CheckNeedShowSignUp, _OnCheckShowSignUp);
|
||
}
|
||
private void _Init()
|
||
{
|
||
_accumulateDic = new Dictionary<int, SignObjAccumulate>();
|
||
}
|
||
|
||
private void _CreateSignObjs()
|
||
{
|
||
_CreateAccumulateObjs();
|
||
}
|
||
|
||
//创建累计充值的对象
|
||
private void _CreateAccumulateObjs()
|
||
{
|
||
if (_accumulateDic.Count > 0)
|
||
{
|
||
_accumulateDic.Clear();
|
||
}
|
||
_CreateAccumulateObj(1);
|
||
}
|
||
|
||
private void _CreateAccumulateObj(int signId)
|
||
{
|
||
if (!_accumulateDic.ContainsKey(signId))
|
||
{
|
||
var accSignObj = SignObjAccumulate.CreateObj(signId);
|
||
_accumulateDic.Add(signId, accSignObj);
|
||
}
|
||
}
|
||
|
||
private async void _OnCheckShowSignUp()
|
||
{
|
||
if (_accumulateDic.Count > 0)
|
||
{
|
||
return;
|
||
}
|
||
_CreateSignObjs();
|
||
|
||
if (_accumulateDic[1].IsNeedToShow)
|
||
{
|
||
await UniTask.Delay(2000); // 延迟2秒,防止过场黑屏截图是黑的
|
||
await UI_DailyBonusController.Open(1);
|
||
}
|
||
}
|
||
|
||
public SignObjAccumulate GetAccumulateSignObj(int signId)
|
||
{
|
||
if (_accumulateDic.TryGetValue(signId, out var obj))
|
||
{
|
||
return obj;
|
||
}
|
||
|
||
return null;
|
||
}
|
||
} |