105 lines
2.9 KiB
C#
105 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using cfg.ActorCfg;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Net;
|
|
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 _cycleCount; //每次循环总次数
|
|
private readonly List<ItemCount> _itemList; //奖励道具表
|
|
private bool _isNeedShowSign;
|
|
private int _totalCount; //总次数
|
|
|
|
public DataSign Cfg => _cfg;
|
|
public List<ItemCount> ItemList => _itemList;
|
|
public int AccumulateCount => _accumulateCount;
|
|
public bool IsNeedToShow {
|
|
get{return _isNeedShowSign;}
|
|
set { _isNeedShowSign = value; }
|
|
}
|
|
|
|
public int CycleCount => _cycleCount;
|
|
public int TotalCount => _totalCount;
|
|
|
|
private SignObjAccumulate(DataSign data)
|
|
{
|
|
_itemList = new List<ItemCount>();
|
|
|
|
_cfg = data;
|
|
var uIntCount = Actor.Instance.Logic.GetCount((uint)data.CountID);
|
|
_accumulateCount = _ParseCount(uIntCount, out _isNeedShowSign);
|
|
_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");
|
|
// DebugUtil.LogError($"_isNeedShowSign{_isNeedShowSign}");
|
|
// DebugUtil.LogError($"storeData.IsShowAccumulateWindow{storeData.IsShowAccumulateWindow}");
|
|
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;
|
|
}
|
|
|
|
public static SignObjAccumulate CreateObj(int signId)
|
|
{
|
|
var tableData = TableManager.Instance.Tables.SignCfg;
|
|
var data = tableData.GetOrDefault(signId);
|
|
if (data == null)
|
|
{
|
|
DebugUtil.LogError($"////创建签到对象传入的ID有误////");
|
|
return null;
|
|
}
|
|
|
|
return new SignObjAccumulate(data);
|
|
}
|
|
|
|
public void SetIsNeedShow(bool state)
|
|
{
|
|
_isNeedShowSign = state;
|
|
}
|
|
}
|
|
|
|
public class SignStoreData
|
|
{
|
|
public bool IsShowAccumulateWindow;
|
|
} |