128 lines
3.6 KiB
C#
128 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using cfg.ActorCfg;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Net;
|
|
using NLDPB;
|
|
using Unity.Mathematics;
|
|
using ItemCount = cfg.item.ItemCounts;
|
|
|
|
public class SignObjBase
|
|
{
|
|
private int _signId;
|
|
|
|
protected SignObjBase(int signId)
|
|
{
|
|
_signId = signId;
|
|
}
|
|
|
|
protected SignObjBase()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public class SignObjAccumulate : SignObjBase
|
|
{
|
|
private readonly DataSign _cfg;
|
|
private int _accumulateCount; //累计签到次数
|
|
private int _signIndex; //签到组ID
|
|
private int _signDay; //第几天需签到
|
|
private int _cycleCount; //每次循环总次数
|
|
private readonly List<ItemCount> _itemList; //奖励道具表
|
|
private bool _isNeedShowSign;
|
|
private int _totalCount; //总次数
|
|
|
|
public DataSign Cfg => _cfg;
|
|
public List<ItemCount> ItemList => _itemList;
|
|
public int AccumulateCount => _signDay;
|
|
|
|
public bool IsNeedToShow
|
|
{
|
|
get
|
|
{
|
|
return _CheckIsTimeToday();
|
|
}
|
|
}
|
|
public int CycleCount => _cycleCount;
|
|
public int TotalCount => _totalCount;
|
|
|
|
private SignObjAccumulate()
|
|
{
|
|
_itemList = new List<ItemCount>();
|
|
|
|
_ParseCount();
|
|
var dataList = TableManager.Instance.Tables.SignCfg.DataList;
|
|
var data = dataList[_signIndex];
|
|
_cfg = data;
|
|
_totalCount = data.Rewards.Count;
|
|
|
|
for (int i = 0; i < data.Rewards.Count; i++)
|
|
{
|
|
var reward = data.Rewards[i];
|
|
_itemList.Add(reward);
|
|
}
|
|
|
|
//缓存到本地
|
|
// var storeData = StorageMgr.Instance.GetStorage<SignStoreData>("SignStoreData");
|
|
// if (_isNeedShowSign)
|
|
// {
|
|
// storeData.IsShowAccumulateWindow = _isNeedShowSign;
|
|
// StorageMgr.Instance.SyncForce = true;
|
|
// return;
|
|
// }
|
|
// if (storeData.IsShowAccumulateWindow)
|
|
// {
|
|
// _isNeedShowSign = storeData.IsShowAccumulateWindow;
|
|
// }
|
|
}
|
|
|
|
private int _ParseCount(uint inputData, out bool isNeedSign)
|
|
{
|
|
isNeedSign = inputData > int.MaxValue;
|
|
var retInt = CommonUtils.GetIntBitByIndex(inputData, 31, true);
|
|
|
|
return retInt;
|
|
}
|
|
|
|
private void _ParseCount()
|
|
{
|
|
var actorSignCount = (int)Actor.Instance.Logic.GetCount((uint)LogicID.SignCount);
|
|
_signIndex = actorSignCount / (int)GlobalDefine.SignOffset;
|
|
_signDay = actorSignCount - _signIndex * (int)GlobalDefine.SignOffset;
|
|
}
|
|
|
|
public static SignObjAccumulate CreateObj()
|
|
{
|
|
//var tableData = TableManager.Instance.Tables.SignCfg;
|
|
// var data = tableData.GetOrDefault(signId);
|
|
// if (data == null)
|
|
// {
|
|
// DebugUtil.LogError($"////创建签到对象传入的ID有误////");
|
|
// return null;
|
|
// }
|
|
|
|
return new SignObjAccumulate();
|
|
}
|
|
|
|
private bool _CheckIsTimeToday()
|
|
{
|
|
var curDateTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Server);
|
|
var today5 = new DateTime(curDateTime.Year, curDateTime.Month, curDateTime.Day, 5, 0, 0);
|
|
var timeStamp = new DateTimeOffset(today5);
|
|
var timeStampSec = (uint)timeStamp.ToUnixTimeSeconds();
|
|
var lastTimeStamp = Actor.Instance.Logic.GetCount((uint)_cfg.TimeID);
|
|
return lastTimeStamp < timeStampSec;
|
|
}
|
|
|
|
public void SetIsNeedShow(bool state)
|
|
{
|
|
_isNeedShowSign = state;
|
|
}
|
|
}
|
|
|
|
public class SignStoreData
|
|
{
|
|
public bool IsShowAccumulateWindow;
|
|
} |