先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
633 lines
26 KiB
C#
633 lines
26 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using LitJson;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
|
|
namespace GameCore
|
|
{
|
|
public class TriggerPackBuyData
|
|
{
|
|
public int ID;
|
|
//领取第几个
|
|
public int index;
|
|
//礼包类型
|
|
public int lastID;
|
|
//结束时间
|
|
public string time;
|
|
//触发当时VIP等级
|
|
public int vipLevel;
|
|
//触发当时地图ID
|
|
public int mapID;
|
|
}
|
|
public class GiftVIPDData
|
|
{
|
|
public int oldVipLevel;
|
|
public int curVipLevel;
|
|
//记录数据用于明天时间(天)
|
|
public int timer;
|
|
}
|
|
public class TriggerPackEvent
|
|
{
|
|
|
|
}
|
|
public class TriggerPackData
|
|
{
|
|
Tables _tables;
|
|
PlayerShopData playerShopData;
|
|
public TriggerPackData(Tables tables)
|
|
{
|
|
_tables = tables;
|
|
}
|
|
//固定时机开启的过期时间
|
|
Dictionary<int, FixedTimeEvent> fixedTimeShopDic = new Dictionary<int, FixedTimeEvent>();
|
|
|
|
//触发礼包的数据
|
|
public List<TriggerPackBuyData> triggerPackList = new List<TriggerPackBuyData>();
|
|
|
|
//VIP 等级叠加
|
|
public Dictionary<string, GiftVIPDData> giftVIPDData = new Dictionary<string, GiftVIPDData>();
|
|
public void Init()
|
|
{
|
|
playerShopData = GContext.container.Resolve<PlayerShopData>();
|
|
GContext.OnEvent<ConditionTypeEvent>().Subscribe(UpdateTriggerPackData);
|
|
InitPackData();
|
|
}
|
|
#region 礼包限制、开启、初始化
|
|
public void SetFixedTimeShopDic(Dictionary<int, FixedTimeEvent> _limitedTimeShopDic)
|
|
{
|
|
fixedTimeShopDic = _limitedTimeShopDic;
|
|
}
|
|
public bool FixedTimeEventExpired(int eventId)
|
|
{
|
|
if (fixedTimeShopDic.TryGetValue(eventId, out FixedTimeEvent fixedTimeEvent))
|
|
{
|
|
var endTime = GlobalUtils.TryParseDateTime(fixedTimeEvent.endTime, ZZTimeHelper.UtcNow().UtcNowOffset());
|
|
return endTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks;
|
|
}
|
|
return true;
|
|
}
|
|
public void InitPackData()
|
|
{
|
|
InitGiftVIPDData();
|
|
//过期礼包删除
|
|
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
for (int i = triggerPackList.Count - 1; i >= 0; i--)
|
|
{
|
|
TriggerPackBuyData item = triggerPackList[i];
|
|
DateTime endTime = GlobalUtils.TryParseDateTime(item.time, curTime);
|
|
if (endTime.Ticks <= curTime.Ticks)
|
|
{
|
|
triggerPackList.Remove(item);
|
|
}
|
|
}
|
|
List<TriggerPackManager> _dataList = _tables.TbTriggerPackManager.DataList;
|
|
foreach (var t in _dataList)
|
|
{
|
|
if (t.PackType == 2)
|
|
{
|
|
ConditionTypeAdd(t);
|
|
}
|
|
}
|
|
triggerPackList.Sort((a, b) => a.lastID.CompareTo(b.lastID));
|
|
}
|
|
bool isInitFace;
|
|
public void SetInitFace()
|
|
{
|
|
if (isInitFace)
|
|
{
|
|
return;
|
|
}
|
|
isInitFace = true;
|
|
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (playerShopData.GetShopPackBuyCount(triggerPackList[i].lastID) == 0 && triggerPackList[i].lastID != 4)
|
|
{
|
|
playerShopData.AddShopPackDailyBuyCount(triggerPackList[i].lastID, 1, false);
|
|
}
|
|
if (triggerPackList[i].mapID <= 0)
|
|
{
|
|
triggerPackList[i].mapID = GContext.container.Resolve<PlayerData>().currentMapId;
|
|
}
|
|
if (triggerPackList[i].lastID == 53)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(triggerPackList[i].ID, UITypes.MapPackPanel, triggerPackList[i].lastID);
|
|
}
|
|
else if (triggerPackList[i].lastID == 2)
|
|
{
|
|
// CommerceNoviceGiftPopupPanel 已禁用
|
|
}
|
|
else if (triggerPackList[i].lastID == 1)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(triggerPackList[i].ID, UITypes.GiftPopupPanel_6, triggerPackList[i].lastID);
|
|
}
|
|
else if (triggerPackList[i].lastID == 5)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(triggerPackList[i].ID, UITypes.AdsPackPanel, triggerPackList[i].lastID);
|
|
}
|
|
|
|
}
|
|
}
|
|
public void UpdateTriggerPackData(ConditionTypeEvent typeData)
|
|
{
|
|
ConditionType type = typeData.type;
|
|
List<TriggerPackManager> _dataList = _tables.TbTriggerPackManager.DataList;
|
|
foreach (var t in _dataList)
|
|
{
|
|
if (t.Condition == type)
|
|
{
|
|
if (ConditionTypeAdd(t, true, typeData.count))
|
|
{
|
|
if (t.PackType == 53)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(t.ID, UITypes.MapPackPanel, t.PackType);
|
|
GContext.Publish(new TriggerPackEvent());
|
|
}
|
|
else if (t.PackType == 2)
|
|
{
|
|
//SetPack2Panel(t);
|
|
// CommerceNoviceGiftPopupPanel 已禁用
|
|
GContext.Publish(new TriggerPackEvent());
|
|
}
|
|
else if (t.PackType == 1)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(t.ID, UITypes.GiftPopupPanel_6, t.PackType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 钓鱼失败 看完广告 触发礼包
|
|
/// </summary>
|
|
public void TriggerAdsPack()
|
|
{
|
|
if (!playerShopData.IsOpenAdPack() || playerShopData.GetAdticketCount() >= 5 ||
|
|
GContext.container.Resolve<PlayerData>().vip < 1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TriggerPackManager t = _tables.TbTriggerPackManager.GetOrDefault(4000101);
|
|
if (t == null || t.PackType != 5)
|
|
{
|
|
return;
|
|
}
|
|
//特殊的 广告礼包 使用 fixedTimeShopDic 记录CD时间
|
|
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
|
|
if (!FixedTimeEventExpired(t.ID))
|
|
{
|
|
fixedTimeShopDic.Remove(t.ID);
|
|
}
|
|
if (!fixedTimeShopDic.ContainsKey(t.ID))
|
|
{
|
|
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
|
|
//广告礼包记录的是 cd时间
|
|
fixedTimeShopDic[t.ID] = new FixedTimeEvent()
|
|
{
|
|
id = t.ID,
|
|
endTime = dateTime.AddSeconds(fixedTime.EndTime).ToString(),
|
|
};
|
|
PlayFabMgr.Instance.UpdateUserDataValue("FixedTimeShopDic", JsonMapper.ToJson(fixedTimeShopDic));
|
|
|
|
TriggerPackBuyData _newSignEvent = null;
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].ID == t.ID)
|
|
{
|
|
_newSignEvent = triggerPackList[i];
|
|
break;
|
|
}
|
|
}
|
|
string time = dateTime.AddSeconds(fixedTime.StartTime).ToString();
|
|
if (_newSignEvent == null)
|
|
{
|
|
_newSignEvent = new TriggerPackBuyData()
|
|
{
|
|
ID = t.ID,
|
|
lastID = t.PackType,
|
|
index = 0,
|
|
time = time,
|
|
vipLevel = GetVIPLevel(t.PackType),
|
|
mapID = GContext.container.Resolve<PlayerData>().lastMapId,
|
|
};
|
|
triggerPackList.Insert(0, _newSignEvent);
|
|
}
|
|
else
|
|
{
|
|
_newSignEvent.time = time;
|
|
_newSignEvent.vipLevel = GetVIPLevel(t.PackType);
|
|
}
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(_newSignEvent.ID, UITypes.AdsPackPanel, _newSignEvent.lastID);
|
|
PlayFabMgr.Instance.UpdateUserDataValue("TriggerPackDataList", JsonMapper.ToJson(triggerPackList));
|
|
}
|
|
}
|
|
|
|
public void RefreshTriggerPackData(int id, int mapID)
|
|
{
|
|
TriggerPackManager t = _tables.TbTriggerPackManager.GetOrDefault(id);
|
|
bool isOpen = playerShopData.GetShopPackBuyCount(t.PackType) < t.MaxTrigger;
|
|
|
|
if (isOpen)
|
|
{
|
|
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
TriggerPackBuyData _newSignEvent = null;
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].ID == t.ID)
|
|
{
|
|
_newSignEvent = triggerPackList[i];
|
|
break;
|
|
}
|
|
}
|
|
if (_newSignEvent != null)
|
|
{
|
|
triggerPackList.Remove(_newSignEvent);
|
|
}
|
|
string time = dateTime.AddDays(10).ToString();
|
|
if (t.TimeDefinition is FixedTime)
|
|
{
|
|
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
|
|
time = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(fixedTime.StartTime).ToString();
|
|
FixedTimeEvent fixedTimeEvent = new FixedTimeEvent()
|
|
{
|
|
id = t.ID,
|
|
endTime = time,
|
|
};
|
|
fixedTimeShopDic[t.ID] = fixedTimeEvent;
|
|
PlayFabMgr.Instance.UpdateUserDataValue("FixedTimeShopDic", JsonMapper.ToJson(fixedTimeShopDic));
|
|
}
|
|
else if (t.TimeDefinition is LimitedTime)
|
|
{
|
|
LimitedTime limitedTime = (LimitedTime)t.TimeDefinition;
|
|
time = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow()).UtcNowOffset().ToString();
|
|
}
|
|
|
|
_newSignEvent = new TriggerPackBuyData()
|
|
{
|
|
ID = t.ID,
|
|
lastID = t.PackType,
|
|
index = 0,
|
|
time = time,
|
|
vipLevel = GetVIPLevel(t.PackType),
|
|
mapID = mapID,
|
|
};
|
|
triggerPackList.Insert(0, _newSignEvent);
|
|
playerShopData.AddShopPackDailyBuyCount(t.PackType, 1, false);
|
|
PlayFabMgr.Instance.UpdateUserDataValue("TriggerPackDataList", JsonMapper.ToJson(triggerPackList));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 特殊触发礼包
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void AddTriggerPackData(int id)
|
|
{
|
|
TriggerPackManager t = _tables.TbTriggerPackManager.GetOrDefault(id);
|
|
|
|
bool isOpen = t.MaxTrigger == 0 || ((t.PackType == 1 || t.PackType == 2) && GContext.container.Resolve<PlayerShopData>().GetAllPackCount(t.ID) < t.MaxTrigger)//类型为1.2新手礼包
|
|
|| (t.PackType != 1 && t.PackType != 2 && playerShopData.GetShopPackBuyCount(t.PackType) < t.MaxTrigger);//每日限购礼包
|
|
|
|
if (isOpen)
|
|
{
|
|
if (t.TimeDefinition is FixedTime)
|
|
{
|
|
if (t.PackType == 53)
|
|
{
|
|
fixedTimeShopDic.Remove(t.ID);
|
|
}
|
|
if (!fixedTimeShopDic.ContainsKey(t.ID))
|
|
{
|
|
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
|
|
fixedTimeShopDic[t.ID] = new FixedTimeEvent()
|
|
{
|
|
id = t.ID,
|
|
endTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(fixedTime.StartTime).ToString(),
|
|
};
|
|
|
|
PlayFabMgr.Instance.UpdateUserDataValue("FixedTimeShopDic", JsonMapper.ToJson(fixedTimeShopDic));
|
|
}
|
|
if (FixedTimeEventExpired(t.ID))
|
|
{
|
|
AddTriggerPack(t);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddTriggerPack(t);
|
|
}
|
|
}
|
|
}
|
|
bool ConditionTypeAdd(TriggerPackManager t, bool trigger = false, int Param = 0)
|
|
{
|
|
bool isOpen = false;
|
|
if (Condition(t, false, Param))
|
|
{
|
|
if (t.TimeDefinition is FixedTime)
|
|
{
|
|
if (trigger && (t.PackType == 53))
|
|
{
|
|
fixedTimeShopDic.Remove(t.ID);
|
|
}
|
|
if (!fixedTimeShopDic.ContainsKey(t.ID))
|
|
{
|
|
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
|
|
fixedTimeShopDic[t.ID] = new FixedTimeEvent()
|
|
{
|
|
id = t.ID,
|
|
endTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(fixedTime.StartTime).ToString(),
|
|
};
|
|
|
|
PlayFabMgr.Instance.UpdateUserDataValue("FixedTimeShopDic", JsonMapper.ToJson(fixedTimeShopDic));
|
|
}
|
|
if (FixedTimeEventExpired(t.ID))
|
|
{
|
|
AddTriggerPack(t);
|
|
isOpen = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddTriggerPack(t);
|
|
isOpen = true;
|
|
}
|
|
}
|
|
return isOpen;
|
|
}
|
|
bool Condition(TriggerPackManager packManager, bool isAdd, int Param)
|
|
{
|
|
if (packManager.PackType == 5)
|
|
{
|
|
return false;
|
|
}
|
|
bool isOpen = packManager.MaxTrigger == 0 || ((packManager.PackType == 1 || packManager.PackType == 2) && GContext.container.Resolve<PlayerShopData>().GetAllPackCount(packManager.ID) < packManager.MaxTrigger)//类型为1.2新手礼包
|
|
|| (packManager.PackType != 1 && packManager.PackType != 2 && playerShopData.GetShopPackBuyCount(packManager.PackType) < packManager.MaxTrigger);//每日限购礼包
|
|
if (!isOpen)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (packManager.TimeDefinition is LimitedTime)
|
|
{
|
|
LimitedTime limitedTime = (LimitedTime)packManager.TimeDefinition;
|
|
var timer = ZZTimeHelper.UtcNow();
|
|
isOpen = GlobalUtils.TryParseDateTime(limitedTime.StartTime, timer) <= timer && timer < GlobalUtils.TryParseDateTime(limitedTime.EndTime, timer);
|
|
}
|
|
|
|
switch (packManager.Condition)
|
|
{
|
|
case ConditionType.AccountLevel:
|
|
if (isAdd)
|
|
{
|
|
isOpen &= GContext.container.Resolve<PlayerData>().lv >= int.Parse(packManager.Param[0]);
|
|
}
|
|
else
|
|
{
|
|
isOpen &= GContext.container.Resolve<PlayerData>().lv == int.Parse(packManager.Param[0]);
|
|
}
|
|
break;
|
|
case ConditionType.GetFishCount:
|
|
if (isAdd)
|
|
{
|
|
isOpen &= GContext.container.Resolve<PlayerFishData>().GetAnglingCount() >= int.Parse(packManager.Param[0]);
|
|
}
|
|
else
|
|
{
|
|
isOpen &= GContext.container.Resolve<PlayerFishData>().GetAnglingCount() == int.Parse(packManager.Param[0]);
|
|
}
|
|
break;
|
|
case ConditionType.CompleteGuide:
|
|
isOpen &= GContext.container.Resolve<GuideDataCenter>().GetIsFinish(packManager.Param[0]);
|
|
break;
|
|
case ConditionType.BuyPack:
|
|
isOpen &= playerShopData.shopAllPackBuyCount.GetValueOrDefault(int.Parse(packManager.Param[0])) > 0;
|
|
break;
|
|
case ConditionType.MapUnlocked:
|
|
//isOpen &= GContext.container.Resolve<PlayerData>().MapIsUnlock(packManager.Param);
|
|
isOpen &= packManager.Param.Contains(Param.ToString());
|
|
break;
|
|
}
|
|
// if ( packManager.PackType == 2 )
|
|
// Debug.Log("??" + packManager.Condition+GContext.container.Resolve<PlayerData>().lv+int.Parse(packManager.Param[0])+ (GContext.container.Resolve<PlayerData>().lv >= int.Parse(packManager.Param[0])) + " " +isOpen);
|
|
return isOpen;
|
|
}
|
|
#endregion
|
|
void InitGiftVIPDData()
|
|
{
|
|
if (giftVIPDData.Count > 0)
|
|
{
|
|
var timer = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
int dateTime = timer.AddDays(1).DayOfYear;
|
|
bool isUpdate = false;
|
|
foreach (var item in giftVIPDData)
|
|
{
|
|
GiftVIPDData giftVIPDData = item.Value;
|
|
if (giftVIPDData.timer != dateTime)
|
|
{
|
|
isUpdate = true;
|
|
if (giftVIPDData.timer == timer.DayOfYear)
|
|
{
|
|
giftVIPDData.oldVipLevel = giftVIPDData.curVipLevel;
|
|
giftVIPDData.curVipLevel = 0;
|
|
}
|
|
else
|
|
{
|
|
giftVIPDData.oldVipLevel = 0;
|
|
giftVIPDData.curVipLevel = 0;
|
|
}
|
|
giftVIPDData.timer = dateTime;
|
|
}
|
|
}
|
|
if (isUpdate)
|
|
{
|
|
PlayFabMgr.Instance.UpdateUserDataValue("GiftVIPDData", JsonMapper.ToJson(giftVIPDData));
|
|
}
|
|
}
|
|
}
|
|
public int GetVIPLevel(int packType)
|
|
{
|
|
string PackType = packType.ToString();
|
|
return GetVIPLevel(PackType);
|
|
}
|
|
public void SetVIPLevel(int packType, int VIPBonusForNextType)
|
|
{
|
|
string PackType = packType.ToString();
|
|
SetVIPLevel(PackType, VIPBonusForNextType);
|
|
}
|
|
public int GetVIPLevel(string type)
|
|
{
|
|
int vipLevel = GContext.container.Resolve<PlayerData>().PriceLv;
|
|
if (giftVIPDData.TryGetValue(type, out GiftVIPDData giftVIPD))
|
|
{
|
|
vipLevel += giftVIPD.oldVipLevel;
|
|
}
|
|
if (vipLevel >= _tables.TbVipLevel.DataList.Count)
|
|
{
|
|
vipLevel = _tables.TbVipLevel.DataList.Count - 1;
|
|
}
|
|
return vipLevel;
|
|
}
|
|
public void SetVIPLevel(string PackType, int VIPBonusForNextType)
|
|
{
|
|
if (VIPBonusForNextType > 0)
|
|
{
|
|
if (giftVIPDData.TryGetValue(PackType, out GiftVIPDData giftVIPD))
|
|
{
|
|
giftVIPD.curVipLevel += VIPBonusForNextType;
|
|
}
|
|
else
|
|
{
|
|
giftVIPD = new GiftVIPDData()
|
|
{
|
|
curVipLevel = VIPBonusForNextType,
|
|
timer = ZZTimeHelper.UtcNow().UtcNowOffset().AddDays(1).DayOfYear,
|
|
};
|
|
}
|
|
giftVIPDData[PackType] = giftVIPD;
|
|
PlayFabMgr.Instance.UpdateUserDataValue("GiftVIPDData", JsonMapper.ToJson(giftVIPDData));
|
|
}
|
|
}
|
|
#region 触发礼包
|
|
public void AddTriggerPack(TriggerPackManager t)
|
|
{
|
|
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
TriggerPackBuyData _newSignEvent = null;
|
|
//if (t.PackType != 53)
|
|
//{
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].ID == t.ID)
|
|
{
|
|
_newSignEvent = triggerPackList[i];
|
|
break;
|
|
}
|
|
}
|
|
//}
|
|
if (_newSignEvent != null &&
|
|
(GlobalUtils.TryParseDateTime(_newSignEvent.time, ZZTimeHelper.UtcNow()).Ticks < dateTime.Ticks))
|
|
{
|
|
triggerPackList.Remove(_newSignEvent);
|
|
_newSignEvent = null;
|
|
}
|
|
if (_newSignEvent == null)
|
|
{
|
|
string time = dateTime.AddDays(10).ToString();
|
|
if (t.TimeDefinition is FixedTime)
|
|
{
|
|
if (fixedTimeShopDic.TryGetValue(t.ID, out FixedTimeEvent fixedTimeEvent))
|
|
{
|
|
time = fixedTimeEvent.endTime;
|
|
}
|
|
else
|
|
{
|
|
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
|
|
time = dateTime.AddSeconds(fixedTime.StartTime).ToString();
|
|
}
|
|
}
|
|
else if (t.TimeDefinition is LimitedTime)
|
|
{
|
|
LimitedTime limitedTime = (LimitedTime)t.TimeDefinition;
|
|
time = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow()).UtcNowOffset().ToString();
|
|
}
|
|
|
|
_newSignEvent = new TriggerPackBuyData()
|
|
{
|
|
ID = t.ID,
|
|
lastID = t.PackType,
|
|
index = 0,
|
|
time = time,
|
|
vipLevel = GetVIPLevel(t.PackType),
|
|
mapID = GContext.container.Resolve<PlayerData>().lastMapId,
|
|
};
|
|
triggerPackList.Insert(0, _newSignEvent);
|
|
playerShopData.AddShopPackDailyBuyCount(t.PackType, 1, false);
|
|
PlayFabMgr.Instance.UpdateUserDataValue("TriggerPackDataList", JsonMapper.ToJson(triggerPackList));
|
|
}
|
|
}
|
|
public void AddTriggerPackCount(int id)
|
|
{
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].ID == id)
|
|
{
|
|
if (++triggerPackList[i].index >= _tables.TbTriggerPackManager.Get(triggerPackList[i].ID).VIPPackList[GetVIPLevel(triggerPackList[i].lastID)].Count)
|
|
{
|
|
triggerPackList.Remove(triggerPackList[i]);
|
|
}
|
|
PlayFabMgr.Instance.UpdateUserDataValue("TriggerPackDataList", JsonMapper.ToJson(triggerPackList));
|
|
break;
|
|
}
|
|
}
|
|
playerShopData.AddAllPackCount(id, 1);
|
|
TriggerPackManager packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
|
GContext.Publish(new TriggerPackEvent());
|
|
if (packManager.VIPBonus > 0)
|
|
{
|
|
SetVIPLevel(packManager.PackType, packManager.VIPBonus);
|
|
}
|
|
}
|
|
public List<TriggerPackBuyData> GetTriggerPackList(int type)
|
|
{
|
|
List<TriggerPackBuyData> newTriggerPackList = new List<TriggerPackBuyData>();
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].lastID == type && _tables.TbTriggerPackManager.GetOrDefault(triggerPackList[i].ID) != null)
|
|
{
|
|
newTriggerPackList.Add(triggerPackList[i]);
|
|
}
|
|
}
|
|
newTriggerPackList.Sort((a, b) => a.ID.CompareTo(b.ID));
|
|
return newTriggerPackList;
|
|
}
|
|
public void ShowTriggerPack(int type, int id)
|
|
{
|
|
for (int i = 0; i < triggerPackList.Count; i++)
|
|
{
|
|
if (triggerPackList[i].lastID == type && triggerPackList[i].ID == id)
|
|
{
|
|
var t = _tables.TbTriggerPackManager.GetOrDefault(id);
|
|
if (t.PackType == 53)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(t.ID, UITypes.MapPackPanel, t.PackType);
|
|
}
|
|
else if (t.PackType == 2)
|
|
{
|
|
// CommerceNoviceGiftPopupPanel 已禁用
|
|
}
|
|
else if (t.PackType == 1)
|
|
{
|
|
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUIOnLogin(t.ID, UITypes.GiftPopupPanel_6, t.PackType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public TimeSpan GetCurTriggerPackEndTime(TriggerPackBuyData dailySignEvent)
|
|
{
|
|
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
DateTime endTime = GlobalUtils.TryParseDateTime(dailySignEvent.time, curTime);
|
|
if (endTime.Ticks <= curTime.Ticks)
|
|
{
|
|
triggerPackList.Remove(dailySignEvent);
|
|
GContext.Publish(new TriggerPackEvent());
|
|
PlayFabMgr.Instance.UpdateUserDataValue("TriggerPackDataList", JsonMapper.ToJson(triggerPackList));
|
|
}
|
|
return endTime - curTime;
|
|
}
|
|
#endregion
|
|
|
|
public TriggerPackBuyData GetTriggerPackBuyDataById(int packId)
|
|
{
|
|
return triggerPackList.FirstOrDefault(x => x.ID == packId);
|
|
}
|
|
}
|
|
}
|