NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/SignUp/SignUpManager.cs

119 lines
3.0 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2024-04-09 18:44:57 +08:00
using Cysharp.Threading.Tasks;
using Framework;
2024-03-25 17:08:42 +08:00
using Gameplay;
2024-07-08 13:20:11 +08:00
using Gameplay.Guide;
2025-04-01 15:32:40 +08:00
using Gameplay.Net;
using PhxhSDK;
2024-04-29 14:22:22 +08:00
using Unity.Mathematics;
2024-03-25 17:08:42 +08:00
using Constants = PhxhSDK.Constants;
public class SignUpManager : Singlenton<SignUpManager>, IInitable
{
private Dictionary<int, SignObjAccumulate> _accumulateDic;
public bool DoNotShowDailyAccumulate; //可展示每日登录签到
2025-04-01 15:32:40 +08:00
private SignObjAccumulate _accumulateObj; //登录签到对象
public bool NeedShowDailyAccumulate
{
get{
if (_accumulateDic != null)
{
if (_accumulateDic.TryGetValue(1, out var accObj))
{
return accObj.IsNeedToShow;
}
}
return false;
}
}
public void Init()
{
2024-04-29 14:22:22 +08:00
_accumulateDic = new Dictionary<int, SignObjAccumulate>();
EventManager.Instance.Register(EventManager.EventName.PartLogicSign, OnPartLogicRefresh);
}
public void Release()
{
EventManager.Instance.Unregister(EventManager.EventName.PartLogicSign, OnPartLogicRefresh);
}
private void _CreateSignObjs()
{
_CreateAccumulateObjs();
}
//创建累计充值的对象
private void _CreateAccumulateObjs()
{
if (_accumulateDic.Count > 0)
{
_accumulateDic.Clear();
}
2025-04-01 15:32:40 +08:00
_CreateAccumulateObj();
}
2025-04-01 15:32:40 +08:00
private void _CreateAccumulateObj()
{
2025-04-01 15:32:40 +08:00
// if (!_accumulateDic.ContainsKey(signId))
// {
// var accSignObj = SignObjAccumulate.CreateObj();
// _accumulateDic.Add(signId, accSignObj);
// }
_accumulateObj = SignObjAccumulate.CreateObj();
}
2024-04-29 14:22:22 +08:00
public async UniTask<bool> CheckShowSignUp()
{
2024-07-08 13:20:11 +08:00
if (GuideManager.Instance.IsGuiding) // 引导中不弹每日登录奖励
return false;
if (DoNotShowDailyAccumulate)
{
2024-04-29 14:22:22 +08:00
return false;
}
2025-04-01 15:32:40 +08:00
if (_accumulateObj == null)
_CreateSignObjs();
2025-04-01 15:32:40 +08:00
if (_accumulateObj != null && _accumulateObj.IsNeedToShow)
2024-04-29 14:22:22 +08:00
{
DebugUtil.LogP("--- 展示签到界面 --- ");
2024-03-29 12:30:23 +08:00
await UI_DailyBonusController.Open(1);
2024-04-29 14:22:22 +08:00
return true;
}
return false;
2024-02-28 15:10:11 +08:00
}
2025-04-01 15:32:40 +08:00
public SignObjAccumulate GetAccumulateSignObj()
2024-02-28 15:10:11 +08:00
{
2025-04-01 15:32:40 +08:00
// if (_accumulateDic.TryGetValue(signId, out var obj))
// {
// return obj;
// }
2024-02-28 15:10:11 +08:00
2025-04-01 15:32:40 +08:00
return _accumulateObj;
}
private void OnPartLogicRefresh()
{
_CreateAccumulateObjs();
if (DoNotShowDailyAccumulate)
{
DoNotShowDailyAccumulate = false;
}
//DebugUtil.LogG("--- Accumulate_Refresh --- ");
EventManager.Instance.Send(EventManager.EventName.Accumulate_Refresh);
}
2025-04-01 15:32:40 +08:00
/// <summary>
/// 申请签到
/// </summary>
public void ReqAccumulateSignUp()
{
NetHelper.ReqAccumulateSignUp();
}
}