Files
MinFt/Client/Assets/Scripts/DataCenter/DataCenter.FishingEventData.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

2600 lines
106 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using asap.core;
// using Assets.Scripts.UI.SocialRush;
using cfg;
// using DataCenter;
using game;
using LitJson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UniRx;
using UnityEngine;
public class LimitedTimeEvent
{
public int id;
//持续时间分钟
public double duration;
//开始时间
public string startTime;
}
public class FixedTimeEvent
{
public int id;
//结束时间
public string endTime;
}
public struct TargetEvent
{
public TargetEvent(int id, int type, int subType)
{
this.id = id;
this.type = type;
this.subType = subType;
}
public int id;
public int type;
public int subType;
}
public struct ConditionTypeEvent
{
public ConditionTypeEvent(ConditionType conditionType, int count)
{
this.type = conditionType;
this.count = count;
}
public ConditionType type;
public int count;
}
namespace GameCore
{
public partial class FishingEventData : IDisposable
{
private cfg.Tables _tables;
public FishingEventData(cfg.Tables tables)
{
this._tables = tables;
}
Dictionary<int, LimitedTimeEvent> limitedTimeEventDic = new Dictionary<int, LimitedTimeEvent>();
//固定时间开启事件的过期时间
Dictionary<int, FixedTimeEvent> fixedTimeEventDic = new Dictionary<int, FixedTimeEvent>();
public Dictionary<int, FixedTimeEvent> FixedTimeEventDic => fixedTimeEventDic;
private int collectingTargetEventID = -1;
private int virtualCollectingTargetEventID = -1;
private DateTime NewPlayerEvent = DateTime.MinValue;
public CollectingTargetInit collectingTargetInit = null;
public int collectingTargetInitTokenID;
public int collectingTargetInitTaskID;
public bool IsJoinUsPanelOpen = false;
public bool collectingTargetResoure = true;
public bool IsAquariumOpen = false;
public bool IsOpenDrop = false;
public int OpenAquariumID;
public static string NextQueueKey = "CollectingTargetNextQueueKey";
List<int> TargetList;
public CollectingTargetReward collectingTarget = null;
public Queue<CollectingTargetReward> preCollectingTarget = null;
public List<ItemData> targetItemDatas = null;
public List<RankTargets> preRankTarget = null;
public List<ItemData> rankItemDatas = null;
/// <summary>
/// 0:rankEventID -1:isRankSendNotification -4 当前体力膨胀倍率(InflationRate*100)
/// </summary>
public Dictionary<int, int> RankTargetCount = new Dictionary<int, int>();
private FishingEvent rankEvent = null;
public RankInit rankInit = null;
public RankTargets rankTarget = null;
/// <summary>
///-5 当前任务Index
///-4 当前体力膨胀倍率(InflationRate*100)
///-3新手活动过期时间
///-1礼包购买数量
///0rankEventID
///1新手引导数量 FishID :X 倍率 数量 ItemID: 钓鱼数量 TokenID任务目标ID
/// </summary>
Dictionary<int, int> ETDropAfterDropDic = new Dictionary<int, int>();
bool _isTargetGuidance = true;
private FishingEvent turntableEvent;
public WheelInit wheelInit = null;
public WheelLevel wheelLevel = null;
/// <summary>
/// Exp of each lvl. Key "-1" has expire time count.
/// Key "-2" counts the purchase time in "lack of ticket" panel.
/// LYNB.
/// </summary>
public Dictionary<int, int> WheelLevelCount = new Dictionary<int, int>();
public int TurntableCoupon { get; private set; }
public int WheelOperateCount;
public int AllWheelOperateCount;
//public Dictionary<string,int> WheelOperateCountDic = new Dictionary<string, int>();
public int freecount;
Dictionary<int, bool> SystemOpen = new Dictionary<int, bool>();
HashSet<int> _unlocked = new HashSet<int>();
//待释放
IDisposable disposable;
public void InitData(Dictionary<string, string> userDatas)
{
InitTurntableRoll(_tables.TbGlobalConfig.InitWheelTicket);
string data_value;
try
{
if (userDatas.TryGetValue("LimitedTimeEventDic", out data_value))
{
var limitedTimeEventDic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, LimitedTimeEvent>>(data_value);
SetLimitedTimeEventDic(limitedTimeEventDic);
}
}
catch (Exception e)
{
Debug.LogError(e);
}
if (userDatas.TryGetValue("FixedTimeEventDic", out data_value))
{
fixedTimeEventDic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, FixedTimeEvent>>(data_value);
}
if (userDatas.TryGetValue("ETDropAfterDropDic", out data_value))
{
ETDropAfterDropDic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
}
if (userDatas.TryGetValue("RankTargetCount", out data_value))
{
RankTargetCount = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
}
if (userDatas.TryGetValue("TurntableRoll", out data_value))
{
InitTurntableRoll(GlobalUtils.TryParseInt(data_value));
}
if (userDatas.TryGetValue("WheelLevelCount", out data_value))
{
WheelLevelCount = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, int>>(data_value);
}
if (userDatas.TryGetValue("WheelOperateCount", out data_value))
{
WheelOperateCount = GlobalUtils.TryParseInt(data_value);
}
if (userDatas.TryGetValue("AllWheelOperateCount", out data_value))
{
AllWheelOperateCount = GlobalUtils.TryParseInt(data_value);
}
if (userDatas.TryGetValue("WheelLevelFreeCount", out data_value))
{
freecount = GlobalUtils.TryParseInt(data_value);
}
// TransitionData 已统一由 EventTokenService 管理,不再本地加载
// if (userDatas.TryGetValue("PVPToken", out data_value))
// {
// PVPToken = GlobalUtils.TryParseInt(data_value);
// }
}
public void SetLimitedTimeEventDic(Dictionary<int, LimitedTimeEvent> _limitedTimeEventDic)
{
limitedTimeEventDic.Clear();
var timer = ZZTimeHelper.UtcNow().UtcNowOffset();
foreach (var limitedTimeEvent in _limitedTimeEventDic)
{
if ((timer - GlobalUtils.TryParseDateTime(limitedTimeEvent.Value.startTime, timer)).TotalMinutes < limitedTimeEvent.Value.duration)
{
limitedTimeEventDic.Add(limitedTimeEvent.Key, limitedTimeEvent.Value);
}
}
}
public void Init()
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.DataList;
foreach (var t in _dataList)
{
switch (t.Type)
{
case 1:
switch (t.SubType)
{
case 3:
GContext.container.Resolve<PlayerShopData>().vipTipforUnlocked = t.ID;
break;
case 4:
GContext.container.Resolve<PlayerShopData>().shopTipforUnlocked = t.ID;
break;
case 5:
break;
case 6:
GContext.container.Resolve<PlayerFishData>().MapTipforUnlocked = t.ID;
break;
case 17:
GContext.container.Resolve<BattlePassDataProvider>().LockTipID = t.ID;
break;
case 18:
GContext.container.Resolve<PlayerData>().OpenGradeID = t.ID;
break;
case 20:
OpenAquariumID = t.ID;
break;
//case 7:
// //杆
// break;
}
break;
//case 2:
// switch (t.SubType)
// {
// case 1:
// break;
// case 2:
// break;
// }
// break;
//case 3:
// switch (t.SubType)
// {
// //case 1:
// // GContext.container.Resolve<AlbumData>().TipforUnlocked = t.ID;
// // break;
// //case 2:
// // break;
// //case 3:
// // break;
// case 4:
// break;
// }
// break;
}
SetEvent(t);
}
foreach (var limitedTimeEvent in limitedTimeEventDic)
{
FishingEvent fishingEvent =
_tables.TbFishingEvent.GetOrDefault(limitedTimeEvent.Key);
if (fishingEvent != null)
{
SetEvent(fishingEvent, false);
}
}
if (disposable == null)
{
disposable = GContext.OnEvent<ConditionTypeEvent>().Subscribe(OnEventDataChange);
}
InitTransitionDataDic();
}
public string GetTipforUnlocked(int id)
{
var t = _tables.TbFishingEvent.GetOrDefault(id);
if (t != null)
{
int conditionCount = t.ConditionList.Count;
if (conditionCount > 1)
{
for (int i = 0; i < conditionCount; i++)
{
if (!GetEventCondition(t.ConditionList[i]))
{
return GetEventConditionString(t.ConditionList[i]);
}
}
}
else
{
return GetEventConditionString(t.ConditionList[0]);
}
}
return "";
}
string GetEventConditionString(EventCondition eventCondition)
{
switch (eventCondition.Condition)
{
case ConditionType.GetFishCount:
int count = int.Parse(eventCondition.Param[0]) - GContext.container.Resolve<PlayerFishData>().GetAnglingCount();
if (count < 0)
{
count = 0;
}
return LocalizationMgr.GetFormatTextValue(eventCondition.TipforUnlocked_l10n_key, count);
case ConditionType.AccountLevel:
return LocalizationMgr.GetFormatTextValue(eventCondition.TipforUnlocked_l10n_key, eventCondition.Param[0]);
default:
return "";
}
}
void OnEventDataChange(ConditionTypeEvent conditionTypeEvent)
{
OnEventDataChange(conditionTypeEvent.type, conditionTypeEvent.count);
}
//事件数据改变
void OnEventDataChange(ConditionType type, int count)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.DataList;
foreach (var t in _dataList)
{
List<EventCondition> ConditionList = t.ConditionList;
for (int i = 0; i < ConditionList.Count; i++)
{
if (ConditionList[i].Condition == type)
{
SetEvent(t);
break;
}
}
}
}
/// <summary>
/// 时间跨天刷新
/// </summary>
public void AllRefresh()
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.DataList;
List<int> systemOpen = new List<int>();
foreach (var t in _dataList)
{
int open = RedirectType(t.Type, t.SubType);
if (t.Type > 1 && !systemOpen.Contains(open))
{
try
{
if (SetEvent(t))
{
systemOpen.Add(open);
}
}
catch (Exception e)
{
Debug.LogError(e);
}
}
}
RefreshEvent();
}
public void RefreshEvent()
{
}
/// <summary>
/// 检查某一类型活动是否开启,并初始化,用于活动到期检查刷新
/// </summary>
/// <param name="type"></param>
/// <param name="subType"></param>
public int GetEventAndInit(int type, int subType)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type, subType);
foreach (var t in _dataList)
{
if (SetEvent(t))
{
return t.ID;
}
}
return -1;
}
/// <summary>
/// 检查某一类型活动是否开启,不初始化
/// </summary>
/// <param name="type"></param>
/// <param name="subType"></param>
/// <returns></returns>
public int GetEvent(int type, int subType)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type, subType);
foreach (var t in _dataList)
{
if (Condition(t))
{
return t.ID;
}
}
return -1;
}
/// <summary>
/// 检查某一类型活动是否开启,不初始化
/// </summary>
/// <param name="type"></param>
/// <param name="subType"></param>
/// <param name="isCheckCondition"></param>
/// <returns></returns>
public int GetEventRedirectID(int type, int subType)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type, subType);
foreach (var t in _dataList)
{
if (Condition(t))
{
return t.RedirectID;
}
}
return -1;
}
/// <summary>
/// 检查某一类型活动是否开启,不初始化
/// </summary>
/// <param name="type"></param>
/// <param name="subType"></param>
/// <param name="isCheckCondition"></param>
/// <returns></returns>
public FishingEvent GetEventByTypeAndSubType(int type, int subType, bool isCheckCondition = true)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type, subType);
foreach (var t in _dataList)
{
if (Condition(t) || !isCheckCondition)
{
return t;
}
}
return null;
}
/// <summary>
/// 检查某一类型活动是否开启,不初始化
/// </summary>
/// <param name="type"></param>
/// <param name="subType"></param>
/// <returns></returns>
public FishingEvent GetEventeByTimType(int type, int subType)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type, subType);
foreach (var t in _dataList)
{
bool isOpen = true;
if (t.TimeDefinition is UserRegistration)
{
UserRegistration userRegistrationEvent = (UserRegistration)t.TimeDefinition;
double time = GContext.container.Resolve<IUserService>().CreateTotalSeconds();
isOpen = userRegistrationEvent.StartTime <= time && time < userRegistrationEvent.EndTime;
}
else if (t.TimeDefinition is FixedTime)
{
isOpen = FixedTimeEventExpired(t.ID);
}
else if (t.TimeDefinition is LimitedTime)
{
LimitedTime limitedTime = (LimitedTime)t.TimeDefinition;
isOpen = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow()) <= ZZTimeHelper.UtcNow() && ZZTimeHelper.UtcNow() < GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow());
}
if (isOpen)
{
return t;
}
}
return null;
}
/// <summary>
/// 获取type开启活动数据并确保活动初始化,用于活动代币转换
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public FishingEvent GetEventTable(int type)
{
List<FishingEvent> _dataList = _tables.TbFishingEvent.GetAllDataByType(type);
foreach (var t in _dataList)
{
if (Condition(t))
{
if (!_unlocked.Contains(t.ID))
{
Debug.Log($"<color=red>Event {t.ID} unlocked</color>");
SetEvent(t, false);
_unlocked.Add(t.ID);
}
return t;
}
}
return null;
}
/// <summary>
/// 刷新活动 条件发生改变持续广播当前条件能开启哪些活动
/// 最好记一下活动ID t.ID,只要ID不同就初始化
/// </summary>
/// <param name="t"></param>
/// <param name="condition"></param>
/// <returns></returns>
bool SetEvent(FishingEvent t, bool condition = true)
{
//Assert.IsTrue(t.ID != 30801002);
//bool b = Condition(t);
//if (t.Type == 3)
// Debug.Log($"<color=red>condition of id: {t.ID} {t.Type} {t.SubType}: {b}</color>");
if (!condition || Condition(t))
{
if (t.TimeDefinition is FixedTime)
{
if (!fixedTimeEventDic.ContainsKey(t.ID))
{
FixedTime fixedTime = (FixedTime)t.TimeDefinition;
fixedTimeEventDic[t.ID] = new FixedTimeEvent()
{
id = t.ID,
endTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(fixedTime.StartTime).ToString(),
};
PlayFabMgr.Instance.UpdateUserDataValue("FixedTimeEventDic", JsonMapper.ToJson(fixedTimeEventDic));
}
}
switch (t.Type)
{
case 1:
SetEvent1(t);
break;
case 2:
SetEvent2(t);
break;
case 3:
SetEvent3(t);
break;
case 4:
// if (t.SubType == 1) //沙滩寻宝
// {
// }
// else if (t.SubType == 3) //鱼缸建造
// {
// // Debug.Log($"<color=red>[EventPartner]Event On, Try load data</color>");
// // data.LoadData(t);
// }
// else if (t.SubType == 5) // 魔药
// {
// }
// else if (t.SubType == 6) // 弹珠
// {
// }
// else if (t.SubType == 7)
// {
// var pfData = EventBingoPlayfabData.Load();
// var ppData = EventBingoPlayerPreferenceData.Load();
// if (bingoModel == null)
// {
// if (pfData == null || pfData.EventId != t.ID)
// {
// // Debug.Log("[EventBingo] Reset bingo.");
// bingoModel.Init(t);
// bingoModel.ToPlayfabData().Save();
// bingoModel.ToPlayerPreferenceData().Save();
// }
// else
// {
// // Debug.Log("[EventBingo] Load bingo.");
// bingoModel.Load(pfData, ppData, t);
// }
// }
// else if (bingoModel.EventId != t.ID)
// {
// bingoModel.Init(t);
// bingoModel.ToPlayfabData().Save();
// bingoModel.ToPlayerPreferenceData().Save();
// }
// else if (pfData == null)
// {
// Debug.LogWarning("[EventBingo] Playfab data empty but model exists.");
// }
// else if (bingoModel.EventId == t.ID && pfData.EventId == t.ID)
// {
// Debug.Log("[EventBingo] Redundant call. Skip.");
// }
// else
// {
// Debug.LogWarning($"[EventBingo] EventId mismatch! event: {t.ID}, pf: {pfData.EventId}, model: {bingoModel.EventId}");
// }
// }
// // else if (t.SubType == 8)
// // {
// // InitPartnerGatherData(t);
// // }
// else if (t.SubType == 11 || t.SubType == 16)
// {
// InitCubeMeltData(t);
// }
// else if (t.SubType == 12)
// {
// }
// else if (t.SubType == 14)
// {
// }
// break;
// case 5:
// if (t.SubType == 1)
// {
// InitSoloData(t);
// }
break;
case 6:
SetEvent6(t);
break;
case 7:
SetEvent7(t);
break;
case 8:
SetEvent8(t);
break;
case 9:
SetEvent9(t);
break;
case 10:
SetEvent10(t);
break;
case 11:
SetEvent11(t);
break;
case 15:
SetEvent15(t);
break;
}
SystemOpen[RedirectType(t.Type, t.SubType)] = true;
GContext.Publish(new TargetEvent(t.ID, t.Type, t.SubType));
return true;
}
return false;
}
public bool FixedTimeEventExpired(int eventId)
{
if (fixedTimeEventDic.TryGetValue(eventId, out FixedTimeEvent fixedTimeEvent))
{
var endTime = GlobalUtils.TryParseDateTime(fixedTimeEvent.endTime, ZZTimeHelper.UtcNow().UtcNowOffset());
return endTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks;
}
return true;
}
public bool Condition(FishingEvent fishingEvent)
{
if (fishingEvent == null)
{
return false;
}
bool isOpen = true;
if (fishingEvent.TimeDefinition is UserRegistration)
{
UserRegistration userRegistrationEvent = (UserRegistration)fishingEvent.TimeDefinition;
double time = GContext.container.Resolve<IUserService>().CreateTotalSeconds();
isOpen = userRegistrationEvent.StartTime <= time && time < userRegistrationEvent.EndTime;
}
else if (fishingEvent.TimeDefinition is FixedTime)
{
isOpen = FixedTimeEventExpired(fishingEvent.ID);
}
else if (fishingEvent.TimeDefinition is LimitedTime)
{
LimitedTime limitedTime = (LimitedTime)fishingEvent.TimeDefinition;
isOpen = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow()) <= ZZTimeHelper.UtcNow() && ZZTimeHelper.UtcNow() < GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow());
}
if (!isOpen)
{
if (fishingEvent.Type == 3 && fishingEvent.SubType == 3 && fishingEvent.TimeDefinition is LimitedTime)
{
if (GetOpenByConditionList(fishingEvent.ConditionList, fishingEvent.ConditionRelation))
{
LimitedTime limitedTime = (LimitedTime)fishingEvent.TimeDefinition;
RankInit rankInit = _tables.TbRankInit.GetOrDefault(fishingEvent.RedirectID);
if (rankInit != null)
{
DateTime endTime = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow().AddMonths(-1)).AddSeconds(rankInit.HoldTime);
if (endTime > ZZTimeHelper.UtcNow())
{
GContext.container.Resolve<LeadboardData>().lastEventRank = rankInit;
GContext.container.Resolve<LeadboardData>().fishingEvent = fishingEvent;
}
}
}
}
return false;
}
//ab测试影响 开启时间不一致 走单独逻辑
// if (fishingEvent.Type == 2 && fishingEvent.SubType == 4)
// {
// return ad.IsOpen(this, fishingEvent, GetEventCondition, Condition_NoRechargeSeconds);
// }
return GetOpenByConditionList(fishingEvent.ConditionList, fishingEvent.ConditionRelation);
}
bool GetOpenByConditionList(List<EventCondition> ConditionList, int ConditionRelation)
{
bool isOpen = false;
int conditionCount = ConditionList.Count;
if (conditionCount > 1)
{
if (ConditionRelation == 0)
{
isOpen = false;
//或
for (int i = 0; i < conditionCount; i++)
{
if (GetEventCondition(ConditionList[i]))
{
isOpen = true;
break;
}
}
}
else
{
isOpen = true;
// 1与
for (int i = 0; i < conditionCount; i++)
{
if (!GetEventCondition(ConditionList[i]))
{
isOpen = false;
break;
}
}
}
}
else
{
isOpen = GetEventCondition(ConditionList[0]);
}
return isOpen;
}
bool GetEventCondition(EventCondition eventCondition)
{
bool isOpen = false;
switch (eventCondition.Condition)
{
case ConditionType.AccountLevel:
isOpen = GContext.container.Resolve<PlayerData>().lv >= int.Parse(eventCondition.Param[0]);
break;
case ConditionType.GetFishCount:
isOpen = GContext.container.Resolve<PlayerFishData>().GetAnglingCount() >= int.Parse(eventCondition.Param[0]);
break;
case ConditionType.RoleCreateTime:
//isOpen = true;
double time = GContext.container.Resolve<IUserService>().CreateTotalSeconds();
isOpen = (time >= int.Parse(eventCondition.Param[0]) * 3600);
break;
case ConditionType.RoleCreateTimeLessThan:
//isOpen = true;
double time1 = GContext.container.Resolve<IUserService>().CreateTotalSeconds();
isOpen = (time1 < int.Parse(eventCondition.Param[0]) * 3600);
break;
case ConditionType.AccountLevelAfterNoEnergy:
isOpen = GContext.container.Resolve<PlayerData>().lv > int.Parse(eventCondition.Param[0]);
break;
case ConditionType.NoRechargeSeconds:
isOpen = Condition_NoRechargeSeconds(int.Parse(eventCondition.Param[0]));
break;
default:
Debug.LogWarning($"Event {eventCondition.Condition} not registered.");
break;
}
return isOpen;
}
private bool Condition_NoRechargeSeconds(int timeSeconds)
{
var lastPaymentStr = PlayFabMgr.Instance.GetLocalData("LastPaymentTime");
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
DateTime endTime = curTime;
if (string.IsNullOrEmpty(lastPaymentStr) || !lastPaymentStr.Contains("__"))
endTime = GContext.container.Resolve<IUserService>().CreateTime.UtcNowOffset();
//else
//{
// var lastPaymentTimeStr = lastPaymentStr.Split('_')?.FirstOrDefault();
// if (string.IsNullOrEmpty(lastPaymentTimeStr)) return false;
// endTime = GlobalUtils.TryParseDateTime(lastPaymentTimeStr, curTime);
//}
var curTimeSceond = new DateTimeOffset(curTime).ToUnixTimeSeconds();
var endTimeSceond = new DateTimeOffset(endTime).ToUnixTimeSeconds();
if (curTimeSceond - endTimeSceond >= timeSeconds)
return true;
return false;
}
public static bool Condition_NoRechargeDay(int timeDay = 7)
{
var lastPaymentStr = PlayFabMgr.Instance.GetLocalData("LastPaymentTime");
if (!string.IsNullOrEmpty(lastPaymentStr) && lastPaymentStr.Contains("__"))
return false;
DateTime curTime = ZZTimeHelper.UtcNow();
DateTime endTime = GContext.container.Resolve<IUserService>().CreateTime;
if ((curTime - endTime).Days < timeDay)
return false;
return true;
}
void SetEvent1(FishingEvent t)
{
switch (t.SubType)
{
case 2:
GContext.container.Resolve<PlayerData>().IsOpenMagnification = true;
break;
case 3:
GContext.container.Resolve<PlayerShopData>().IsVIPOpen = true;
break;
case 4:
GContext.container.Resolve<PlayerShopData>().IsShopOpen = true;
GContext.Publish(new SUnlockDiamondShopEvent { });
break;
case 5:
break;
case 6:
GContext.container.Resolve<PlayerFishData>().IsOpenMap = true;
break;
case 7:
GContext.container.Resolve<PlayerFishData>().IsOpenRod = true;
break;
//case 8:
// GContext.container.Resolve<PlayerFishData>().IsOpenAutoFish = true;
// break;
case 9:
GContext.container.Resolve<PlayerShopData>().IsShopTopOpen = true;
break;
case 10:
GContext.container.Resolve<PlayerShopData>().OpenAdPack();
break;
case 11:
var dataProvider1 = GContext.container.Resolve<FishingBoxDataProvier>();
dataProvider1.IsUnclocked = true;
//var boxCount = dataProvider1.Data.GetBoxTotalCount();
//RedPointManager.Instance.SetRedPointState("Home.FishingBox", boxCount > 0, boxCount);
break;
case 13:
GContext.container.Resolve<PlayerFishData>().IsOpenPiercing = true;
break;
case 14:
GContext.container.Resolve<IInGameMailService>().IsUnlock = true;
break;
//case 15:
// //GContext.container.Resolve<RedeemCodeService>().IsUnlock = true;
// break;
//case 17:
// //GContext.container.Resolve<BattlePassDataProvider>().IsUnlock = true;
// break;
case 18:
GContext.container.Resolve<PlayerData>().OpenGrade = true;
break;
case 19:
IsJoinUsPanelOpen = true;
// Debug.Log("<color=#4d90fe>IsJoinUsPanelOpen True!!!!!!!!!!!</color>");
break;
case 20:
IsAquariumOpen = true;
break;
case 21:
GContext.container.Resolve<LeadboardData>().IsOpenleaderboard = true;
break;
case 22:
IsOpenDrop = true;
break;
}
}
public bool GetSystemOpen(int id)
{
FishingEvent fishingEvent = _tables.TbFishingEvent.GetOrDefault(id);
if (fishingEvent == null)
{
return false;
}
id = RedirectType(fishingEvent.Type, fishingEvent.SubType);
return SystemOpen.TryGetValue(id, out bool isOpen) ? isOpen : false;
}
void SetEvent2(FishingEvent t)
{
switch (t.SubType)
{
case 1:
//七日签到礼包
GContext.container.Resolve<SigninData>().SetDailySignEvent(t);
break;
case 2:
//周任务
//GContext.container.Resolve<TaskData>().SetTaskToWeeklyEvent(t);
break;
case 3:
//GContext.container.Resolve<SigninData>().SetEventSignEvent(t);
break;
}
}
void SetEvent3(FishingEvent t)
{
switch (t.SubType)
{
//case 1:
// GContext.container.Resolve<AlbumData>().SetAlbumEvent(t);
// GContext.container.Resolve<SmallGameData>().AlbumEventID = t.ID;
// break;
case 2:
SetCollectingTargetEvent(t);
break;
case 3:
SetRankEvent(t);
break;
case 4:
//转盘
SetTurntable(t);
break;
case 7:
GContext.container.Resolve<BattlePassData>().RefreshBattlePassRecord(t);
break;
case 8:
case 11:
SetEventPackData(t);
break;
case 9:
// Debug.Log("<color=#23aaf2>Black Friday update data!!</color>");
var d = GContext.container.Resolve<PlayerShopData>().CouponData;
d.UpdateData(t);
if (d.IsActive && d.DoesPop)
{
GContext.container.Resolve<IFaceUIService>()
.AddGiftFaceUIForce(t.ID, UITypes.BlackFridayPopupPanel);
d.DoesPop = false;
}
break;
case 10:
GContext.container.Resolve<PlayerShopData>().AddChainPack(t);
break;
}
}
void SetEvent6(FishingEvent t)
{
switch (t.SubType)
{
case 1:
SetPack1A2(t);
break;
case 2:
// Debug.Log($"<color=#f18c0a>Event Triggered Thanks Giving!</color>");
// if (t.ID != data.EventId)
// data.UpdateData(t);
break;
}
}
private void SetEvent7(FishingEvent e)
{
// switch (e.SubType)
// {
// case 1:
// if (data == null)
// {
// }
// data.UpdateData(e);
// UITypes.EventWinterShootingPanel.SetType(data.MainPanelUrl);
// UITypes.ShootingChainPackPanel.SetType(data.ChainPackPanelUrl);
// UITypes.ShootingRangeFinalRewardPopup.SetType(data.RewardPanelUrl);
// UITypes.ShootingRangeInfoPanel.SetType(data.InfoPanelUrl);
// UITypes.ShootingNormalPackPanel.SetType(data.PackPanelUrl);
// UITypes.ShootingRangeTransitionPanel.SetType(data.TransitionPanelUrl);
// break;
// case 2:
// // Debug.Log($"[EventBreak] Id {e.ID} activated.");
// EventBreakAct.Ctx = EventBreakTableContext.ReadTables(e.ID, GContext.container.Resolve<Tables>());
// if (eventBreakModel == null)
// {
// }
// if (eventBreakModel != null && eventBreakModel.EventId == e.ID)
// return;
// eventBreakModel.Update(e.ID, playfabData);
// var uiData = EventBreakAct.Ctx.GetUIData();
// UITypes.EventBreakPanel.SetType(uiData.MainPanelUrl);
// UITypes.EventBreakInfoPanel.SetType(uiData.InfoPanelUrl);
// UITypes.EventBreakChainPackPanel.SetType(uiData.ChainPackPanelUrl);
// UITypes.EventBreakNormalPackPanel.SetType(uiData.NormalPackPanelUrl);
// UITypes.EventBreakRewardPopupPanel.SetType(uiData.RewardPanelUrl);
// break;
// case 3: // 刮刮乐
// break;
// case 4:
// var ecPpString = PlayerPrefs.GetString(EventCanPlayerPreferenceData.PlayerPrefsKey);
// var ecPlayerPrefsData = EventCanPlayerPreferenceData.Deserialize(ecPpString);
// var tableContext = GContext.container.Resolve<EventCanTableContext>();
// if (tableContext == null)
// {
// GContext.container.Register<EventCanTableContext>().AsSingleton();
// tableContext = GContext.container.Resolve<EventCanTableContext>();
// }
// tableContext.ReadTables(e.ID);
// if (canModel == null || canModel.EventId != e.ID)
// {
// if (canModel == null)
// {
// tableContext.ReadTables(e.ID);
// }
// canModel.InitializeModel(e.ID, ecPlayfabData, ecPlayerPrefsData);
// }
// if (chainPackData == null)
// {
// }
// chainPackData.Init(
// GContext.container.Resolve<EventCanTableContext>().GetPackData(canModel.ChainPackID),
// e.ID, ref canModel.ChainPackProgress);
// break;
// case 5:
// EventGatherCoreAct.Ctx = EventGatherCoreTableContext.ReadTables(e.ID);
// var egcPfData = EventGatherCorePlayfabData.Load();
// if (gatherCoreData == null)
// {
// }
// if (gatherCoreData != null && gatherCoreData.EventId == e.ID)
// return;
// if (egcPfData != null && egcPfData.EventId == e.ID)
// gatherCoreData.LoadData(egcPfData);
// else
// gatherCoreData.InitNew(e.ID);
// var gatherCoreUiData = EventGatherCoreAct.Ctx.GetUiData();
// UITypes.EventGatherCorePanel.SetType(gatherCoreUiData.MainPanelUrl);
// UITypes.EventGatherCoreInfoPanel.SetType(gatherCoreUiData.InfoPanelUrl);
// UITypes.EventGatherCoreChainPackPanel.SetType(gatherCoreUiData.ChainPackPanelUrl);
// UITypes.EventGatherCoreNormalPackPanel.SetType(gatherCoreUiData.NormalPackPanelUrl);
// UITypes.EventGatherCoreRewardPopupPanel.SetType(gatherCoreUiData.RewardPopupPanelUrl);
// break;
// case 6:
// break;
// case 10: // 砸罐子
// {
// var smashMain = _tables.TbEventSmashMain.GetOrDefault(e.RedirectID);
// if (smashMain != null && smashMain.BattlePassId > 0)
// {
// }
// }
// break;
// }
}
void SetEvent8(FishingEvent t)
{
// switch (t.SubType)
// {
// case 2:
// SetTurntable(t);
// break;
// case 3:
// var pfString = PlayFabMgr.Instance.GetLocalData(EventLuckMagicPlayfabData.Key);
// var pfData = EventLuckMagicPlayfabData.Deserialize(pfString);
// var ppString = PlayerPrefs.GetString(EventLuckMagicPlayerPreferenceData.Key);
// var ppData = EventLuckMagicPlayerPreferenceData.Deserialize(ppString);
//
// EventLuckMagicAct.TableContext = EventLuckMagicTableContext.ReadTables(t.ID);
// if (eventLuckMagicModel == null)
// {
// if (pfData == null || pfData.EventId != t.ID)
// eventLuckMagicModel.InitNew(t.ID);
// else
// eventLuckMagicModel.Load(pfData, ppData);
// }
// else if (eventLuckMagicModel.EventId != t.ID)
// {
// // Here, I'll assume that playfab data is consistent with the model in memory.
// eventLuckMagicModel.InitNew(t.ID);
// }
// else
// {
// //In this situation, this is a redundant call.
// }
// EventLuckMagicAct.System = new EventLuckMagicSystem();
// var uiUrls = EventLuckMagicAct.TableContext.GetUiPanelUrls();
// UITypes.EventLuckMagicTriplePackPanel.SetType(uiUrls.TriplePackPanelUrl);
// break;
// case 4:
// break;
// }
}
/// <summary>
/// 9-1 小战令
/// 9-5 offer journey
/// 9-6 小马礼包
/// </summary>
/// <param name="t"></param>
void SetEvent9(FishingEvent t)
{
// if (t.SubType == 4)
// {
// }
// else if (t.SubType == 5)
// {
// var playerData = GContext.container.Resolve<PlayerData>();
// var eventOfferJourneyLvlTriggerTableContext = new EventOfferJourneyLvlTriggerTableContext();
// var pfData = EventOfferJourneyLvlTriggerPlayfabData.Load();
// if (eventOfferJourneyLvlTriggerTableContext.IsEventActive &&
// (pfData == null || pfData.RoundCount < eventOfferJourneyLvlTriggerTableContext.MaxRoundCount))
// {
// Debug.Log("[EventOfferJourney] Normal event suppressed. TriggerPack On the way.");
// return;
// }
// else if (offerJourneyData == null)
// {
// if (!offerJourneyData.LoadDataFromPlayfab() || offerJourneyData.EventId != t.ID)
// {
// }
// GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.EventOfferJourneyPanel, 0);
// }
// else if (offerJourneyData.EventId != t.ID)
// {
// offerJourneyDataActual.Init(t.ID, playerData.PriceLv);
// else
// {
// }
// GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.EventOfferJourneyPanel, 0);
// }
// else
// {
// Debug.Log("[EventOfferJourney] Redundant call, ignore.");
// }
// var uiData = offerJourneyData.GetUiData();
// UITypes.EventOfferJourneyPanel.SetType(uiData.PanelUrl);
// UITypes.EventOfferJourneyInfoPanel.SetType(uiData.InfoPanelUrl);
// }
// else if (t.SubType == 6)
// {
// }
// else if (t.SubType == 7)
// {
// }
// else if (t.SubType == 8)
// {
// }
// else if (t.SubType == 11)
// {
// }
// else if (t.SubType == 1 || t.SubType == 2 || t.SubType == 3)
// {
// }
// else if (t.SubType == 9)
// {
// }
}
void SetEvent10(FishingEvent t)
{
}
void SetEvent11(FishingEvent t)
{
// switch (t.SubType)
// {
// case 1:
// break;
// }
}
private void InitPartnerGatherData(FishingEvent fishingEvent)
{
// manager.UpdateEventData(fishingEvent);
// EventPartnerStatueTokenExchangeData.Load(fishingEvent);
}
public void InitCubeMeltData(FishingEvent fishingEvent)
{
}
public void SetRankEvent(FishingEvent t)
{
rankEvent = t;
if (!RankTargetCount.ContainsKey(0))
{
RankTargetCount[0] = 0;
}
if (rankInit == null || RankTargetCount[0] != rankEvent.ID)
{
rankInit = _tables.TbRankInit.GetOrDefault(rankEvent.RedirectID);
InitRankTarget();
//GContext.Publish(new TargetEvent(rankInit.ID, 3, 3));
}
}
void SetTurntable(FishingEvent t)
{
turntableEvent = t;
if (!WheelLevelCount.ContainsKey(0))
{
WheelLevelCount[0] = 0;
}
if (wheelInit == null || WheelLevelCount[0] != t.ID)
{
wheelInit = _tables.TbWheelInit.GetOrDefault(t.RedirectID);
InitWheelLevel();
}
//GContext.Publish(new TargetEvent(wheelInit.ID, 3, 4));
}
public void InitTurntableRoll(int value)
{
TurntableCoupon = value;
}
public void AddTurntableCoupon(int value)
{
TurntableCoupon = TurntableCoupon + value;
if (turntableEvent != null)
{
SaveTransitionData(turntableEvent.ID, TurntableCoupon);
}
TurntableRed();
PlayFabMgr.Instance.UpdateUserDataValue("TurntableRoll", TurntableCoupon.ToString());
}
public void RewardTurntableRoll(int value, bool remote = true)
{
GContext.Publish(new ConditionTypeEvent { type = ConditionType.ConusumeTicketCount, count = value });
//Debug.Log($"Consume {value}");
TurntableCoupon = TurntableCoupon - value;
if (turntableEvent != null)
SaveTransitionData(turntableEvent.ID, TurntableCoupon);
TurntableRed();
#if AGG
using (var e = GEvent.GameEvent("item_change", gaSend: true))
{
e.AddContent("item_id", 1004)
.AddContent("state_info", "cost")
.AddContent("change_num", value);
}
#endif
PlayFabMgr.Instance.UpdateUserDataValue("TurntableRoll", TurntableCoupon.ToString(), remote);
}
public void TurntableRed()
{
int CostNumber = 10;
if (wheelLevel != null)
{
CostNumber = wheelLevel.CostNumber;
}
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Turntable, TurntableCoupon >= 10 && TurntableCoupon >= CostNumber);
}
public void GMSetEvent(int eventId)
{
FishingEvent fishingEvent = _tables.TbFishingEvent.GetOrDefault(eventId);
if (fishingEvent == null)
{
return;
}
switch (fishingEvent.Type)
{
case 1:
SetEvent1(fishingEvent);
SystemOpen[RedirectType(fishingEvent.Type, fishingEvent.SubType)] = true;
break;
case 3:
case 4:
if (fishingEvent.TimeDefinition is LimitedTime)
{
LimitedTime limitedTime = (LimitedTime)fishingEvent.TimeDefinition;
limitedTimeEventDic[eventId] = new LimitedTimeEvent()
{
id = eventId,
duration = (GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow()) - GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow())).TotalMinutes,
startTime = ZZTimeHelper.UtcNow().UtcNowOffset().ToString("yyyy-MM-dd HH:mm:ss")
};
}
else if (fishingEvent.TimeDefinition is FixedTime)
{
FixedTime fixedTime = (FixedTime)fishingEvent.TimeDefinition;
limitedTimeEventDic[eventId] = new LimitedTimeEvent()
{
id = eventId,
duration = fixedTime.StartTime / 60,
startTime = ZZTimeHelper.UtcNow().UtcNowOffset().ToString("yyyy-MM-dd HH:mm:ss")
};
}
//保存到PlayFab
SetLimitedTimeEventDic();
if (fishingEvent.Type == 3)
{
SetEvent3(fishingEvent);
}
else if (fishingEvent.Type == 4)
{
if (fishingEvent.SubType == 5)
{
}
else if (fishingEvent.SubType == 6)
{
}
}
else if (fishingEvent.Type == 6)
{
SetEvent6(fishingEvent);
}
SystemOpen[RedirectType(fishingEvent.Type, fishingEvent.SubType)] = true;
break;
case 7:
if (fishingEvent.SubType == 3)
{
}
break;
}
GContext.Publish(new TargetEvent(eventId, fishingEvent.Type, fishingEvent.SubType));
}
void SetLimitedTimeEventDic()
{
PlayFabMgr.Instance.UpdateUserDataValue("LimitedTimeEventDic", Newtonsoft.Json.JsonConvert.SerializeObject(limitedTimeEventDic));
}
#region
#region
public float OnFishReward(int mapId, int index, int fishCount)
{
float extraPoint = 0;
if (collectingTargetInit != null)
{
EventTargetExtraDrop eventTargetExtraDrop = collectingTargetInit.FishingExtraDrop;
int itemId = 0;
if (eventTargetExtraDrop is ETKeepsake)
{
var eTKeepsake = eventTargetExtraDrop as ETKeepsake;
itemId = eTKeepsake.FishIDList[index];
if (index == 0)
{
int curHour = ZZTimeHelper.UtcNow().UtcNowOffset().Hour;
if (curHour >= 16)
{
curHour = 16;
}
else if (curHour >= 8)
{
curHour = 8;
}
else
{
curHour = 0;
}
//每日清空的数据
GContext.container.Resolve<PlayerShopData>().AddShopPackDailyBuyCount("CTFishID0" + curHour);
}
}
else if (eventTargetExtraDrop is ETNewItem)
{
var etNewItem = eventTargetExtraDrop as ETNewItem;
itemId = etNewItem.NewItemID[index];
}
if (itemId > 0)
{
var itemToFishID = _tables.TbItem[itemId].RedirectID;
if (ETDropAfterDropDic.ContainsKey(itemToFishID))
{
ETDropAfterDropDic[itemToFishID] += fishCount;
ETDropAfterDropDic[itemId]++;
}
else
{
ETDropAfterDropDic.Add(itemId, 1);
ETDropAfterDropDic.Add(itemToFishID, fishCount);
}
SaveCollectingTargetEvent();
extraPoint += GContext.container.Resolve<BuffDataCenter>().GetCollectionTargetExtraPointBuffValue(mapId);
}
}
return extraPoint;
}
void SaveCollectingTargetEvent()
{
GContext.container.Resolve<PlayerData>().SavePlayerData();
//PlayFabMgr.Instance.UpdateUserDataValue("ETDropAfterDropDic", JsonMapper.ToJson(ETDropAfterDropDic));
}
public string CTSerialize()
{
if (ETDropAfterDropDic.Count > 0)
{
return ETDropAfterDropDic.Select(kv => kv.Key + ":" + kv.Value).Aggregate((a, b) => a + "," + b);
}
else
{
return "";
}
}
public void CTDeserialize(string data)
{
if (!string.IsNullOrEmpty(data))
{
ETDropAfterDropDic.Clear();
var pairs = data.Split(',');
foreach (var pair in pairs)
{
var kv = pair.Split(':');
if (kv.Length == 2 && int.TryParse(kv[0], out int key) && int.TryParse(kv[1], out int value))
{
ETDropAfterDropDic[key] = value;
}
}
}
}
#endregion
void SetCollectingTargetEvent(FishingEvent t)
{
// int idOffset = _mmtService.GetEventTargetIDOffset();
int idOffset = 0;
int RedirectID = t.RedirectID + idOffset;
var curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
//ETDropAfterDropDic.Clear();
if (!ETDropAfterDropDic.ContainsKey(0))
{
//新手活动
NewPlayerEvent = curTime.AddSeconds(_tables.TbGlobalConfig.EventtargetNoviceMinTime);
if (t.TimeDefinition is LimitedTime)
{
LimitedTime limitedTime = (LimitedTime)t.TimeDefinition;
var endTime = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow()).UtcNowOffset();
//下一个目标奖励活动为常规目标奖励活动如果其剩余时间小于1天则时间会被归并到本次目标奖励活动
if (endTime < NewPlayerEvent)
{
endTime = endTime.AddDays(3);
}
if (endTime < curTime.AddSeconds(_tables.TbGlobalConfig.EventtargetNextToNoviceMaxTime))
{
NewPlayerEvent = endTime;
}
}
ETDropAfterDropDic[0] = 0;
ETDropAfterDropDic[-3] = (int)(NewPlayerEvent - new DateTime(2025, 10, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;//存储新手活动结束时间
SaveCollectingTargetEvent();
}
else if (ETDropAfterDropDic.ContainsKey(-3))
{
NewPlayerEvent = new DateTime(2025, 10, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(ETDropAfterDropDic[-3]);
}
if (NewPlayerEvent > curTime)
{
//随便输入一个不存在的ID
collectingTargetEventID = virtualCollectingTargetEventID;
RedirectID = _tables.TbGlobalConfig.EventtargetNoviceID + idOffset;
}
else
{
collectingTargetEventID = t.ID;
}
bool redirectIDChanged = ETDropAfterDropDic.TryGetValue(-6, out var savedRedirectID) && savedRedirectID != RedirectID;
if (collectingTargetInit == null || ETDropAfterDropDic[0] != collectingTargetEventID || redirectIDChanged)
{
//new target event
collectingTargetInit = _tables.TbCollectingTargetInit.GetOrDefault(RedirectID);
if (collectingTargetInit == null && idOffset != 0)
{
Debug.LogError($"CollectingTargetInit not found with MMT offset, fallback: {RedirectID} -> {RedirectID - idOffset}");
RedirectID -= idOffset;
collectingTargetInit = _tables.TbCollectingTargetInit.GetOrDefault(RedirectID);
}
if (collectingTargetInit == null)
{
Debug.LogError($"CollectingTargetInit Error Id == {RedirectID} EventId == {collectingTargetEventID}");
GContext.container.Resolve<BuffDataCenter>().ClearTargetBuff();
collectingTarget = null;
collectingTargetResoure = false;
}
else
{
if (redirectIDChanged)
{
ETDropAfterDropDic.Clear();
ETDropAfterDropDic[0] = 0;
}
collectingTargetResoure = false;
collectingTargetInitTokenID = collectingTargetInit.TokenID;
collectingTargetInitTaskID = collectingTargetInit.TaskID;
InitCollectingTarget();
ETDropAfterDropDic[-6] = RedirectID;
SaveCollectingTargetEvent();
UITypes.FishingTargetPopupPanel.SetType(collectingTargetInit.BgDescPrefab);
}
}
}
public async Task<bool> CheckResourceLoadQueue(string key, List<string> label)
{
if (!collectingTargetResoure)
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
collectingTargetResoure = await loadResourceService.CheckResourceLoadQueue(key, label);
}
return collectingTargetResoure;
}
int requiredCount = 0;
void InitCollectingTarget()
{
if (!ETDropAfterDropDic.ContainsKey(0))
{
ETDropAfterDropDic[0] = 0;
}
//Event Still Launch
if (collectingTargetEventID == ETDropAfterDropDic[0])
{
SetTargetList();
ETDropAfterDropDic.TryGetValue(collectingTargetInitTokenID, out var progress);
while (collectingTarget != null && collectingTarget.NextTarget > 0 && requiredCount <= progress)
{
collectingTarget = _tables.TbCollectingTargetReward.GetOrDefault(collectingTarget.NextTarget);
requiredCount += collectingTarget.TokenRequiredB;
ETDropAfterDropDic.TryGetValue(collectingTargetInitTokenID, out progress);
}
}
//Event Still Launch
else
{
RefreshTargetGuidance();
if (collectingTargetEventID == virtualCollectingTargetEventID)
{
ETDropAfterDropDic[0] = virtualCollectingTargetEventID;
}
else
{
ETDropAfterDropDic.Clear();
ETDropAfterDropDic[0] = collectingTargetEventID;
}
var TargetGroupByHook = collectingTargetInit.TargetGroupByHook;
int hook = GContext.container.Resolve<PlayerData>().Energy;
for (int i = TargetGroupByHook.Count - 1; i >= 0; i--)
{
if (hook >= TargetGroupByHook[i])
{
ETDropAfterDropDic[-5] = i; //记录当前钩子档位
break;
}
}
ETDropAfterDropDic[-4] = (int)(GContext.container.Resolve<PlayerData>().InflationRate * 100);
SetTargetList();
GContext.container.Resolve<BuffDataCenter>().ClearTargetBuff();
}
}
void SetTargetList()
{
TargetList = GetIndexOfCollectingTargetHook();
collectingTarget = _tables.TbCollectingTargetReward.GetOrDefault(TargetList[0]);
requiredCount = collectingTarget.TokenRequiredB;
}
public bool VirtualCollectingTargetEvent => collectingTargetEventID == virtualCollectingTargetEventID;
/// <summary>
/// 特殊鱼,技能新手引导数量
/// </summary>
public bool TargetGuidance(string guidanceName)
{
if (_isTargetGuidance)
{
_isTargetGuidance = false;
int SkillGuidanceRemainings = _tables.TbGlobalConfig.SkillGuidanceRemainings;
if (SkillGuidanceRemainings > (ETDropAfterDropDic.TryGetValue(1, out var progress) ? progress : 0))
{
bool isGuide = GContext.container.Resolve<GuideDataCenter>().TriggerGuide(guidanceName, "FishingPanel_Advanced", true);
if (isGuide)
{
if (!ETDropAfterDropDic.ContainsKey(1))
{
ETDropAfterDropDic[1] = 1;
}
else
{
ETDropAfterDropDic[1]++;
}
SaveCollectingTargetEvent();
}
return isGuide;
}
}
return false;
}
public void RefreshTargetGuidance()
{
_isTargetGuidance = true;
}
public int GetCollectingTargetCount()
{
return ETDropAfterDropDic.TryGetValue(-1, out var progress) ? progress : 0;
}
public void AddCollectingTarget(int progress)
{
if (collectingTarget != null)
{
preCollectingTarget = null;
if (!ETDropAfterDropDic.ContainsKey(collectingTargetInitTokenID))
{
ETDropAfterDropDic[collectingTargetInitTokenID] = 0;
}
//float Enhanced = GContext.container.Resolve<PlayerFishData>().GetDoubleTokenEnhanced();
//if (Enhanced > UnityEngine.Random.value)
//{
// progress += progress;
//}
int _progress;
bool isMax = requiredCount <= (ETDropAfterDropDic.TryGetValue(collectingTargetInitTokenID, out _progress) ? _progress : 0);
GContext.Publish(new TargetAddData(collectingTargetInitTokenID, GetCurCollectingTarget(), progress));
ETDropAfterDropDic[collectingTargetInitTokenID] += progress;
targetItemDatas = null;
if (!isMax && requiredCount <= (ETDropAfterDropDic.TryGetValue(collectingTargetInitTokenID, out _progress) ? _progress : 0))
{
List<int> dropIDs = new List<int>();
preCollectingTarget = new Queue<CollectingTargetReward>();
SetNextCollectingTarget(dropIDs);
var fishingStage = GContext.container.ResolveStage("FishingStage") as FishingStage;
if (fishingStage != null)
{
fishingStage.IsNextQueue = true;
fishingStage.NextQueueKey = NextQueueKey;
}
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
ChangeSource changeSource = new ChangeSource(ETDropAfterDropDic[0], "Event_CollectingTarget", "Event_CollectingTarget", "TaskReward");
targetItemDatas = playerItemData.AddItemByDropListLureInflation(CollectingTargetInflation, dropIDs, changeSource);
if (fishingStage != null)
{
fishingStage.IsNextQueue = false;
fishingStage.NextQueueKey = string.Empty;
}
//时间不同 特殊处理
GContext.Publish(new TargetEvent(collectingTargetInitTaskID, 3, 2));
}
#if AGG
using (var e = GEvent.GameEvent("target_event"))
{
e.AddContent("event_no", collectingTargetInitTaskID)
.AddContent("reward_info", progress)
.AddContent("group_index", ETDropAfterDropDic.GetValueOrDefault(-5))
.AddContent("range_no", collectingTarget.TaskID);
if (targetItemDatas != null)
{
int reward_hook = 0;
int hook_origin = 0;
int reward_cash = 0;
for (int i = 0; i < targetItemDatas.Count; i++)
{
if (targetItemDatas[i].id == 1001)
{
reward_hook += targetItemDatas[i].count;
hook_origin += targetItemDatas[i].origin;
}
else if (targetItemDatas[i].id == 1002)
{
reward_cash += targetItemDatas[i].count;
}
}
e.AddContent("reward_hook", reward_hook)
.AddContent("hook_origin", hook_origin)
.AddContent("reward_cash", reward_cash);
}
}
#endif
SaveCollectingTargetEvent();
}
}
void SetNextCollectingTarget(List<int> dropIDs)
{
//掉落奖励
dropIDs.Add(collectingTarget.DropID); // GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(collectingTarget.DropID);
preCollectingTarget.Enqueue(collectingTarget);
if (collectingTarget.NextTarget <= 0)
{
return;
}
collectingTarget = _tables.TbCollectingTargetReward.GetOrDefault(collectingTarget.NextTarget);
requiredCount += collectingTarget.TokenRequiredB;
if (requiredCount <= ETDropAfterDropDic[collectingTargetInitTokenID])
{
SetNextCollectingTarget(dropIDs);
}
}
public int GetAllCollectingTarget()
{
if (collectingTarget != null)
{
return GetEtDropAfterDropDic(collectingTargetInitTokenID);
}
return 0;
}
public int GetCurCollectingTarget()
{
if (collectingTarget != null)
{
int startNum = 0;
int id = TargetList[0];
CollectingTargetReward localcollectingTarget = _tables.TbCollectingTargetReward.GetOrDefault(id);
if (collectingTarget.TaskID != id)
{
startNum += localcollectingTarget.TokenRequiredB;
ETDropAfterDropDic.TryGetValue(collectingTargetInitTokenID, out var progress);
while (localcollectingTarget != null && startNum <= progress)
{
localcollectingTarget = _tables.TbCollectingTargetReward.GetOrDefault(localcollectingTarget.NextTarget);
if (localcollectingTarget.NextTarget <= 0)
{
if (localcollectingTarget.NextTarget == 0)
{
Debug.LogError("CollectingTargetReward NextTarget == 0");
}
break;
}
startNum += localcollectingTarget.TokenRequiredB;
if (startNum > progress)
{
startNum -= localcollectingTarget.TokenRequiredB;
break;
}
}
}
return GetAllCollectingTarget() - startNum;
}
return 0;
}
public void AddCollectingTarget(int id, int progress)
{
// int idOffset = _mmtService.GetEventTargetIDOffset();
int idOffset = 0;
if (collectingTarget == null || (id != collectingTargetInitTaskID && id + idOffset != collectingTargetInitTaskID))
{
return;
}
AddCollectingTarget(progress);
}
public void GetRankData()
{
if (IsOpenRank())
{
_ = GContext.container.Resolve<LeadboardData>().GetLeaderboard(RankTargetCount[rankInit.TokenID]);
}
if (GContext.container.Resolve<LeadboardData>().IsOpenleaderboard)
{
//GContext.container.Resolve<LeadboardData>().SetLvData();
GContext.container.Resolve<LeadboardData>().GetLevelLeadboardData();
GContext.container.Resolve<LeadboardData>().GetLevelLeadboardData(true);
}
}
public string RTSerialize()
{
if (RankTargetCount.Count > 0)
{
return RankTargetCount.Select(kv => kv.Key + ":" + kv.Value).Aggregate((a, b) => a + "," + b);
}
else
{
return "";
}
}
public void RTDeserialize(string data)
{
if (!string.IsNullOrEmpty(data))
{
RankTargetCount.Clear();
var pairs = data.Split(',');
foreach (var pair in pairs)
{
var kv = pair.Split(':');
if (kv.Length == 2 && int.TryParse(kv[0], out int key) && int.TryParse(kv[1], out int value))
{
RankTargetCount[key] = value;
}
}
}
}
public void AddRankTarget(int progress)
{
if (rankInit != null)
{
preRankTarget = null;
if (!RankTargetCount.ContainsKey(rankInit.TokenID))
{
RankTargetCount[rankInit.TokenID] = 0;
}
GContext.Publish(new TargetAddData(rankInit.TokenID, GetCurRankTarget(), progress));
bool isMax = requiredRankCount <= RankTargetCount[rankInit.TokenID];
RankTargetCount[rankInit.TokenID] += progress;
if (IsOpenRank())
{
GContext.container.Resolve<LeadboardData>().UpdateScore(RankTargetCount[rankInit.TokenID]);
}
GContext.container.Resolve<PlayerData>().SavePlayerData();
//PlayFabMgr.Instance.UpdateUserDataValue("RankTargetCount", JsonMapper.ToJson(RankTargetCount));
rankItemDatas = null;
if (!isMax && requiredRankCount <= RankTargetCount[rankInit.TokenID])
{
List<int> dropIDs = new List<int>();
preRankTarget = new List<RankTargets>();
//掉落奖励
SetNextRankTarget(dropIDs);
ChangeSource changeSource = new ChangeSource(RankTargetCount[0], "Event_Rank", "Event_Rank", "TaskReward");
rankItemDatas = GContext.container.Resolve<PlayerItemData>().AddItemByDropListLureInflation(RankTargetInflation, dropIDs, changeSource);
}
#if AGG
using (var e = GEvent.GameEvent("rank_reward"))
{
e.AddContent("event_no", rankInit.ID)
.AddContent("reward_info", progress)
.AddContent("range_no", rankTarget.TaskID);
if (rankItemDatas != null)
{
int reward_hook = 0;
int hook_origin = 0;
int reward_cash = 0;
for (int i = 0; i < rankItemDatas.Count; i++)
{
if (rankItemDatas[i].id == 1001)
{
reward_hook += rankItemDatas[i].count;
hook_origin += rankItemDatas[i].origin;
}
else if (rankItemDatas[i].id == 1002)
{
reward_cash += rankItemDatas[i].count;
}
}
e.AddContent("reward_hook", reward_hook)
.AddContent("hook_origin", hook_origin)
.AddContent("reward_cash", reward_cash);
}
}
#endif
}
}
void SetNextRankTarget(List<int> dropIDs)
{
preRankTarget.Add(rankTarget);
//掉落奖励
dropIDs.Add(rankTarget.DropID);
if (rankTarget.NextTarget <= 0)
{
return;
}
rankTarget = _tables.TbRankTargets.GetOrDefault(rankTarget.NextTarget);
requiredRankCount += rankTarget.TokenRequiredB;
if (requiredRankCount <= RankTargetCount[rankInit.TokenID])
{
SetNextRankTarget(dropIDs);
}
}
public int GetAllRankTarget()
{
if (rankInit != null)
{
return RankTargetCount.TryGetValue(rankInit.TokenID, out int progress) ? progress : 0;
}
return 0;
}
public int GetCurRankTarget()
{
if (rankInit != null)
{
int startNum = 0;
int id = rankInit.TargetList[0];
RankTargets localRankTarget = _tables.TbRankTargets.GetOrDefault(id);
if (rankTarget.TaskID != id)
{
startNum += localRankTarget.TokenRequiredB;
RankTargetCount.TryGetValue(rankInit.TokenID, out int progress);
while (localRankTarget != null && startNum <= progress)
{
localRankTarget = _tables.TbRankTargets.GetOrDefault(localRankTarget.NextTarget);
if (localRankTarget.NextTarget <= 0)
{
if (localRankTarget.NextTarget == 0)
{
Debug.LogError("RankTargets NextTarget == 0");
}
break;
}
startNum += localRankTarget.TokenRequiredB;
if (startNum > progress)
{
startNum -= localRankTarget.TokenRequiredB;
break;
}
}
}
return GetAllRankTarget() - startNum;
}
return 0;
}
public void AddRankTarget(int id, int progress)
{
if (rankTarget == null || id != rankInit.ID)
{
return;
}
AddRankTarget(progress);
}
/// <summary>
/// 目标奖励活动相关
/// </summary>
/// <param name="id">0==eventID</param>
/// <returns></returns>
public int GetEtDropAfterDropDic(int id)
{
return ETDropAfterDropDic.TryGetValue(id, out int progress) ? progress : 0;
}
public List<int> GetIndexOfCollectingTargetHook()
{
int index = ETDropAfterDropDic.GetValueOrDefault(-5);
if (index >= collectingTargetInit.TargetList.Count)
{
Debug.LogError("TargetList.Count");
return collectingTargetInit.TargetList[0];
}
return collectingTargetInit.TargetList[index];
}
public float CollectingTargetInflation
{
get
{
return GetEtDropAfterDropDic(-4) / 100f;
}
}
public int GetWheelLevelCount(int id)
{
return WheelLevelCount.TryGetValue(id, out int progress) ? progress : 0;
}
public DateTime GetCollectingTargetEndTime()
{
DateTime endTime = ZZTimeHelper.UtcNow().UtcNowOffset();
if (NewPlayerEvent > endTime)
{
return NewPlayerEvent;
}
return GetEventEndTime(collectingTargetEventID);
}
/// <summary>
/// 统一计算 固定时间段时间计算 真实时间和配置时间全加偏移(其他配置是偏移后的时间)
/// 计算的时候要使用 ZZTimeHelper.UtcNow()).UtcNowOffset() 时间
/// 也可以自己写代码计算结束时间
/// </summary>
/// <param name="eventId"></param>
/// <returns></returns>
public DateTime GetEventEndTime(int eventId)
{
FishingEvent fishingEvent = _tables.TbFishingEvent.GetOrDefault(eventId);
DateTime endTime = ZZTimeHelper.UtcNow().UtcNowOffset();
if (fishingEvent == null)
{
Debug.LogError($"FishingEvent not found for ID: {eventId}");
return endTime;
}
if (fishingEvent.TimeDefinition is LimitedTime)
{
//统一计算 固定时间段时间计算 真实时间和配置时间全加偏移(其他配置是偏移后的时间)
LimitedTime limitedTime = (LimitedTime)fishingEvent.TimeDefinition;
endTime = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow()).UtcNowOffset();
}
else if (fishingEvent.TimeDefinition is FixedTime)
{
if (fixedTimeEventDic.TryGetValue(fishingEvent.ID, out FixedTimeEvent fixedTimeEvent))
{
endTime = GlobalUtils.TryParseDateTime(fixedTimeEvent.endTime, ZZTimeHelper.UtcNow().UtcNowOffset());
}
}
else if (fishingEvent.TimeDefinition is Weekly)
{
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset().Date;
Weekly weekly = (Weekly)fishingEvent.TimeDefinition;
int offfset = (int)dateTime.DayOfWeek - weekly.StartTime;
if (offfset < 0)
{
offfset = -offfset;
}
else
{
offfset = 7 - offfset;
}
endTime = dateTime.AddDays(offfset);
//endTime = GlobalUtils.TryParseDateTime(time, ZZTimeHelper.UtcNow().UtcNowOffset());
}
else if (fishingEvent.TimeDefinition is UserRegistration)
{
UserRegistration userRegistrationEvent = (UserRegistration)fishingEvent.TimeDefinition;
endTime = GContext.container.Resolve<IUserService>().CreateTime.AddSeconds(userRegistrationEvent.EndTime).UtcNowOffset();
}
if (limitedTimeEventDic.TryGetValue(fishingEvent.ID, out LimitedTimeEvent limitedTimeEvent))
{
LimitedTime limitedTime = (LimitedTime)fishingEvent.TimeDefinition;
var timer = ZZTimeHelper.UtcNow();
endTime = GlobalUtils.TryParseDateTime(limitedTimeEvent.startTime, timer.UtcNowOffset())
.Add((GlobalUtils.TryParseDateTime(limitedTime.EndTime, timer) - GlobalUtils.TryParseDateTime(limitedTime.StartTime, timer)));
}
return endTime;
}
//获取掉落的挂件
public EventTargetExtraDrop GetEventTargetExtraDrop()
{
if (collectingTargetInit != null)
{
return collectingTargetInit.FishingExtraDrop;
}
return null;
}
#endregion
#region
int requiredRankCount = 0;
void InitRankTarget()
{
if (!RankTargetCount.ContainsKey(0))
{
RankTargetCount[0] = 0;
}
if (rankInit != null && rankInit.TargetList.Count > 0)
{
rankTarget = _tables.TbRankTargets.GetOrDefault(rankInit.TargetList[0]);
requiredRankCount = rankTarget.TokenRequiredB;
if (rankTarget != null && rankEvent.ID == RankTargetCount[0])
{
RankTargetCount.TryGetValue(rankInit.TokenID, out int progress);
while (rankTarget != null && rankTarget.NextTarget > 0 && requiredRankCount <= progress)
{
rankTarget = _tables.TbRankTargets.GetOrDefault(rankTarget.NextTarget);
requiredRankCount += rankTarget.TokenRequiredB;
RankTargetCount.TryGetValue(rankInit.TokenID, out progress);
}
}
else
{
RankTargetCount.Clear();
RankTargetCount[0] = rankEvent.ID;
RankTargetCount[-4] = (int)(GContext.container.Resolve<PlayerData>().InflationRate * 100);
}
if (!RankTargetCount.ContainsKey(rankInit.TokenID))
{
RankTargetCount[rankInit.TokenID] = 0;
}
LeadboardData leadboardData = GContext.container.Resolve<LeadboardData>();
if (IsOpenRank())
{
leadboardData.UpdateScore(RankTargetCount[rankInit.TokenID]);
}
else
{
leadboardData.rankTarget = null;
leadboardData.GetRewards();
}
}
else
rankTarget = null;
}
public float RankTargetInflation
{
get
{
return (RankTargetCount.TryGetValue(-4, out int progress) ? progress : 0) / 100f;
}
}
public DateTime GetRankEndTime()
{
return GetEventEndTime(rankEvent.ID);
}
public bool IsOpenRank()
{
return (rankTarget != null && rankInit != null && GetAllRankTarget() >= rankInit.UnlockPoint);
}
#endregion
#region
void InitWheelLevel()
{
if (wheelInit != null)
{
if (WheelLevelCount[0] != turntableEvent.ID)
{
int welcome = GetInitWelcomeGift(turntableEvent.ID);
if (WheelLevelCount[0] != 0 || TurntableCoupon < welcome)
{
//不是第一次开启,代币归零
TurntableCoupon = welcome;
}
SaveTransitionData(turntableEvent.ID, TurntableCoupon);
WheelLevelCount.Clear();
WheelLevelCount[0] = turntableEvent.ID;
WheelLevelCount[-2] = 0;
freecount = 0;
wheelLevel = _tables.TbWheelLevel.DataList[0];
UpdateTurnTableData();
}
else
{
int currentKey = WheelLevelCount.Keys.Max();
currentKey = currentKey < 1 ? 1 : currentKey;
wheelLevel = _tables.TbWheelLevel.GetOrDefault(currentKey);
}
if (wheelLevel != null)
{
TurntableRed();
}
}
}
public void UpdateTurnTableData()
{
PlayFabMgr.Instance.UpdateUserDataValue("WheelLevelCount", JsonMapper.ToJson(WheelLevelCount));
PlayFabMgr.Instance.UpdateUserDataValue("WheelLevelFreeCount", freecount.ToString());
}
/// <summary>
/// Add item by dropId and multiplier, or just return that item without giving to player, if doAdd is false.
/// </summary>
/// <param name="dropId">Drop ID.</param>
/// <param name="magnification">Multiplier of item.</param>
/// <param name="doAdd">If true, items will actually be given to player. Otherwise, just resolve item.</param>
/// <returns>Item resolved. Potentially given to player, if doAdd is true.</returns>
public ItemData UpdateWheel(int dropId, int magnification, bool doAdd = true)
{
ItemData itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropId);
itemData.count *= magnification;
if (doAdd)
GContext.container.Resolve<PlayerItemData>().AddItem(itemData, null);
return itemData;
}
public void AddIncreaseScore(int score, int multiplier)
{
IncreaseScore(score * multiplier);
WheelOperateCount++;
PlayFabMgr.Instance.UpdateUserDataValue("WheelOperateCount", WheelOperateCount.ToString());
AllWheelOperateCount += multiplier;
PlayFabMgr.Instance.UpdateUserDataValue("AllWheelOperateCount", AllWheelOperateCount.ToString());
}
public void IncreaseScore(int score)
{
// 获取当前转盘等级和积分进度
int progress = GetWheelLevelCount(wheelLevel.Level);
// 增加对应积分
progress += score;
WheelLevelCount[wheelLevel.Level] = progress;
// 检查是否需要升级
if (progress >= wheelLevel.NextLevelPoint)
{
IncreaseWheelLevel();
}
else
{
PlayFabMgr.Instance.UpdateUserDataValue("WheelLevelCount", JsonMapper.ToJson(WheelLevelCount));
}
}
public void AddFreecount(int count)
{
#if AGG
if (count < 0)
{
using (var e = GEvent.GameEvent("item_change", gaSend: true))
{
e.AddContent("item_id", 6002)
.AddContent("state_info", "cost")
.AddContent("change_num", count);
}
}
#endif
freecount += count;
if (freecount < 0)
{
freecount = 0;
}
PlayFabMgr.Instance.UpdateUserDataValue("WheelLevelFreeCount", freecount.ToString());
}
//转盘等级增加函数
public void IncreaseWheelLevel()
{
if (wheelLevel != null)
{
int progress = GetWheelLevelCount(wheelLevel.Level);
int requiredPoints = wheelLevel.NextLevelPoint;
// 循环检查是否需要升级到多个未来等级
while (wheelLevel.NextLevel > 0 && wheelLevel.NextLevel != wheelLevel.Level && progress >= requiredPoints && requiredPoints != -1)
{
WheelLevelCount[wheelLevel.Level] = wheelLevel.NextLevelPoint;
wheelLevel = _tables.TbWheelLevel.GetOrDefault(wheelLevel.NextLevel);
progress -= requiredPoints;
requiredPoints = wheelLevel.NextLevelPoint;
}
// 更新积分进度
WheelLevelCount[wheelLevel.Level] = progress;
TurntableRed();
PlayFabMgr.Instance.UpdateUserDataValue("WheelLevelCount", JsonMapper.ToJson(WheelLevelCount));
}
}
public DateTime GetTurntableEndTime()
{
return GetEventEndTime(turntableEvent.ID);
}
public bool IsShowTurntable()
{
if (turntableEvent == null)
{
return false;
}
var endTime = DateTime.Parse((turntableEvent.TimeDefinition as LimitedTime).EndTime);
var startTime = DateTime.Parse((turntableEvent.TimeDefinition as LimitedTime).StartTime);
var dateTime = ZZTimeHelper.UtcNow();
return wheelLevel != null
&& endTime > dateTime
&& startTime <= dateTime;
}
#endregion
#region eventPack
//private bool
private void SetEventPackData(FishingEvent t)
{
//Debug.Log("I tried.");
int packType = _tables.TbEventPackManager[t.RedirectID].PackType;
switch (packType)
{
case 1: ActivateThreeChoseOnePack(t); break;
case 2: ActivatePiggyBankPack(t); break;
case 3: ActiavteBargainPack(t); break;
case 6:
SetPack1A1(t);
break;
//case 7:
// SetPack1A2(t);
// break;
default: Debug.Log($"Pack Type {packType} of event {t.ID} unrecognized."); break;
}
}
private void ActivateThreeChoseOnePack(FishingEvent t)
{
var eventPackDataSaved = GContext.container.Resolve<EventPackData>();//pack data to be saved to remote server
var eventPackDataRead = GContext.container.Resolve<Tables>()
.TbEventPackManager.DataMap[t.RedirectID];//pack data read from tables
bool eventUpdated = eventPackDataSaved.UpdateEventData(t);//event is updated only when event changed or user login
if (eventPackDataSaved.PurchaseCount < eventPackDataRead.MaxCount && eventUpdated)
//TODO:change panel according to RedirecctID of current event
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.GiftPopupPanel_9, eventPackDataRead.PackType);
}
private void ActivatePiggyBankPack(FishingEvent t) { }
private void ActiavteBargainPack(FishingEvent t)
{
var eventPackDataSaved = GContext.container.Resolve<BargainPackData>();//pack data to be saved to remote server
//var eventPackDataRead = GContext.container.Resolve<Tables>()
// .TbEventPackManager.DataMap[t.RedirectID];//pack data read from tables
eventPackDataSaved.UpdateData(t);//event is updated only when event changed or user login
}
#endregion
#region
public int curActivateItemId { get; set; }
public int GetActivateItemId()
{
float BasicProb = UnityEngine.Random.Range(0, 1f);
if (BasicProb <= _tables.TbGlobalConfig.CommercialFishParam)
{
try
{
// [REMOVED] PiggyBankPackData deleted
BargainPackData barginPackData = GContext.container.Resolve<BargainPackData>();
if (barginPackData.DoNeedTrigger && barginPackData.IsWithinEventTime)
{
return barginPackData.ActivateItemId;
}
}
catch (Exception e)
{
Debug.LogError($"GetActivateItemId Error: {e.Message}");
return 0;
}
}
return 0;
}
public void AddProgress(int fishTier, int magnification)
{
// [REMOVED] PiggyBankPackData deleted
BargainPackData barginPackData = GContext.container.Resolve<BargainPackData>();
if (barginPackData != null)
{
barginPackData.AddProgress(fishTier, magnification);
}
}
#endregion
public void Dispose()
{
disposable?.Dispose();
disposable = null;
}
#region EventTokenService
public Dictionary<int, TransitionData> curTransitionData { get; private set; } = new Dictionary<int, TransitionData>();
public void SaveTransitionData(int eventId, int count)
{
// if (eventId > 0)
// {
// TokenService.SetToken(eventId, count);
// }
}
public int GetTransitionDataCount(int eventId)
{
// return TokenService.GetTokenCount(eventId);
return 0;
}
void InitTransitionDataDic()
{
// GetTransitionData();
}
int EVENT_END_TIME_EXTEND_DAYS = 9;
void GetTransitionData()
{
// var allTokens = TokenService.GetAllTokens();
// if (allTokens != null && allTokens.Count > 0)
// {
// List<int> removeKeys = new List<int>();
// foreach (var item in allTokens)
// {
// FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(item.Key);
// if (fe != null && (fe.Type == 4 || fe.Type == 8 || fe.Type == 7 || fe.Type == 15) && !Condition(fe))
// {
// int count = item.Value;
// if (count <= 0)
// {
// removeKeys.Add(item.Key);
// continue;
// }
// var timeDefinition = fe.TimeDefinition;
// if (timeDefinition is LimitedTime limitedTime)
// {
// DateTime endTime = DateTime.Parse(limitedTime.EndTime).AddDays(EVENT_END_TIME_EXTEND_DAYS);
// if (endTime < ZZTimeHelper.UtcNow())
// {
// removeKeys.Add(item.Key);
// continue;
// }
// }
// FishingEventCycleItem cycle = _tables.TbFishingEventCycleItem.GetOrDefault(fe.RedirectID);
// if (cycle == null || cycle.EventEndSettlement.Count != 2)
// {
// removeKeys.Add(item.Key);
// continue;
// }
// SetTransitionData(fe.ID, cycle.EventName_l10n_key, cycle.ItemId, cycle.EventEndSettlement);
// }
// }
// if (removeKeys.Count > 0)
// {
// Debug.Log($"GetTransitionData removeKeys Count:{removeKeys.Count} IDs {string.Join(',', removeKeys)}");
// for (int i = 0; i < removeKeys.Count; i++)
// {
// Debug.Log($"GetTransitionData removeKeys :{removeKeys[i]} count : {allTokens.GetValueOrDefault(removeKeys[i], 0)}");
// }
// TokenService.ClearTokens(removeKeys);
// }
// }
}
void SetTransitionData(int eventID, string eventName, int itemId, List<int> EventEndSettlement)
{
TransitionData transitionData = new TransitionData();
// int sourceCount = TokenService.GetTokenCount(eventID);
int sourceCount = 0;
transitionData.eventID = eventID;
transitionData.eventName = eventName;
transitionData.sourceItemID = itemId;
transitionData.sourceCount = sourceCount;
transitionData.targetItemID = EventEndSettlement[0];
int targetCount = sourceCount * EventEndSettlement[1];
if (transitionData.targetItemID == 1002)
{
targetCount = GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(targetCount);
}
if (targetCount < 0)
{
targetCount = int.MaxValue;
Debug.LogError($"TransitionData targetCount overflow {eventID} {itemId} {transitionData.sourceCount} {EventEndSettlement[1]}");
}
transitionData.targetCount = targetCount;
curTransitionData[eventID] = transitionData;
GContext.container.Resolve<IFaceUIService>().AddFaceCustomUIData(UITypes.EventConvertedPopupPanel, true);
}
public void ClearTransitionData(TransitionData transitionData)
{
curTransitionData.Remove(transitionData.eventID);
// if (TokenService.GetTokenCount(transitionData.eventID) > 0)
// {
#if AGG
using (var e = GEvent.GameEvent("cycle_item_redemption"))
{
e.AddContent("event_id", transitionData.eventID)
.AddContent("charge_count", GContext.container.Resolve<PlayerShopData>().GetBuyPaymentAmount())
.AddContent("item_id", transitionData.sourceItemID)
.AddContent("item_count", transitionData.sourceCount)
.AddContent("change_item", transitionData.targetItemID)
.AddContent("change_count", transitionData.targetCount);
}
#endif
// TokenService.ClearToken(transitionData.eventID);
// }
}
public int GetInitWelcomeGift(int eventID)
{
int welcomeGift = 0;
if (eventID > 0)
{
FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(eventID);
if (fe != null)
{
FishingEventCycleItem cycle = _tables.TbFishingEventCycleItem.GetOrDefault(fe.RedirectID);
if (cycle != null)
{
welcomeGift = cycle.WelcomeGift;
}
}
}
return welcomeGift;
}
#endregion
#region
public void OnBuyEventPack(int eventID)
{
FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(eventID);
if (fe != null && fe.TimeDefinition is LimitedTime &&
(DateTime.Parse((fe.TimeDefinition as LimitedTime).EndTime) - ZZTimeHelper.UtcNow()).TotalSeconds > 1)
{
if (fe.Type == 3)
{
if (fe.SubType == 8 || fe.SubType == 11)
{
int packType = _tables.TbEventPackManager[fe.RedirectID].PackType;
switch (packType)
{
case 1:
GContext.container.Resolve<EventPackData>().AddPurchaceCount();
break;
case 2:
break;
case 3:
GContext.container.Resolve<BargainPackData>().AddPurchase();
break;
case 6:
SetPack1A1Index(1);
break;
}
}
else if (fe.SubType == 10)
{
GContext.container.Resolve<PlayerShopData>().AddOpenChainGifIndex();
}
}
else if (fe.Type == 4)
{
}
else if (fe.Type == 6)
{
if (fe.SubType == 1)
{
SetPack1A2Index();
RedPointManager.Instance.SetRedPointState(HomeBtnOneTwoPack.redKey, false);
}
else if (fe.SubType == 2)
{
}
}
else if (fe.Type == 7)
{
// switch (fe.SubType)
// {
// case 1:
// if (!shootingPackData.IsChainPackDepleted)
// shootingPackData.OnBuySuccess();
// break;
// case 2:
// if (!breakPackData.IsChainPackDepleted)
// breakPackData.OnBuySuccess();
// break;
// case 3:
// if (ScratchTicketData != null && !ScratchTicketData.IsChainPackDepleted)
// ScratchTicketData.OnBuySuccess();
// break;
// case 4:
// if (chainPackData != null && !chainPackData.IsChainPackDepleted)
// chainPackData.OnBuySuccess();
// break;
// case 5:
// if (gatherCoreData != null)
// {
// var gatherCoreChainData = gatherCoreData.ToChainPackData();
// if (gatherCoreChainData?.IsChainPackDepleted == false)
// gatherCoreChainData.OnBuySuccess();
// }
// break;
// case 6:
// break;
// }
}
else if (fe.Type == 8)
{
// switch (fe.SubType)
// {
// case 3:
// if (luckMagicChainPackData != null && !luckMagicChainPackData.IsChainPackDepleted)
// luckMagicChainPackData.OnBuySuccess();
// break;
// }
}
else if (fe.Type == 9)
{
switch (fe.SubType)
{
// case 4:
// actManager?.OnBuySuccess();
// break;
// case 5:
// break;
// case 7:
// break;
// case 9:
// break;
// case 11:
// break;
}
}
GContext.Publish(new TargetEvent(fe.ID, fe.Type, fe.SubType));
}
}
#endregion
void SetEvent15(FishingEvent t)
{
// if (t.Type != 15)
// return;
// switch (t.SubType)
{
// case 1:
// InitPartnerGatherData(t);
// break;
// case 2:
//
// EventPartnerStatueTokenExchangeData.Load(t);
// break;
}
}
int RedirectType(int type, int subType)
{
return type * 1000 + subType;
}
}
}
public struct TransitionData
{
public int eventID;
public string eventName;
public int sourceItemID;
public int sourceCount;
public int targetItemID;
public int targetCount;
}