130 lines
3.2 KiB
C#
130 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Guide;
|
|
using Gameplay.Net;
|
|
using Gameplay.PopUp;
|
|
using PhxhSDK;
|
|
|
|
public class SignUpManager : Singlenton<SignUpManager>, IInitable
|
|
{
|
|
private Dictionary<int, SignObjAccumulate> _accumulateDic;
|
|
/// <summary>
|
|
/// 签到弹窗
|
|
/// </summary>
|
|
private SignUp_PopUp signUp_PopUp;
|
|
public bool DoNotShowDailyAccumulate { get; set; }
|
|
//可展示每日登录签到
|
|
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()
|
|
{
|
|
_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();
|
|
}
|
|
_CreateAccumulateObj();
|
|
}
|
|
|
|
private void _CreateAccumulateObj()
|
|
{
|
|
// if (!_accumulateDic.ContainsKey(signId))
|
|
// {
|
|
// var accSignObj = SignObjAccumulate.CreateObj();
|
|
// _accumulateDic.Add(signId, accSignObj);
|
|
// }
|
|
_accumulateObj = SignObjAccumulate.CreateObj();
|
|
}
|
|
|
|
public async UniTask<bool> CheckShowSignUp()
|
|
{
|
|
if (GuideManager.Instance.IsGuiding) // 引导中不弹每日登录奖励
|
|
return false;
|
|
|
|
if (DoNotShowDailyAccumulate)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (_accumulateObj == null)
|
|
_CreateSignObjs();
|
|
|
|
if (_accumulateObj != null && _accumulateObj.IsNeedToShow)
|
|
{
|
|
DebugUtil.LogP("--- 展示签到界面 --- ");
|
|
await UI_DailyBonusController.Open(1);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public SignObjAccumulate GetAccumulateSignObj()
|
|
{
|
|
// if (_accumulateDic.TryGetValue(signId, out var obj))
|
|
// {
|
|
// return obj;
|
|
// }
|
|
|
|
return _accumulateObj;
|
|
}
|
|
|
|
private void OnPartLogicRefresh()
|
|
{
|
|
_CreateAccumulateObjs();
|
|
|
|
if (null != signUp_PopUp)
|
|
PopUpManager.Instance.RemovePopUp(signUp_PopUp);
|
|
|
|
signUp_PopUp = new SignUp_PopUp();
|
|
PopUpManager.Instance.AddPopUp(signUp_PopUp); // 添加签到弹窗
|
|
|
|
/*if (DoNotShowDailyAccumulate)
|
|
{
|
|
DoNotShowDailyAccumulate = false;
|
|
}*/
|
|
//DebugUtil.LogG("--- Accumulate_Refresh --- ");
|
|
//EventManager.Instance.Send(EventManager.EventName.Accumulate_Refresh);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 申请签到
|
|
/// </summary>
|
|
public void ReqAccumulateSignUp()
|
|
{
|
|
NetHelper.ReqAccumulateSignUp();
|
|
}
|
|
} |