先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
105 lines
3.9 KiB
C#
105 lines
3.9 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using cfg;
|
|
public class EventPackData
|
|
{
|
|
private Tables _tables = GContext.container.Resolve<Tables>();
|
|
private struct Data
|
|
{
|
|
public int currentEventID;
|
|
public int purchaseCount;
|
|
public int VIPLvlWhenEventActivate;
|
|
public int redirectID;
|
|
public Data(int eventID = 0, int p = 0, int v = 0, int rid = 0)
|
|
{
|
|
currentEventID = eventID;
|
|
purchaseCount = p;
|
|
VIPLvlWhenEventActivate = v;
|
|
redirectID = rid;
|
|
}
|
|
}
|
|
private Data _data;
|
|
public int CurrentEventID { get { return _data.currentEventID; } }
|
|
public int PurchaseCount { get { return _data.purchaseCount; } }
|
|
public int VIPLvlWhenEventActivated { get { return _data.VIPLvlWhenEventActivate; } }
|
|
|
|
public bool IsActive => _tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID) &&
|
|
(System.DateTime.Parse(
|
|
(_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime)
|
|
?.EndTime) -
|
|
ZZTimeHelper.UtcNow()).TotalSeconds > 0 &&
|
|
PurchaseCount < _tables.TbEventPackManager[_data.redirectID].MaxCount;
|
|
public EventPackData()
|
|
{
|
|
//Debug.Log("<color=red>construct</color>");
|
|
_data = new Data();
|
|
//PlayFabMgr.Instance.UpdateUserDataValue("EventPackData",
|
|
// Newtonsoft.Json.JsonConvert.SerializeObject(_data));
|
|
}
|
|
|
|
public void AddPurchaceCount()
|
|
{
|
|
_data.purchaseCount++;
|
|
SaveEventPackData();
|
|
}
|
|
/// <summary>
|
|
/// Refresh and update EventPackData if current event is not the event given. Will reset current
|
|
/// event if the event given is null
|
|
/// </summary>
|
|
/// <param name="e">New event</param>
|
|
public bool UpdateEventData(cfg.FishingEvent e = null)
|
|
{
|
|
bool isUpdated = false;
|
|
if (e == null)
|
|
{
|
|
_data = new Data();
|
|
isUpdated = true;
|
|
}
|
|
else if (_data.currentEventID != e.ID)
|
|
{
|
|
_data = new Data(e.ID, 0, GContext.container.Resolve<PlayerData>().PriceLv, e.RedirectID);
|
|
isUpdated = true;
|
|
}
|
|
//else
|
|
// do nothing
|
|
SaveEventPackData();
|
|
return isUpdated;
|
|
}
|
|
public void LoadEventPackData(string s)
|
|
{
|
|
//Debug.Log("<color=red>load epd</color>");
|
|
_data = Newtonsoft.Json.JsonConvert.DeserializeObject<Data>(s);
|
|
//Debug.Log($"load: {_data.currentEventID}");
|
|
if (!_tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID) ||
|
|
(System.DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition
|
|
as LimitedTime).EndTime) - ZZTimeHelper.UtcNow()).TotalSeconds <= 0 )
|
|
{
|
|
return;
|
|
}
|
|
if (_tables.TbEventPackManager[_tables.TbFishingEvent[_data.currentEventID].RedirectID].PackType != 1)
|
|
{
|
|
_data = new Data();
|
|
return;
|
|
}
|
|
if (_data.redirectID == 0)
|
|
_data.redirectID = 4054001;
|
|
TriggerEventPack();
|
|
}
|
|
public void SaveEventPackData()
|
|
{
|
|
PlayFabMgr.Instance.UpdateUserDataValue("EventPackData",
|
|
Newtonsoft.Json.JsonConvert.SerializeObject(_data));
|
|
}
|
|
private void TriggerEventPack()
|
|
{
|
|
var tables = GContext.container.Resolve<Tables>();
|
|
FishingEvent e = tables.TbFishingEvent.DataMap[_data.currentEventID];
|
|
int packID = _data.redirectID;
|
|
var packData = tables.TbEventPackManager.DataMap[packID];//pack data read from tables
|
|
// if (_data.purchaseCount < packData.MaxCount && packData.PackType == 1)
|
|
//TODO:change panel according to RedirecctID of current event
|
|
// GContext.container.Resolve<IFaceUIService>().
|
|
// AddGiftFaceUI(e.ID, UITypes.GiftPopupPanel_9, packData.PackType, true);
|
|
}
|
|
}
|