106 lines
2.5 KiB
C#
106 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Guide;
|
|
using PhxhSDK;
|
|
using Unity.Mathematics;
|
|
using Constants = PhxhSDK.Constants;
|
|
|
|
public class SignUpManager : Singlenton<SignUpManager>, IInitable
|
|
{
|
|
private Dictionary<int, SignObjAccumulate> _accumulateDic;
|
|
public bool DoNotShowDailyAccumulate; //可展示每日登录签到
|
|
|
|
public bool NeedShowDailyAccumulate
|
|
{
|
|
get{
|
|
if (_accumulateDic != null)
|
|
{
|
|
if (_accumulateDic.TryGetValue(1, out var accObj))
|
|
{
|
|
return accObj.IsNeedToShow;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
_accumulateDic = new Dictionary<int, SignObjAccumulate>();
|
|
EventManager.Instance.Register(EventManager.EventName.PartLogic, OnPartLogicRefresh);
|
|
}
|
|
|
|
public void Release()
|
|
{
|
|
EventManager.Instance.Unregister(EventManager.EventName.PartLogic, OnPartLogicRefresh);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
public async UniTask<bool> CheckShowSignUp()
|
|
{
|
|
if (GuideManager.Instance.IsGuiding) // 引导中不弹每日登录奖励
|
|
return false;
|
|
|
|
if (DoNotShowDailyAccumulate)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (_accumulateDic.Count <= 0)
|
|
_CreateSignObjs();
|
|
|
|
if (_accumulateDic[1].IsNeedToShow)
|
|
{
|
|
await UI_DailyBonusController.Open(1);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public SignObjAccumulate GetAccumulateSignObj(int signId)
|
|
{
|
|
if (_accumulateDic.TryGetValue(signId, out var obj))
|
|
{
|
|
return obj;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void OnPartLogicRefresh()
|
|
{
|
|
_CreateAccumulateObjs();
|
|
if (DoNotShowDailyAccumulate)
|
|
{
|
|
DoNotShowDailyAccumulate = false;
|
|
}
|
|
EventManager.Instance.Send(EventManager.EventName.Accumulate_Refresh);
|
|
}
|
|
} |