备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using UniRx;
public class AchievementData
{
public int Id;
public ulong Target;
public int day;
}
public class AchievementDataManager : IDisposable
{
Tables _tables;
//待释放
IDisposable disposable;
public bool IsOpen;
Dictionary<ConditionType, AchievementData> _achievementDatas = new Dictionary<ConditionType, AchievementData>();
public AchievementDataManager(Tables tables)
{
_tables = tables;
}
public void LoadAchievementData(string value)
{
_achievementDatas = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<ConditionType, AchievementData>>(value);
}
public void Init()
{
if (disposable == null)
{
disposable = GContext.OnEvent<ConditionTypeEvent>().Subscribe(UpdateData);
}
}
public ulong GetAchievementDatas(ConditionType type)
{
switch (type)
{
case ConditionType.AllRodLevel:
return (ulong)(GContext.container.Resolve<PlayerFishData>().GetRoodAllLevel() + GContext.container.Resolve<PlayerFishData>().GetRodAllCount());
case ConditionType.AllFishCardLevel:
return (ulong)GContext.container.Resolve<PlayerFishData>().GetAllLevel();
default:
if (_achievementDatas.ContainsKey(type))
{
return _achievementDatas[type].Target;
}
else
{
return 0;
}
}
}
void UpdateData(ConditionTypeEvent condition)
{
//GetFishWeight
ConditionType type = condition.type;
List<Statistics> stats = _tables.TbStatistics.DataList;
foreach (var item in stats)
{
if (type == item.ConditionType)
{
int day = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear;
ulong count = (ulong)condition.count;
if (_achievementDatas.ContainsKey(type))
{
if (type == ConditionType.LoginDays && _achievementDatas[type].day == day)
{
return;
}
switch (type)
{
case ConditionType.LoginDays:
if (_achievementDatas[type].day == day)
{
return;
}
else
{
_achievementDatas[type].Target++;
}
break;
case ConditionType.MaxCashFromFishing:
case ConditionType.MaxCashFromBomb:
case ConditionType.MaxCashFromHeist:
case ConditionType.AllRodLevel:
case ConditionType.AllFishCardLevel:
if (count > _achievementDatas[type].Target)
{
_achievementDatas[type].Target = count;
}
break;
default:
_achievementDatas[type].Target += count;
break;
}
_achievementDatas[type].day = day;
}
else
{
_achievementDatas[type] = new AchievementData() { day = day, Id = item.Id, Target = count };
}
PlayFabMgr.Instance.UpdateUserDataValue("AchievementData", Newtonsoft.Json.JsonConvert.SerializeObject(_achievementDatas));
return;
}
}
}
public void Dispose()
{
disposable?.Dispose();
disposable = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1008d632e3da56438bb864d1f8f2b1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,250 @@
using asap.core;
using cfg;
using GameCore;
using UnityEngine;
using System;
using game;
using System.Collections.Generic;
public class BargainPackData
{
private readonly Tables _tables = GContext.container.Resolve<Tables>();
private readonly TbEventPackManager _epm = GContext.container.Resolve<Tables>().TbEventPackManager;
private readonly TbSpecialPack _spp = GContext.container.Resolve<Tables>().TbSpecialPack;
private GeneralEventPackData _data;
public int CurrentEventID => _data.currentEventID;
public FishingEvent CurrentEvent => _tables.TbFishingEvent[_data.currentEventID];
public TimeSpan RemainingTime =>
DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).EndTime) -
ZZTimeHelper.UtcNow();
public bool IsWithinEventTime
{
get
{
if (CurrentEventID == 0) return false;
var et = DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).EndTime);
var st = DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).StartTime);
return ZZTimeHelper.UtcNow() >= st && ZZTimeHelper.UtcNow() < et;
}
}
public bool IsPackActivated
{
get
{
bool res = _tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID)
&& _epm.DataMap.ContainsKey(_data.redirectID)
&& _epm[_data.redirectID].PackType == 3
&& IsWithinEventTime
&& _data.isTriggered
&& _data.purchaseCount < _epm[_data.redirectID].MaxCount;
//Debug.Log(_tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID));
//Debug.Log(_epm.DataMap.ContainsKey(_data.redirectID));
//Debug.Log(_epm[_data.redirectID].PackType == 3);
//Debug.Log(IsWithinEventTime);
//Debug.Log(_data.isTriggered);
//Debug.Log(_data.purchaseCount < _epm[_data.redirectID].MaxCount);
return res;
}
}
public int RedirectID => _data.redirectID;
public bool DoNeedTrigger => _data.doNeedTrigger;
public int PackID => _epm[_data.redirectID].VIPPackList[_data.VIPLvlWhenEventActivate][0];
public int DiscountLvlCount => _spp[PackID].IAPID.Count;
public int DiscountLvl => _data.discountLvl;
public int PurchaseCount => _data.purchaseCount;
public int Progress => _data.savingProgress;
public int VIPLvlWhenEventActivated => _data.VIPLvlWhenEventActivate;
public int ActivateItemId => _spp[PackID].ActivateItemId;
public string ActiveItemImg => _spp[PackID].ActiveItemImg;
public int EventItemId => IsPackActivated ? _spp[PackID].EventItemId : 0;
public int RewardDropID => _spp[PackID].DropID[0];
public int MaxCount => _epm[_data.redirectID].MaxCount;
public int NextTarget
{
get
{
int lvl = _data.discountLvl >= DiscountLvlCount - 1 ? DiscountLvlCount - 1 : _data.discountLvl + 1;
return _spp[PackID].EventItemRequire[lvl];
}
}
public bool IsFull => _data.discountLvl >= DiscountLvlCount - 1 && _data.savingProgress >= NextTarget;
public int IAPID => _spp[PackID].IAPID[DiscountLvl];
public List<int> FishingScoreList => _spp[PackID].EventItemGet;
public int NextDiscount
{
get
{
int lvl = _data.discountLvl >= DiscountLvlCount - 1 ? DiscountLvlCount - 1 : _data.discountLvl + 1;
return _spp[PackID].DiscountList[lvl];
}
}
public int VisualProgress => _data.visualProgress;
public int VisualDiscountLvl => _data.visualDiscountLvl;
public int NextVisualTarget
{
get
{
int lvl = _data.visualDiscountLvl >= DiscountLvlCount - 1
? DiscountLvlCount - 1
: _data.visualDiscountLvl + 1;
return _spp[PackID].EventItemRequire[lvl];
}
}
public int NextVisualDiscount
{
get
{
int lvl = _data.visualDiscountLvl >= DiscountLvlCount - 1
? DiscountLvlCount - 1
: _data.visualDiscountLvl + 1;
return _spp[PackID].DiscountList[lvl];
}
}
public void SaveData()
{
//Debug.LogError("Testing, data not saved for debug purpose.");
PlayFabMgr.Instance.UpdateUserDataValue("GeneralEventPackData",
Newtonsoft.Json.JsonConvert.SerializeObject(_data));
}
public void LoadData(GeneralEventPackData data)
{
_data = data;
if (IsPackActivated && IsFull)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(_data.currentEventID,
UITypes.GiftBargainPopupPanel, _epm[RedirectID].PackType, true);
}
}
public void UpdateData(FishingEvent e)
{
if (_epm[_tables.TbFishingEvent[e.ID].RedirectID].PackType != 3)
{
Debug.LogError($"Fishing event ID {e.ID} is not a Bargain back event");
return;
}
if (_data.currentEventID != e.ID)
{
_data = new GeneralEventPackData(
eventID: e.ID,
vip: GContext.container.Resolve<PlayerData>().PriceLv,
redirectID: e.RedirectID,
savingProgress: 0,
discountLvl: 0,
isTriggered: false,
doNeedTrigger: true,
visualProgress: 0,
visualDiscountLvl: 0,
purchaseCount: 0);
}
SaveData();
}
public void TriggerPack()
{
_data.doNeedTrigger = false;
_data.isTriggered = true;
//_data.savingProgress += _spp[PackID].EventItemCountFirst;
AddProgress(_spp[PackID].EventItemCountFirst);
SaveData();
}
public void AddProgress(int progress)
{
if (progress <= 0 || IsFull)
return;
_data.savingProgress += progress;
while (_data.savingProgress >= NextTarget)
{
//DoUICut = true;
_data.savingProgress -= NextTarget;
_data.discountLvl++;
if (_data.discountLvl >= DiscountLvlCount - 1)
{
_data.savingProgress = NextTarget;
break;
}
}
SaveData();
return;
}
public void AddProgress(int fishTier, int magnification)
{
if (!IsPackActivated || fishTier < 1 || fishTier > 5)
{
//Debug.LogError($"Fish Tier {fishTier} not defined in TbSpedialPack");
return;
}
int progress = _spp[PackID].EventItemGet[fishTier - 1] * magnification;
if (progress <= 0 || IsFull)
return;
int curProgress = _data.savingProgress;
_data.savingProgress += progress;
GContext.Publish(new TargetAddData(EventItemId, curProgress, progress));
while (_data.savingProgress >= NextTarget)
{
//DoUICut = true;
_data.savingProgress -= NextTarget;
_data.discountLvl++;
if (_data.discountLvl >= DiscountLvlCount - 1)
{
GContext.container.Resolve<IFaceUIService>()
.AddGiftFaceUI(CurrentEventID, UITypes.GiftBargainPopupPanel, 0, true);
_data.savingProgress = NextTarget;
break;
}
}
SaveData();
return;
}
public void AddPurchase()
{
_data.purchaseCount++;
SaveData();
}
public void RefreshVisualData()
{
_data.visualDiscountLvl = _data.discountLvl;
_data.visualProgress = _data.savingProgress;
SaveData();
}
public int GetNextDiscountTarget(int l)
{
int lvl = l >= DiscountLvlCount - 1 ? DiscountLvlCount - 1 : l + 1;
return _spp[PackID].EventItemRequire[lvl];
}
public int GetNextDiscount(int l)
{
int lvl = l >= DiscountLvlCount - 1 ? DiscountLvlCount - 1 : l + 1;
return _spp[PackID].DiscountList[lvl];
}
}
public class BargainPackProgressEvent
{
public int type; //0: 初始化 1增加动画
public int addProgress;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 391408f221d47ce40a237ad3c6e7b32a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,780 @@
using asap.core;
using cfg;
using game;
using GameCore;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using tysdk;
using UniRx;
using UnityEditor;
using UnityEngine;
public class GetBattlePassRewardEvent
{
public List<int> NormalLevels = new();
public List<int> VipLevels = new();
}
public struct GetAllBPRewards
{
}
public struct BpGetExp
{
}
public struct BpVipUnlock
{
}
public class BattlePassData
{
public BattlePassRecord BattlePassRecord;
public BattleTask BattleTask;
private Tables _tables;
public BattlePassData(Tables tables)
{
if (BattlePassRecord == null)
BattlePassRecord = new BattlePassRecord();
if (BattleTask == null)
BattleTask = new BattleTask();
_tables = tables;
}
#region Load&Save
public void LoadBattlePassRecord(string data)
{
BattlePassRecord = JsonConvert.DeserializeObject<BattlePassRecord>(data);
}
public void LoadBattleTask(string data)
{
BattleTask = JsonConvert.DeserializeObject<BattleTask>(data);
}
public void SaveBattlePassRecord()
{
GContext.container.Resolve<BattlePassDataProvider>().SetRedPoint();
PlayFabMgr.Instance.UpdateUserDataValue("BattlePassRecord", JsonConvert.SerializeObject(BattlePassRecord));
}
public void SaveBattleTask()
{
GContext.container.Resolve<BattlePassDataProvider>().SetRedPoint();
PlayFabMgr.Instance.UpdateUserDataValue("BattleTask", JsonConvert.SerializeObject(BattleTask));
}
#endregion
#region BattlePass
public void RefreshBattlePassRecord(FishingEvent t = null)
{
//没有开启的战令
if (t == null)
{
GContext.container.Resolve<BattlePassDataProvider>().RecordLastBPUnGetDropIDs();
BattlePassRecord.ID = 0;
SaveBattlePassRecord();
return;
}
if (t.ID != BattlePassRecord.ID)
{
GContext.container.Resolve<BattlePassDataProvider>().RecordLastBPUnGetDropIDs();
BattlePassRecord.Init(t.ID);
RefreshDaiyTask();
RefreshWeeklyTask();
SaveBattlePassRecord();
}
}
#endregion
#region Task
public void RefreshDaiyTask()
{
var bpMain = _tables.TbBattlePassMain.GetOrDefault(_tables.TbFishingEvent.GetOrDefault(BattlePassRecord.ID).RedirectID);
if (bpMain != null)
{
BattleTask.DailyTaskEndTime = ConvertTools.GetDateTimeYMD(ZZTimeHelper.UtcNow().UtcNowOffset()).AddDays(1);
var dailyTasks = bpMain.DailyTaskList;
BattleTask.dic_dailyTasks.Clear();
foreach (var task in dailyTasks)
{
BattleTask.dic_dailyTasks.Add(task, 0);
}
}
else
{
BattleTask = new BattleTask();
}
GContext.Publish(new ConditionTypeEvent { type = ConditionType.LoginDays, count = 1 });
SaveBattleTask();
}
public void RefreshWeeklyTask()
{
var bpMain = _tables.TbBattlePassMain.GetOrDefault(_tables.TbFishingEvent.GetOrDefault(BattlePassRecord.ID).RedirectID);
if (bpMain != null)
{
var weeklyTasks = bpMain.WeeklyTaskList;
BattleTask.dic_weeklyTasks.Clear();
foreach (var task in weeklyTasks)
{
BattleTask.dic_weeklyTasks.Add(task, 0);
}
BattleTask.WeeklyTaskEndTime = ConvertTools.GetDateTimeSunDay(ZZTimeHelper.UtcNow().UtcNowOffset()).AddDays(1);
}
//当前没有战令了
else
{
BattleTask = new BattleTask();
}
GContext.Publish(new ConditionTypeEvent { type = ConditionType.LoginDays, count = 1 });
BattleTask.loginDays.Clear();
SaveBattleTask();
}
#endregion
}
public class BattlePassDataProvider : IDisposable
{
#region Fields
public BattlePassData Data;
private PlayerItemData _itemData;
public bool IsUnlock;
public int LockTipID;
public int DefaultBuyLevel
{
get
{
return curPassMain.BuyLevel;
}
}
private Tables _tables;
private Dictionary<int, BattlePassLevel> dic_BPLevel;
public bool IsActivating => IsUnlock && Data.BattlePassRecord.ID != 0;
public bool IsUnlockVip => Data.BattlePassRecord.IsUnlockVip == 1;
CompositeDisposable disposables = new CompositeDisposable();
public BattlePassMain curPassMain
{
get
{
var fishingEvent = _tables.TbFishingEvent.GetOrDefault(Data.BattlePassRecord.ID);
if (fishingEvent == null) { return null; }
return _tables.TbBattlePassMain.GetOrDefault(fishingEvent.RedirectID);
}
}
public BattlePassLevel curPassLevel
{
get
{
if (curPassMain != null)
return dic_BPLevel.GetValueOrDefault(curPassMain.LevelList[Data.BattlePassRecord.Level - 1]);
return null;
}
}
public BattlePassDataProvider(Tables tables, BattlePassData data, PlayerItemData itemData)
{
_tables = tables;
Data = data;
dic_BPLevel = tables.TbBattlePassLevel.DataMap;
_itemData = itemData;
GContext.OnEvent<ConditionTypeEvent>().Subscribe(UpdateTaskData).AddTo(disposables);
}
#endregion
#region Check Func
public void CheckIfRefreshBattblePass()
{
DateTime endTime = GContext.container.Resolve<FishingEventData>().GetEventEndTime(Data.BattlePassRecord.ID);
if (ZZTimeHelper.UtcNow().UtcNowOffset() >= endTime && IsUnlock)
{
RecordLastBPUnGetDropIDs();
Data.RefreshBattlePassRecord();
//GContext.container.Resolve<FishingEventData>().GetEventAndInit(3, 7);
}
}
public void CheckIfRefreshDailyTask()
{
if (ZZTimeHelper.UtcNow().UtcNowOffset() >= Data.BattleTask.DailyTaskEndTime && IsUnlock)
{
Data.RefreshDaiyTask();
}
}
public void CheckIfRefreshWeekTask()
{
if (ZZTimeHelper.UtcNow().UtcNowOffset() >= Data.BattleTask.WeeklyTaskEndTime && IsUnlock)
{
Data.RefreshWeeklyTask();
}
}
public bool CheckIfPopBuyVipPanel()
{
if (Data.BattlePassRecord.BuyVipToastIndex >= curPassMain.RemindLevel.Count)
{
return false;
}
return Data.BattlePassRecord.Level >= curPassMain.RemindLevel[Data.BattlePassRecord.BuyVipToastIndex] && Data.BattlePassRecord.IsUnlockVip == 0;
}
public bool CheckIfGetLastBpRewards()
{
if (LastBpDropIds.Count != 0)
{
var playerData = GContext.container.Resolve<PlayerItemData>();
var itemDatas = playerData.AddItemByDropList(LastBpDropIds.GetRange(1, LastBpDropIds.Count - 1));
#if AGG
using (var e = GEvent.GameEvent("bp_level_reward"))
{
e.AddContent("bp_level", GetBPCurLevel)
.AddContent("drop_id_list", JsonConvert.SerializeObject(LastBpDropIds.GetRange(1, LastBpDropIds.Count - 1)));
if (itemDatas != null && itemDatas.Count > 0)
{
for (int i = 0; i < itemDatas.Count; i++)
{
if (itemDatas[i].id == 1001)
{
e.AddContent("reward_hook", itemDatas[i].count);
}
else if (itemDatas[i].id == 1002)
{
e.AddContent("reward_cash", itemDatas[i].count);
}
}
}
}
#endif
if (LastBpDropIds[0] > 0)
{
#if AGG
using (var e = GEvent.GameEvent("bp_cash_reward"))
{
e.AddContent("bp_level", GetBPCurLevel)
.AddContent("cash_num", LastBpDropIds[0]);
}
#endif
var cash = new ItemData { id = 1002, count = LastBpDropIds[0] };
playerData.AddItem(cash);
GContext.Publish(new ShowData(cash));
}
GContext.Publish(new ShowData(textValue: LocalizationMgr.GetText("UI_BattlePassPanel_25")));
LastBpDropIds.Clear();
Data.SaveBattlePassRecord();
return true;
}
return false;
}
#endregion
#region Get Func
public TimeSpan GetDailyTaskDuration()
{
return Data.BattleTask.DailyTaskEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
}
public TimeSpan GetWeeklyTaskDuration()
{
return Data.BattleTask.WeeklyTaskEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
}
public int GetBPCurLevel => Data.BattlePassRecord.Level;
public int GetBPNextLevel => Mathf.Clamp(Data.BattlePassRecord.Level + 1, 1, BPMaxLevel);
public int BPMaxLevel => curPassMain.LevelList.Count;
public List<int> LastBpDropIds => Data.BattlePassRecord.LastDropIDs;
public BattlePassLevel GetBPLevel(int level) => dic_BPLevel[curPassMain.LevelList[level - 1]];
public int GetBPCurExp() => Data.BattlePassRecord.Exp;
public int GetNeedExpToLevelUp(int upLevel)
{
var curLevel = Data.BattlePassRecord.Level;
return GetTotalExpFromLevelRange(curLevel, curLevel + upLevel) - Data.BattlePassRecord.Exp;
}
public int GetCashBoxCount()
{
var count = 0;
if (GetBPCurLevel == BPMaxLevel)
count = GetBPCurExp() / 100 * curPassMain.ExpToCash;
return count;
}
/// <summary>
/// Level Up From StartLevel To EndLevel
/// </summary>
/// <param name="startLevel"></param>
/// <param name="endLevel"></param>
/// <returns></returns>
public int GetTotalExpFromLevelRange(int startLevel, int endLevel)
{
var expNeed = 0;
endLevel = endLevel > BPMaxLevel ? BPMaxLevel : endLevel;
for (int i = startLevel; i < endLevel; i++)
{
expNeed += dic_BPLevel[curPassMain.LevelList[i - 1]].Exp;
}
return expNeed;
}
public BPRewardSlot.ESlotState GetSlotState(int level, bool isNormalReward)
{
// if ( !IsUnlockVip&&!isNormalReward )
// return BPRewardSlot.ESlotState.VipLock;
if (Data.BattlePassRecord.Level < level || (!isNormalReward && !IsUnlockVip))
{
return BPRewardSlot.ESlotState.LevelLock;
}
if (isNormalReward)
{
if (Data.BattlePassRecord.NormalRewardGet.Contains(level))
return BPRewardSlot.ESlotState.HasGotReward;
}
else if (Data.BattlePassRecord.VipRewardGet.Contains(level))
return BPRewardSlot.ESlotState.HasGotReward;
return BPRewardSlot.ESlotState.CanGetReward;
}
public void GetAllBpRewards()
{
var playItemData = GContext.container.Resolve<PlayerItemData>();
var dropIds = new List<int>();
for (int i = 1; i <= Data.BattlePassRecord.Level; i++)
{
if (GetSlotState(i, true) == BPRewardSlot.ESlotState.CanGetReward)
{
dropIds.Add(GetSlotDropID(i, true));
SetLevelRewardGet(i, true);
}
}
if (IsUnlockVip)
{
for (int i = 1; i <= Data.BattlePassRecord.Level; i++)
{
if (GetSlotState(i, false) == BPRewardSlot.ESlotState.CanGetReward)
{
dropIds.Add(GetSlotDropID(i, false));
SetLevelRewardGet(i, false);
}
}
}
Data.SaveBattlePassRecord();
var itemDatas = playItemData.AddItemByDropList(dropIds);
#if AGG
using (var e = GEvent.GameEvent("bp_level_reward"))
{
e.AddContent("bp_level", GContext.container.Resolve<BattlePassDataProvider>().GetBPCurLevel)
.AddContent("drop_id_list", JsonConvert.SerializeObject(dropIds));
if (itemDatas != null && itemDatas.Count > 0)
{
for (int i = 0; i < itemDatas.Count; i++)
{
if (itemDatas[i].id == 1001)
{
e.AddContent("reward_hook", itemDatas[i].count);
}
else if (itemDatas[i].id == 1002)
{
e.AddContent("reward_cash", itemDatas[i].count);
}
}
}
}
#endif
}
public int GetAllToGetRewardCount()
{
var count = 0;
for (int i = 1; i <= Data.BattlePassRecord.Level; i++)
{
if (GetSlotState(i, true) == BPRewardSlot.ESlotState.CanGetReward)
{
count++;
}
}
if (IsUnlockVip)
{
for (int i = 1; i <= Data.BattlePassRecord.Level; i++)
{
if (GetSlotState(i, false) == BPRewardSlot.ESlotState.CanGetReward)
{
count++;
}
}
}
return count;
}
public int GetSlotDropID(int level, bool isNormalReward)
{
if (isNormalReward)
{
return curPassMain.FreeRewardList[level - 1];
}
return curPassMain.PrimeRewardList[level - 1];
}
public ItemData GetSlotDropItem(int level, bool isNormalReward)
{
if (isNormalReward)
{
return _itemData.GetItemDataOne(curPassMain.FreeRewardList[level - 1]);
}
return _itemData.GetItemDataOne(curPassMain.PrimeRewardList[level - 1]);
}
public int GetDiamondCostByUpLevel(int upLevel)
{
var needExp = GetNeedExpToLevelUp(upLevel);
if (needExp % 100 > 0)
{
needExp = (needExp / 100 + 1) * 100;
}
return needExp / 100 * curPassMain.ExpPrice;
}
public int GetUpLevelByExp(int exp)
{
exp += Data.BattlePassRecord.Exp;
var curLevel = Data.BattlePassRecord.Level;
var upLevel = 0;
var expNeed = GetNeedExpToLevelUp(upLevel + 1);
while (exp >= expNeed && upLevel + curLevel < BPMaxLevel)
{
expNeed = GetNeedExpToLevelUp(++upLevel + 1);
}
return upLevel;
}
public List<ItemData> GetRewardsByUpLevel(int upLevel, bool isNormal)
{
return GetRewardsByLevelRange(GetBPCurLevel + 1, GetBPCurLevel + upLevel, isNormal);
}
public List<ItemData> GetRewardsByLevelRange(int startLevel, int endLevel, bool isNormal)
{
var curLevel = startLevel;
var maxLevel = BPMaxLevel;
var curPass = curPassMain;
Dictionary<int, int> dic_allRewards = new();
var dic_items = GContext.container.Resolve<Tables>().TbItem.DataMap;
var playerItemData = GContext.container.Resolve<PlayerItemData>();
var rewardList = isNormal ? curPass.FreeRewardList : curPass.PrimeRewardList;
for (int i = curLevel - 1; i < endLevel && i < maxLevel; i++)
{
var curItemData = playerItemData.GetItemDataByDropId(rewardList[i])[0];
if (dic_allRewards.ContainsKey(curItemData.id))
{
dic_allRewards[curItemData.id] += curItemData.count;
}
else
dic_allRewards.Add(curItemData.id, curItemData.count);
}
var rewards = dic_allRewards.OrderByDescending(x => dic_items[x.Key].Quality).Select(x => new ItemData { id = x.Key, count = x.Value }).ToList();
return rewards;
}
public int GetBarsDefaultPos()
{
for (int i = 1; i <= GetBPCurLevel; i++)
{
if (GetSlotState(i, true) == BPRewardSlot.ESlotState.CanGetReward)
return Mathf.Clamp(i - 1, 1, BPMaxLevel - 3);
if (GetSlotState(i, false) == BPRewardSlot.ESlotState.CanGetReward)
return Mathf.Clamp(i - 1, 1, BPMaxLevel - 3);
}
return Mathf.Clamp(GetBPCurLevel - 1, 1, BPMaxLevel - 3);
}
#endregion
#region Set Func
public void RecordLastBPUnGetDropIDs()
{
if (curPassMain == null)
return;
var drops = Data.BattlePassRecord.LastDropIDs;
if (Data.BattlePassRecord.ID == 0 || drops.Count > 0)
return;
drops.Add(GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(GetCashBoxCount()));
for (int i = 1; i <= GetBPCurLevel; i++)
{
if (GetSlotState(i, true) == BPRewardSlot.ESlotState.CanGetReward)
drops.Add(curPassMain.FreeRewardList[i - 1]);
if (GetSlotState(i, false) == BPRewardSlot.ESlotState.CanGetReward)
drops.Add(curPassMain.PrimeRewardList[i - 1]);
}
}
public void SetRedPoint()
{
var flag = 0;
for (int i = 1; i <= GetBPCurLevel; i++)
{
if (GetSlotState(i, false) == BPRewardSlot.ESlotState.CanGetReward || GetSlotState(i, true) == BPRewardSlot.ESlotState.CanGetReward)
{
RedPointManager.Instance.SetRedPointState(RedPointName.Home_BattlePass_Reward, true);
flag = 1;
break;
}
}
if (flag == 0)
RedPointManager.Instance.SetRedPointState(RedPointName.Home_BattlePass_Reward, false);
foreach (var taskInfo in Data.BattleTask.dic_dailyTasks)
{
var task = _tables.TbBattlePassTask.Get(taskInfo.Key);
if (taskInfo.Value >= int.Parse(task.Param[0]))
{
RedPointManager.Instance.SetRedPointState(RedPointName.Home_BattlePass_Task, true);
return;
}
}
foreach (var taskInfo in Data.BattleTask.dic_weeklyTasks)
{
var task = _tables.TbBattlePassTask.Get(taskInfo.Key);
if (taskInfo.Value >= int.Parse(task.Param[0]))
{
RedPointManager.Instance.SetRedPointState(RedPointName.Home_BattlePass_Task, true);
return;
}
}
RedPointManager.Instance.SetRedPointState(RedPointName.Home_BattlePass_Task, false);
}
public void SetVipUnlock()
{
Data.BattlePassRecord.IsUnlockVip = 1;
Data.SaveBattlePassRecord();
}
public void SetLevelRewardGet(int level, bool isNormal)
{
if (isNormal)
{
if (Data.BattlePassRecord.NormalRewardGet.Contains(level))
{
Debug.LogError("Has Get Reward" + level);
return;
}
Data.BattlePassRecord.NormalRewardGet.Add(level);
}
else
{
if (Data.BattlePassRecord.VipRewardGet.Contains(level))
{
Debug.LogError("Has Get Reward" + level);
return;
}
Data.BattlePassRecord.VipRewardGet.Add(level);
}
}
public void SetBPExp(int exp)
{
var curExp = Data.BattlePassRecord.Exp + exp;
//Debug.Log("StartExp:" + Data.BattlePassRecord.Exp);
var upLevel = 0;
var curLevel = GetBPCurLevel;
while (curExp - GetTotalExpFromLevelRange(curLevel, curLevel + upLevel + 1) >= 0 && curLevel + upLevel < BPMaxLevel)
{
upLevel++;
}
Data.BattlePassRecord.Exp = curExp - GetTotalExpFromLevelRange(curLevel, curLevel + upLevel);
Data.BattlePassRecord.Level = curLevel + upLevel;
//Debug.Log("EndExp:" + Data.BattlePassRecord.Exp + "Get:" + exp + " Level" + Data.BattlePassRecord.Level);
Data.SaveBattlePassRecord();
SetRedPoint();
}
public void UpdateVipToastLevel()
{
Data.BattlePassRecord.BuyVipToastIndex++;
Data.SaveBattlePassRecord();
}
void UpdateTaskData(ConditionTypeEvent conditionTypeEvent)
{
if (!IsActivating)
return;
bool isUpdata = false;
var tasks = _tables.TbBattlePassTask;
var curTasks = Data.BattleTask.dic_dailyTasks;
var curTasksId = Data.BattleTask.dic_dailyTasks.Keys.ToList();
//每日任务
foreach (var taskId in curTasksId)
{
var task = tasks.GetOrDefault(taskId);
if (task == null)
continue;
if (task.Type == conditionTypeEvent.type)
{
if (curTasks[taskId] == int.Parse(task.Param[0]) || curTasks[taskId] == -1)
{
continue;
}
if (task.Type == ConditionType.LoginDays && Data.BattleTask.loginDays.Contains((int)ZZTimeHelper.UtcNow().UtcNowOffset().DayOfWeek))
{
continue;
}
curTasks[taskId] += conditionTypeEvent.count;
if (curTasks[taskId] >= int.Parse(task.Param[0]))
{
curTasks[taskId] = int.Parse(task.Param[0]);
}
isUpdata = true;
}
}
curTasks = Data.BattleTask.dic_weeklyTasks;
curTasksId = Data.BattleTask.dic_weeklyTasks.Keys.ToList();
//每周任务
foreach (var taskId in curTasksId)
{
var task = tasks.GetOrDefault(taskId);
if (task == null)
continue;
if (task.Type == conditionTypeEvent.type)
{
if (curTasks[taskId] == int.Parse(task.Param[0]) || curTasks[taskId] == -1)
{
continue;
}
if (task.Type == ConditionType.LoginDays && Data.BattleTask.loginDays.Contains((int)ZZTimeHelper.UtcNow().UtcNowOffset().DayOfWeek))
{
continue;
}
curTasks[taskId] += conditionTypeEvent.count;
if (curTasks[taskId] >= int.Parse(task.Param[0]))
{
curTasks[taskId] = int.Parse(task.Param[0]);
}
isUpdata = true;
}
}
if (isUpdata)
{
if (conditionTypeEvent.type == ConditionType.LoginDays && Data.BattleTask.loginDays.Contains((int)ZZTimeHelper.UtcNow().UtcNowOffset().DayOfWeek))
{
Data.BattleTask.loginDays.Add((int)ZZTimeHelper.UtcNow().UtcNowOffset().DayOfWeek);
}
Data.SaveBattleTask();
}
}
public void SetTaskDone(int taskID, bool isDailyTask)
{
var tasks = isDailyTask ? Data.BattleTask.dic_dailyTasks : Data.BattleTask.dic_weeklyTasks;
tasks[taskID] = -1;
Data.SaveBattleTask();
}
#endregion
public void Dispose()
{
disposables?.Dispose();
disposables = null;
}
}
public class BattlePassRecord
{
public int ID;
public int Level;
public int Exp;
//0:Lock,1:Unlock
public int IsUnlockVip;
public int BuyVipToastIndex;
public List<int> NormalRewardGet;
public List<int> VipRewardGet;
public List<int> LastDropIDs;
public BattlePassRecord()
{
ID = 0;
BuyVipToastIndex = 0;
Level = 1;
NormalRewardGet = new List<int>();
VipRewardGet = new List<int>();
LastDropIDs = new();
}
public void Init(int id)
{
ID = id;
Level = 1;
Exp = 0;
BuyVipToastIndex = 0;
IsUnlockVip = 0;
NormalRewardGet.Clear();
VipRewardGet.Clear();
}
}
public class BattleTask
{
public Dictionary<int, int> dic_dailyTasks;
public Dictionary<int, int> dic_weeklyTasks;
public List<int> loginDays;
public DateTime DailyTaskEndTime;
public DateTime WeeklyTaskEndTime;
public BattleTask()
{
dic_dailyTasks = new Dictionary<int, int>();
dic_weeklyTasks = new Dictionary<int, int>();
loginDays = new List<int>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d38b36e2f5abea54da8cfd6aae2ad142
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,535 @@
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
public class BuffDataCenter
{
private cfg.Tables _tables;
public BuffDataCenter(cfg.Tables tables)
{
this._tables = tables;
}
Dictionary<int, FishBuffTimeData> mapBuffDataList = new Dictionary<int, FishBuffTimeData>();
List<FishBuffTimeData> targetBuffDataList = new List<FishBuffTimeData>();
Dictionary<int, FishBuffTimeData> globalBuffDataList = new Dictionary<int, FishBuffTimeData>();
FishBuffTimeData fishDailyBuff = null;
public List<FishBuffTimeData> showFishBuffIds = new List<FishBuffTimeData>();
public void InitData(Dictionary<string, string> userDatas)
{
if (userDatas.TryGetValue("BuffDataList", out string buffDataStr))
{
InitBuffData(buffDataStr);
}
if (userDatas.TryGetValue("TargetBuffDataList", out string targetBuffDataStr))
{
InitTargetBuffData(targetBuffDataStr);
}
if (userDatas.TryGetValue("FishDailyBuff", out string dailyBuffDataStr))
{
InitDailyBuffData(dailyBuffDataStr);
}
if (userDatas.TryGetValue("GlobalBuffDataList", out string globalBuffDataStr))
{
InitGlobalBuffData(globalBuffDataStr);
}
}
void InitBuffData(string dataStr)
{
mapBuffDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, FishBuffTimeData>>(dataStr);
}
void InitTargetBuffData(string dataStr)
{
targetBuffDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FishBuffTimeData>>(dataStr);
}
void InitDailyBuffData(string dataStr)
{
fishDailyBuff = Newtonsoft.Json.JsonConvert.DeserializeObject<FishBuffTimeData>(dataStr);
}
void InitGlobalBuffData(string dataStr)
{
globalBuffDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<int, FishBuffTimeData>>(dataStr);
}
#region Buff或目标奖励Buff
public FishBuff IsMapBuff(int mapId)
{
if (mapBuffDataList.TryGetValue(mapId, out FishBuffTimeData mapBuffData) && !mapBuffData.isEnd && mapBuffData.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
FishBuff buff = _tables.TbFishBuff.GetOrDefault(mapBuffData.buffID);
return buff;
}
foreach (var item in targetBuffDataList)
{
if (!item.isEnd && item.sourceID == mapId && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
FishBuff buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
return buff;
}
}
return null;
}
public bool IsDarkness(int mapId)
{
if (mapBuffDataList.TryGetValue(mapId, out FishBuffTimeData mapBuffData) && !mapBuffData.isEnd && mapBuffData.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
var buff = _tables.TbFishBuff.GetOrDefault(mapBuffData.buffID);
if (buff.IsDarkness)
{
return true;
}
}
foreach (var item in targetBuffDataList)
{
var buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (!item.isEnd && (item.sourceID == mapId || item.sourceID == 0) && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
if (buff.IsDarkness)
{
return true;
}
}
}
return false;
}
public string GetSceneFx(int mapId)
{
if (mapBuffDataList.TryGetValue(mapId, out FishBuffTimeData mapBuffData) && !mapBuffData.isEnd && mapBuffData.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
var buff = _tables.TbFishBuff.GetOrDefault(mapBuffData.buffID);
if (!string.IsNullOrEmpty(buff.SceneFx))
{
return buff.SceneFx;
}
}
foreach (var item in targetBuffDataList)
{
var buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (!item.isEnd && (item.sourceID == mapId || item.sourceID == 0) && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
if (!string.IsNullOrEmpty(buff.SceneFx))
{
return buff.SceneFx;
}
}
}
return "";
}
//获取某种Buff
public FishBuffTimeData GetBuffData<T>() where T : FishBuffType
{
int curMapId = GContext.container.Resolve<PlayerData>().currentMapId;
foreach (var item in targetBuffDataList)
{
var buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (buff.BuffParam is T && !item.isEnd && (item.sourceID == curMapId || item.sourceID == 0) && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
return item;
}
}
return null;
}
//排行榜活动特殊地图额外积分
public float GetSpMapExtraPointBuffValue()
{
float extraPointValue = 0;
foreach (var item in targetBuffDataList)
{
var buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (buff.BuffParam is SpMapExtraPoint && !item.isEnd && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
SpMapExtraPoint extraPoint = buff.BuffParam as SpMapExtraPoint;
extraPointValue += extraPoint.Param;
}
}
return extraPointValue;
}
#endregion
#region Buff
public bool CheckMapBuff(int mapID)
{
if (mapID != GContext.container.Resolve<PlayerData>().lastMapId)
{
return false;
}
if (!mapBuffDataList.ContainsKey(mapID))
{
var mapdata = _tables.TbMapData.GetOrDefault(mapID);
if (mapdata != null && mapdata.FishBuff > 0)
{
var buffData = _tables.TbFishBuff.GetOrDefault(mapdata.FishBuff);
var mapBuffData = new FishBuffTimeData();
mapBuffData.SortID = buffData.SortID;
mapBuffData.sourceID = mapID;
mapBuffData.buffID = mapdata.FishBuff;
DateTime now = ZZTimeHelper.UtcNow().UtcNowOffset();
mapBuffData.buffEndTime = now.AddSeconds(buffData.CountDown);
mapBuffDataList.Add(mapID, mapBuffData);
PlayFabMgr.Instance.UpdateUserDataValue("BuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(mapBuffDataList));
return true;
}
}
return false;
}
//当前地图的Buff
public FishBuffTimeData GetMapBuffTimeData(int mapId)
{
if (mapBuffDataList.TryGetValue(mapId, out FishBuffTimeData mapBuffData) && !mapBuffData.isEnd && mapBuffData.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
return mapBuffData;
}
return null;
}
//钓鱼金币加成
public float GetExtraGoldBuffValue(int mapId, int fishQuality)
{
float extraGoldValue = 0;
if (mapBuffDataList.TryGetValue(mapId, out FishBuffTimeData mapBuffData) && !mapBuffData.isEnd && mapBuffData.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
var buff = _tables.TbFishBuff.GetOrDefault(mapBuffData.buffID);
if (buff.BuffParam is ExtraGold)
{
ExtraGold extraGold = buff.BuffParam as ExtraGold;
extraGoldValue += extraGold.Param;
}
}
MoreFishingCash moreFishingCash = GetWeelyBuffTimeData<MoreFishingCash>();
if (moreFishingCash != null)
{
for (int i = 0; i < moreFishingCash.Quality.Count; i++)
{
if (fishQuality == moreFishingCash.Quality[i])
{
extraGoldValue += moreFishingCash.Param[i];
}
}
}
return extraGoldValue;
}
#endregion
#region Buff
public void CheckTargetBuff()
{
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
var collectingTargetInit = fishingEventData.collectingTargetInit;
if (collectingTargetInit != null)
{
EventTargetExtraDrop eventTargetExtraDrop = collectingTargetInit.FishingExtraDrop;
ETKeepsake eTKeepsake = null;
if (eventTargetExtraDrop is ETKeepsake)
{
eTKeepsake = eventTargetExtraDrop as ETKeepsake;
}
else
{
return;
}
int buffID = eTKeepsake.FishbuffID;
FishBuff fishBuff = _tables.TbFishBuff.GetOrDefault(buffID);
if (fishBuff != null)
{
FishBuffTimeData fishBuffTimeData = new FishBuffTimeData();
if (fishBuff.IsMapBuff)
{
fishBuffTimeData.sourceID = GContext.container.Resolve<PlayerData>().currentMapId;
}
else
{
fishBuffTimeData.sourceID = 0;
}
fishBuffTimeData.SortID = fishBuff.SortID;
fishBuffTimeData.buffID = fishBuff.ID;
if (fishBuff.CountDown > 0)
{
fishBuffTimeData.buffEndTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(fishBuff.CountDown);
}
else
{
fishBuffTimeData.buffEndTime = fishingEventData.GetCollectingTargetEndTime();
}
for (int i = 0; i < targetBuffDataList.Count; i++)
{
if (targetBuffDataList[i].buffID == fishBuffTimeData.buffID && targetBuffDataList[i].sourceID == fishBuffTimeData.sourceID)
{
targetBuffDataList[i] = fishBuffTimeData;
PlayFabMgr.Instance.UpdateUserDataValue("TargetBuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(targetBuffDataList));
return;
}
}
targetBuffDataList.Add(fishBuffTimeData);
PlayFabMgr.Instance.UpdateUserDataValue("TargetBuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(targetBuffDataList));
}
}
else
{
ClearTargetBuff();
}
}
public void ClearTargetBuff()
{
targetBuffDataList.Clear();
PlayFabMgr.Instance.UpdateUserDataValue("TargetBuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(targetBuffDataList));
}
/// <summary>
/// CollectionTargetWeight的特殊处理
/// </summary>
/// <param name="fishItemId"></param>
public void EndCollectionTargetWeight(int fishItemId)
{
CollectingTargetInit collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
if (collectingTargetInit == null)
{
return;
}
EventTargetExtraDrop eventTargetExtraDrop = collectingTargetInit.FishingExtraDrop;
ETKeepsake eTKeepsake = null;
if (eventTargetExtraDrop is ETKeepsake)
{
eTKeepsake = eventTargetExtraDrop as ETKeepsake;
}
else
{
return;
}
FishBuff fishBuff;
int curMapId = GContext.container.Resolve<PlayerData>().currentMapId;
foreach (var item in targetBuffDataList)
{
fishBuff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (!item.isEnd && (item.sourceID == curMapId || item.sourceID == 0) && fishBuff.BuffParam is CollectionTargetWeight)
{
CollectionTargetWeight collectionTargetWeight = fishBuff.BuffParam as CollectionTargetWeight;
if (collectionTargetWeight.TargetFishIndex < 1 || collectionTargetWeight.TargetFishIndex > eTKeepsake.FishIDList.Count)
{
continue;
}
else if (fishItemId == eTKeepsake.FishIDList[collectionTargetWeight.TargetFishIndex - 1])
{
item.isEnd = true;
PlayFabMgr.Instance.UpdateUserDataValue("TargetBuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(targetBuffDataList));
break;
}
}
}
}
//目标奖励活动额外积分
public float GetCollectionTargetExtraPointBuffValue(int mapId)
{
float extraPointValue = 0;
foreach (var item in targetBuffDataList)
{
var buff = _tables.TbFishBuff.GetOrDefault(item.buffID);
if (buff.BuffParam is CollectionTargetExtraPoint && !item.isEnd && (item.sourceID == mapId || item.sourceID == 0) && item.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
CollectionTargetExtraPoint extraPoint = buff.BuffParam as CollectionTargetExtraPoint;
extraPointValue += extraPoint.Param;
}
}
return extraPointValue;
}
#endregion
#region Buff Item投放
public void SetGlobalBucffNew(int buffID, bool isNew = true)
{
var buff = _tables.TbFishBuff.GetOrDefault(buffID);
if (buff != null)
{
if (globalBuffDataList.TryGetValue(buff.GroupId, out FishBuffTimeData fishBuffTimeData))
{
if (fishBuffTimeData.isNew != isNew)
{
fishBuffTimeData.isNew = isNew;
if (isNew)
{
showFishBuffIds.Add(fishBuffTimeData);
}
else
{
showFishBuffIds.Remove(fishBuffTimeData);
}
}
}
}
}
public void AddGlobalBuff(int buffID)
{
var buff = _tables.TbFishBuff.GetOrDefault(buffID);
if (buff != null)
{
var UtcNow = ZZTimeHelper.UtcNow().UtcNowOffset();
bool isNewBuff = true;
if (globalBuffDataList.TryGetValue(buff.GroupId, out FishBuffTimeData fishBuffTimeData))
{
var oldBuff = _tables.TbFishBuff.GetOrDefault(fishBuffTimeData.buffID);
if (oldBuff.GroupId != buff.GroupId)
{
globalBuffDataList.Remove(buff.GroupId);
}
else
{
isNewBuff = false;
if (fishBuffTimeData.buffEndTime.Ticks > UtcNow.Ticks)
{
fishBuffTimeData.buffEndTime = fishBuffTimeData.buffEndTime.AddSeconds(buff.CountDown);
if (buff.SortID > fishBuffTimeData.SortID)
{
fishBuffTimeData.SortID = buff.SortID;
}
}
else
{
fishBuffTimeData.buffEndTime = UtcNow.AddSeconds(buff.CountDown);
fishBuffTimeData.SortID = buff.SortID;
fishBuffTimeData.isNew = true;
}
fishBuffTimeData.isEnd = false;
showFishBuffIds.Add(fishBuffTimeData);
fishBuffTimeData.addDown = buff.CountDown;
}
}
if (isNewBuff)
{
fishBuffTimeData = new FishBuffTimeData();
if (buff.IsMapBuff)
{
fishBuffTimeData.sourceID = GContext.container.Resolve<PlayerData>().currentMapId;
}
else
{
fishBuffTimeData.sourceID = 0;
}
fishBuffTimeData.buffID = buffID;
if (buff.CountDown > 0)
{
fishBuffTimeData.buffEndTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(buff.CountDown);
}
else
{
fishBuffTimeData.buffEndTime = ZZTimeHelper.UtcNow().UtcNowOffset().AddDays(1);
}
globalBuffDataList[buff.GroupId] = fishBuffTimeData;
fishBuffTimeData.SortID = buff.SortID;
fishBuffTimeData.isNew = true;
fishBuffTimeData.addDown = buff.CountDown;
showFishBuffIds.Add(fishBuffTimeData);
}
PlayFabMgr.Instance.UpdateUserDataValue("GlobalBuffDataList", Newtonsoft.Json.JsonConvert.SerializeObject(globalBuffDataList));
}
}
//GetBuffGroupTimeData
public T GetWeelyBuffTimeData<T>(bool isEnd = false) where T : FishBuffType
{
GetWeelyBuff();
foreach (var item in globalBuffDataList)
{
if (!item.Value.isEnd && item.Value.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
FishBuff buff = _tables.TbFishBuff.GetOrDefault(item.Value.buffID);
if (buff.BuffParam is T)
{
//if (isEnd)
//{
// item.Value.isEnd = true;
//}
return buff.BuffParam as T;
}
}
}
return null;
}
public List<FishBuffTimeData> GetGroupBuff()
{
GetWeelyBuff();
List<FishBuffTimeData> buffList = new List<FishBuffTimeData>();
foreach (var item in globalBuffDataList)
{
if (!item.Value.isEnd && item.Value.buffEndTime.Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks)
{
buffList.Add(item.Value);
}
}
return buffList;
}
#endregion
#region Buff
FishBuffTimeData GetWeelyBuff()
{
DateTime now = ZZTimeHelper.UtcNow().UtcNowOffset();
int week = (int)now.DayOfWeek;
var weelyBuff = _tables.TbWeelyBuffInit.GetOrDefault(week);
if (weelyBuff != null)
{
List<int> dailyBuffList = weelyBuff.DailyBuffList;
int day = now.DayOfYear;
if (fishDailyBuff != null && fishDailyBuff.buffEndTime > now/* && fishDailyBuff.buffEndTime.DayOfYear == day*/)
{
//旧的每日Buff还未结束
return fishDailyBuff;
}
for (int i = 0; i < dailyBuffList.Count; i++)
{
var buff = _tables.TbDailyBuffTrigger.GetOrDefault(dailyBuffList[i]);
if (buff != null)
{
DateTime startTime = now.Date.AddSeconds(buff.StartTime);
DateTime endTime = now.Date.AddSeconds(buff.EndTime);
if (now >= startTime && now <= endTime)
{
//开启新的每日Buff
if (buff.LevelRequired > GContext.container.Resolve<PlayerData>().lv)
{
return null;
}
if (fishDailyBuff == null)
{
fishDailyBuff = new FishBuffTimeData();
}
if (fishDailyBuff.sourceID == buff.Day/* && fishDailyBuff.buffEndTime.DayOfYear == day*/)
{
return null;
}
FishBuff fishBuff = _tables.TbFishBuff.GetOrDefault(buff.BuffID);
fishDailyBuff.buffID = buff.BuffID;
fishDailyBuff.sourceID = buff.Day;
fishDailyBuff.buffEndTime = endTime;
if (fishBuff.CountDown > 0)
{
fishDailyBuff.buffEndTime = now.AddSeconds(fishBuff.CountDown);
}
AddGlobalBuff(buff.BuffID);
fishDailyBuff.isEnd = false;
PlayFabMgr.Instance.UpdateUserDataValue("FishDailyBuff", Newtonsoft.Json.JsonConvert.SerializeObject(fishDailyBuff));
return fishDailyBuff;
}
}
}
}
return null;
}
#endregion
}
public class FishBuffTimeData
{
public int SortID;
public int sourceID;
public int buffID;
public bool isEnd = false;
[NonSerialized]
public bool isNew = false;
[NonSerialized]
public int addDown;
public DateTime buffEndTime;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52ff19b6484fe994298501901693d645
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,447 @@
using System;
using System.Collections.Generic;
using System.Linq;
using asap.core;
using cfg;
using game;
using LitJson;
namespace GameCore
{
public class AlbumData
{
private cfg.Tables _tables;
public AlbumData(cfg.Tables tables)
{
this._tables = tables;
}
public Theme theme;
public int eventId = 0;
public List<Album> albumList = new List<Album>();
public Dictionary<int, int> fishAlbumData = new Dictionary<int, int>();
public List<int> newAlbum = new List<int>();
public Dictionary<int, int> PhotoRequestCountByDay = new Dictionary<int, int>();
List<int> pictureList = new List<int>();
public Dictionary<int, double> exchangeCD = new Dictionary<int, double>();
public int TipforUnlocked;
public void InitGiftToFriendsDay(Dictionary<string, int> _photoRequestCountByDay)
{
if (_photoRequestCountByDay.ContainsKey("-1"))
{
int dayOfYear = _photoRequestCountByDay["-1"];
if (dayOfYear == ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear)
{
PhotoRequestCountByDay = _photoRequestCountByDay.ToDictionary(i => int.Parse(i.Key), i => i.Value);
}
}
}
public void GMAddAll()
{
foreach (var i in pictureList)
{
if (fishAlbumData.ContainsKey(i))
{
fishAlbumData[i] += 1;
}
else
{
fishAlbumData[i] = 1;
newAlbum.Add(i);
}
}
SaveNewAlbumData();
GetAllAlbumReward();
SavePictureProgress();
SetExchangeRed();
}
public void SetAlbumEvent(FishingEvent t)
{
theme = _tables.TbTheme.GetOrDefault(t.RedirectID);
if (theme != null)
{
eventId = t.ID;
if (GContext.container.Resolve<PlayerData>().seasonId != t.RedirectID)
{
GContext.container.Resolve<PlayerData>().seasonId = t.RedirectID;
SetAlubmRed(RedPointName.Home_Album_ID, true);
PlayFabMgr.Instance.UpdateUserDataValue("SeasonId", theme.ID.ToString());
Init();
}
}
}
public void Init()
{
if (theme == null)
{
return;
}
List<int> fishAlbumDataRoot = new List<int> { theme.ID };
foreach (var t in theme.AlbumList)
{
Album album = _tables.TbAlbum[t];
albumList.Add(album);
pictureList.AddRange(album.PictureList);
if (fishAlbumData.ContainsKey(album.ID))
{
fishAlbumDataRoot.Add(album.ID);
}
}
var newAlbumData = fishAlbumData.Where(i => pictureList.Contains(i.Key) || fishAlbumDataRoot.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);
fishAlbumData = newAlbumData;
SetAlubmRed(RedPointName.Home_Album_New, newAlbum.Count > 0);
SetExchangeRed();
}
public bool IsEventStart()
{
return theme != null;
}
public void SetExchangeCd(int index, float cd)
{
exchangeCD[index] = (ZZTimeHelper.UtcNow().UtcNowOffset().AddSeconds(cd) - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
SetExchangeRed();
//保存exchangeCD
PlayFabMgr.Instance.UpdateUserDataValue("PictureExchangeCD", JsonMapper.ToJson(exchangeCD));
}
public void RemoveExchangeCd(int index)
{
if (exchangeCD.ContainsKey(index))
{
exchangeCD.Remove(index);
}
SetExchangeRed();
}
public float GetExchangeCd(int index)
{
if (exchangeCD.TryGetValue(index, out var cd))
{
float endCd = (float)(cd - (ZZTimeHelper.UtcNow().UtcNowOffset() - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
if (endCd <= 0.001)
{
RemoveExchangeCd(index);
}
return endCd;
}
return 0;
}
public int GetAlbumProgress(List<int> ids)
{
int count = 0;
foreach (var id in ids)
{
if (GetPictureProgress(id) > 0)
{
count++;
}
}
return count;
}
void SetExchangeRed()
{
bool isRed = false;
if (theme != null)
{
List<int> exchangeIdList = theme.ExchangeList;
int count = exchangeIdList.Count;
int allCount = GetPictureRepeatCount();
for (int i = 0; i < count; i++)
{
AlbumExchange albumExchange = _tables.GetAlbumExchange(exchangeIdList[i]);
if (GetExchangeCd(i) <= 0.001 && albumExchange.PictureRequired <= GetPictureRepeatCount())
{
isRed = true;
break;
}
}
}
SetAlubmRed(RedPointName.Home_Album_Exchange, isRed);
}
public void AddPictureProgress(int id, int progress)
{
if (fishAlbumData.ContainsKey(id))
{
fishAlbumData[id] += progress;
}
else
{
fishAlbumData[id] = progress;
newAlbum.Add(id);
SaveNewAlbumData();
}
SetExchangeRed();
GetAlbumReward(id);
GetAllAlbumReward();
SavePictureProgress();
}
public void AddPictureProgress(List<int> pictureIDs)
{
int id;
for (int i = 0; i < pictureIDs.Count; i++)
{
id = pictureIDs[i];
if (fishAlbumData.ContainsKey(id))
{
fishAlbumData[id]++;
}
else
{
fishAlbumData[id] = 1;
newAlbum.Add(id);
}
GetAlbumReward(id);
}
SaveNewAlbumData();
SetExchangeRed();
GetAllAlbumReward();
SavePictureProgress();
}
public bool IsNewPicture(int id)
{
return newAlbum.Contains(id);
}
public void RemoveNewPicture(int id)
{
if (newAlbum.Contains(id))
{
newAlbum.Remove(id);
SaveNewAlbumData();
}
SetExchangeRed();
}
//集齐相册奖励
void GetAlbumReward(int id)
{
int count = albumList.Count;
if (count == 0)
{
//GContext.container.Resolve<FishingEventData>().GetEventAndInit(3, 1);
count = albumList.Count;
}
if (theme == null)
{
return;
}
for (int i = 0; i < count; i++)
{
if (albumList[i].PictureList.Contains(id))
{
if (GetPictureProgress(albumList[i].ID) == 0)
{
int fishPictureProgress = 0;
foreach (var t in albumList[i].PictureList)
{
if (GetPictureProgress(t) > 0)
{
fishPictureProgress++;
}
}
if (fishPictureProgress >= albumList[i].PictureList.Count)
{
//领取全部奖励
fishAlbumData[albumList[i].ID] = 1;
List<ItemData> itemDataList = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(albumList[i].CollectionReward);
GContext.container.Resolve<PlayerItemData>().AddItem(itemDataList);
GContext.Publish(new ShowData(itemDataList, RewardType.CollectionAlbum, albumList[i].ID));
}
}
break;
}
}
}
//全部集齐图鉴奖励
void GetAllAlbumReward()
{
int count = albumList.Count;
if (count == 0)
{
//GContext.container.Resolve<FishingEventData>().GetEventAndInit(3, 1);
count = albumList.Count;
}
if (theme == null)
{
return;
}
//当收集完成的时候获得全部奖励
if (GetPictureProgress(theme.ID) == 0 && count > 0)
{
int fishAlbumProgress = 0;
for (int i = 0; i < count; i++)
{
if (GetAlbumProgress(albumList[i].PictureList) >= albumList[i].PictureList.Count)
{
fishAlbumProgress++;
}
}
if (fishAlbumProgress >= count)
{
//领取全部奖励
fishAlbumData[theme.ID] = 1;
//全部图鉴收集完成
List<ItemData> itemDataList = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(theme.CollectionReward);
GContext.container.Resolve<PlayerItemData>().AddItem(itemDataList);
GContext.Publish(new ShowData(itemDataList, RewardType.CollectionAlbum));
}
}
}
public void RemovePictureProgress(int id, int progress)
{
if (fishAlbumData.ContainsKey(id))
{
fishAlbumData[id] -= progress;
}
else
{
fishAlbumData[id] = 0;
}
SavePictureProgress();
}
public void RemovePictureProgress(Dictionary<int, int> selectPicture)
{
foreach (var i in selectPicture)
{
if (fishAlbumData.ContainsKey(i.Value) && fishAlbumData[i.Value] > 0)
{
fishAlbumData[i.Value]--;
}
else
{
fishAlbumData[i.Key] = 0;
}
}
SavePictureProgress();
}
public int GetPictureProgress(int id)
{
if (fishAlbumData.ContainsKey(id))
{
return fishAlbumData[id];
}
else
{
return 0;
}
}
//重复卡片数量
public int GetPictureRepeatCount()
{
cfg.Picture picture;
int allCount = 0;
foreach (var i in fishAlbumData)
{
if (i.Value > 1)
{
picture = _tables.TbPicture[i.Key];
if (picture.IsTradable)
{
allCount += i.Value - 1;
}
}
}
return allCount;
}
public List<cfg.Picture> GetPictureRepeatList()
{
cfg.Picture picture;
List<cfg.Picture> pictureList = new List<cfg.Picture>();
foreach (var i in fishAlbumData)
{
if (i.Value > 1)
{
picture = _tables.TbPicture[i.Key];
if (picture.IsTradable)
{
pictureList.Add(picture);
}
}
}
return pictureList;
}
public int SetPhotoRequestCountByDay(int id = 0)
{
int dayOfYear = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear;
if (PhotoRequestCountByDay.TryGetValue(-1, out int day))
{
if (day != dayOfYear)
{
PhotoRequestCountByDay.Clear();
}
}
PhotoRequestCountByDay[-1] = dayOfYear;
if (!PhotoRequestCountByDay.ContainsKey(id))
{
PhotoRequestCountByDay[id] = 1;
}
else
{
PhotoRequestCountByDay[id]++;
}
UpdatePlayerStatistics();
return PhotoRequestCountByDay[id];
}
public int GetPhotoRequestCountByDay(int id = 0)
{
if (PhotoRequestCountByDay.TryGetValue(id, out int count))
{
int dayOfYear = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear;
if (PhotoRequestCountByDay.TryGetValue(-1, out int day))
{
if (day != dayOfYear)
{
PhotoRequestCountByDay.Clear();
PhotoRequestCountByDay[-1] = dayOfYear;
UpdatePlayerStatistics();
count = 0;
}
}
}
return count;
}
public void UpdatePlayerStatistics()
{
PlayFabMgr.Instance.UpdateUserDataValue("PhotoRequestCountByDay", JsonMapper.ToJson(PhotoRequestCountByDay));
}
public void SavePictureProgress()
{
PlayFabMgr.Instance.UpdateUserDataValue("Picture", JsonMapper.ToJson(fishAlbumData));
}
void SaveNewAlbumData()
{
SetAlubmRed(RedPointName.Home_Album_New, newAlbum.Count > 0);
PlayFabMgr.Instance.UpdateUserDataValue("NewAlbum", JsonMapper.ToJson(newAlbum));
}
public void SetAlubmRed(string key, bool value)
{
RedPointManager.Instance.SetRedPointState(key, value && theme != null);
RedPointManager.Instance.SetRedPointState(RedPointName.Home_Album, (newAlbum.Count > 0 || RedPointManager.Instance.GetRedPointState(RedPointName.Home_Album_Exchange)) && theme != null);
}
public DateTime GetAlbumEndTime()
{
return GContext.container.Resolve<FishingEventData>().GetEventEndTime(eventId);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43668595c23b8164dac63068d9a1663a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bcf64fc4125c4b18933a8446e5b5c422
timeCreated: 1693380651

View File

@@ -0,0 +1,656 @@
using asap.core;
using cfg;
using game;
using LitJson;
using System;
using System.Collections.Generic;
using tysdk;
using UniRx;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace GameCore
{
public class GuideNextEvent
{
}
public class AddIndexEvent
{
public bool CompleteGuide;
public int guideSubIndex;
public bool isAutoNext;
}
/// <summary>
/// 废弃
/// </summary>
public struct OnEventTriggerGuide
{
public OnEventTriggerGuide(string panelName)
{
this.panelName = panelName;
}
public string panelName;
}
public class GuideSaveData
{
public int guideSubIndex = 0;
public bool isFinish = false;
public string groupName;
}
public class GuideDataCenter : IDisposable
{
Tables _tables;
PlayerData playerData;
public GuideDataCenter(cfg.Tables tables, PlayerData playerData)
{
this._tables = tables;
this.playerData = playerData;
}
public string CurPanelName;
public Dictionary<string, GuideSaveData> GuideSaveDataDic = new Dictionary<string, GuideSaveData>();
public GuideSaveData curSaveData;
public GuidanceGroupDefine[] guidanceGroupDefines;
public GuidanceDefine curDefine;
public string popupPanelNode;
public GuidanceGroupDefine curGroupDefine;
public GuidanceDefineSetting guidanceDefineSetting;
//待释放
IDisposable disposable;
IDisposable disposable2;
IDisposable disposable3;
public void GMClearGuide()
{
foreach (var item in guidanceGroupDefines)
{
if (!GuideSaveDataDic.TryGetValue(item.groupName.ToString(), out GuideSaveData _saveData))
{
_saveData = new GuideSaveData();
_saveData.groupName = item.groupName.ToString();
GuideSaveDataDic.Add(item.groupName.ToString(), _saveData);
}
_saveData.isFinish = true;
}
GContext.Publish(new ConditionTypeEvent(ConditionType.CompleteGuide, 0));
curDefine = null;
curGroupDefine = null;
Save();
}
public async void Init()
{
guidanceDefineSetting = (GuidanceDefineSetting)await Addressables.LoadAssetAsync<object>("GuidanceConfig");
if (guidanceDefineSetting != null)
{
guidanceGroupDefines = guidanceDefineSetting.guidanceGroupDefines;
List<GroupName> Skip = guidanceDefineSetting.SkipGroupNames;
bool isSkip = playerData.lv >= guidanceDefineSetting.SkipLevel;
if (GuideSaveDataDic == null)
{
GuideSaveDataDic = new Dictionary<string, GuideSaveData>();
}
else
{
GuideSaveData _saveData;
GuidanceDefine _define;
Dictionary<string, GuideSaveData> keyValuePairs = new Dictionary<string, GuideSaveData>();
foreach (var item in guidanceGroupDefines)
{
if (GuideSaveDataDic.TryGetValue(item.groupName.ToString(), out _saveData))
{
if (!_saveData.isFinish && _saveData.guideSubIndex > 0)
{
for (int i = _saveData.guideSubIndex; i < item.guidanceDefines.Length; i++)
{
_define = item.guidanceDefines[i];
if (_define.isKey)
{
_saveData.guideSubIndex = _define.JumpIndex;
if (_saveData.guideSubIndex < item.guidanceDefines.Length)
{
_saveData.isFinish = false;
curSaveData = _saveData;
curGroupDefine = item;
curDefine = curGroupDefine.guidanceDefines[_saveData.guideSubIndex];
}
else
{
_saveData.isFinish = true;
GContext.Publish(new ConditionTypeEvent(ConditionType.CompleteGuide, 1));
}
break;
}
else
{
_saveData.isFinish = true;
}
}
}
keyValuePairs[item.groupName.ToString()] = _saveData;
}
else if (isSkip && Skip.Contains(item.groupName))
{
_saveData = new GuideSaveData();
_saveData.groupName = item.groupName.ToString();
_saveData.isFinish = true;
keyValuePairs[item.groupName.ToString()] = _saveData;
}
}
GuideSaveDataDic = keyValuePairs;
Save();
}
if (disposable2 == null)
{
disposable2 = GContext.OnEvent<OnEventTriggerGuide>().Subscribe(TriggerGuideNext);
}
}
}
public bool GetIsFinish(string groupName)
{
return GuideSaveDataDic.ContainsKey(groupName) && GuideSaveDataDic[groupName].isFinish;
}
public bool InspectTriggerGuide(string panelName, string prePanelName = "", string curPanelName = "")
{
if (prePanelName.Contains("FishingRodPanel"))
{
return false;
}
if (guidanceDefineSetting == null)
{
return false;
}
if (curGroupDefine != null
&& GuideSaveDataDic.TryGetValue(curGroupDefine.groupName.ToString(), out var guideSaveData)
//&& !guideSaveData.isFinish
&& curGroupDefine.guidanceDefines.Length > guideSaveData.guideSubIndex
&& panelName == curGroupDefine.guidanceDefines[guideSaveData.guideSubIndex].panelName)
{
TriggerGuideNext(new OnEventTriggerGuide(panelName));
return true;
}
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
GuidanceGroupDefine guidanceGroupDefine;
for (int i = 0; i < guidanceGroupDefines.Length; i++)
{
guidanceGroupDefine = guidanceGroupDefines[i];
bool isFinish = GetIsFinish(guidanceGroupDefine.groupName.ToString());
if (isFinish || panelName != guidanceGroupDefine.guidanceDefines[0].panelName)
{
continue;
}
if (CheckTriggerGuideFinish(guidanceGroupDefine))
{
continue;
}
int count;
switch (guidanceGroupDefine.TriggerConditionsType)
{
case GuideTriggerConditions.Next:
break;
case GuideTriggerConditions.First_login:
break;
case GuideTriggerConditions.OpenSystem_Shop:
if (GContext.container.Resolve<PlayerShopData>().IsShopOpen == false)
{
continue;
}
break;
case GuideTriggerConditions.UnlockSystem_Album:
if (GContext.container.Resolve<AlbumData>().theme == null)
{
continue;
}
break;
case GuideTriggerConditions.Level_2:
if (playerData.lv >= 2)
{
break;
}
continue;
case GuideTriggerConditions.Group_Finish:
if (GuideSaveDataDic.TryGetValue(guidanceGroupDefine.TriggerConditionsParameter, out var _data) && _data.isFinish)
{
break;
}
continue;
case GuideTriggerConditions.GetDiffFishCount:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && playerFishData.GetDiffFishCount() >= count)
{
if (playerFishData.GetDiffFishCount() > count)
{
TriggerGuideFinish(guidanceGroupDefine);
continue;
}
break;
}
continue;
case GuideTriggerConditions.GetFishCount:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && playerFishData.GetAnglingCount() >= count)
{
if (playerFishData.GetAnglingCount() > count)
{
TriggerGuideFinish(guidanceGroupDefine);
continue;
}
break;
}
continue;
case GuideTriggerConditions.FirstClickMap_AtMap2:
if (playerData.lastMapId == _tables.TbMapData.DataList[1].ID)
{
break;
}
continue;
case GuideTriggerConditions.AccountLevel:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && playerData.lv >= count)
{
break;
}
continue;
case GuideTriggerConditions.UnlockSystem:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && GContext.container.Resolve<FishingEventData>().GetSystemOpen(count))
{
break;
}
continue;
case GuideTriggerConditions.UnlockEvent:
string[] str = guidanceGroupDefine.TriggerConditionsParameter.Split('-');
if (str.Length == 2)
{
if (int.TryParse(str[0], out count) && int.TryParse(str[1], out int count2) && GContext.container.Resolve<FishingEventData>().GetEvent(count, count2) > 0)
{
break;
}
}
else if (str.Length == 3)
{
if (int.TryParse(str[0], out count) && int.TryParse(str[1], out int count2) && int.TryParse(str[2], out int count3) && GContext.container.Resolve<FishingEventData>().GetEventRedirectID(count, count2) == count3)
{
break;
}
}
//if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && GContext.container.Resolve<FishingEventData>().GetSystemOpen(count))
//{
// break;
//}
continue;
case GuideTriggerConditions.MaxMultiplierCount:
if (playerData.IsOpenMagnification &&
int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) &&
playerData.ContainsOrGreaterRatio(count))
{
break;
}
continue;
case GuideTriggerConditions.GetSecondRod:
if (!prePanelName.Contains("HomePanel") && playerFishData.IsOpenRod && playerFishData.GetRodAllCount() > 1)
{
break;
}
continue;
case GuideTriggerConditions.RodAscendAvailable:
if (!prePanelName.Contains("HomePanel") && playerFishData.IsOpenRod && playerFishData.GetRodCanUp())
{
break;
}
continue;
case GuideTriggerConditions.RodUpgradeAvailable:
if (!prePanelName.Contains("HomePanel") && playerFishData.IsOpenRod && playerFishData.GetRodCanUpLevel())
{
break;
}
continue;
case GuideTriggerConditions.BuyPack:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && GContext.container.Resolve<PlayerShopData>().GetAllPackCount(count) > 0)
{
break;
}
continue;
case GuideTriggerConditions.BoxOpenCondition:
FishingBoxDataProvier fishingBoxData = GContext.container.Resolve<FishingBoxDataProvier>();
if (fishingBoxData.IsUnclocked && fishingBoxData.GetBoxCount(fishingBoxData.GetIDByQuality(3)) > 0)
{
break;
}
continue;
case GuideTriggerConditions.GoBuilding:
if (GContext.container.Resolve<CampDataMM>().GoBuilding())
{
break;
}
continue;
case GuideTriggerConditions.GoBuilding02:
if (playerData.lv >= 12)
{
TriggerGuideFinish(guidanceGroupDefine);
Debug.Log("TriggerGuideFinish(guidanceGroupDefine);");
continue;
}
if (GContext.container.Resolve<CampDataMM>().GoBuilding02(101012))
{
Debug.Log("TriggerGuideFinish();");
break;
}
continue;
case GuideTriggerConditions.EventWashingStep:
if (int.TryParse(guidanceGroupDefine.TriggerConditionsParameter, out count) && GContext.container.Resolve<EventWashingDataManager>().IsCurrentStepID(count))
{
break;
}
continue;
default:
continue;
}
if (curGroupDefine == guidanceGroupDefine)
{
return false;
}
if (panelName == guidanceGroupDefine.guidanceDefines[0].panelName)
{
TriggerGuide(guidanceGroupDefine, curPanelName);
return true;
}
}
return false;
}
public void ClearGuide(string groupName)
{
if (GuideSaveDataDic.ContainsKey(groupName))
{
GuideSaveDataDic.Remove(groupName);
Save();
}
}
/// <summary>
/// 特殊屏蔽的新手引导
/// </summary>
/// <param name="group"></param>
bool CheckTriggerGuideFinish(GuidanceGroupDefine group)
{
bool isFinishPass = false;
//判断是否直接完成
if (group.groupName == GroupName.Chanllenge)
{
// isFinishPass = !GContext.container.Resolve<FishingChallengeCenter>().IsFirstOpen;
isFinishPass = !GContext.container.Resolve<FishingChallengeManager>().IsFirstOpen;
}
if (group.groupName == GroupName.BeginnerPack01)
{
MMTService mMTService = GContext.container.Resolve<MMTService>();
if (mMTService.mmt)
{
isFinishPass = true;
}
}
if (isFinishPass)
{
TriggerGuideFinish(group);
}
return isFinishPass;
}
void TriggerGuideFinish(GuidanceGroupDefine group)
{
string groupName = group.groupName.ToString();
if (!GuideSaveDataDic.TryGetValue(groupName, out var guideSaveData))
{
guideSaveData = new GuideSaveData();
guideSaveData.groupName = groupName;
GuideSaveDataDic.Add(groupName, guideSaveData);
}
guideSaveData.guideSubIndex = group.guidanceDefines.Length;
guideSaveData.isFinish = true;
Save();
}
public bool TriggerGuide(string groupName, string panelName, bool loop = true)
{
if (guidanceDefineSetting == null)
{
return false;
}
GuidanceGroupDefine guidanceGroupDefine;
if (!loop)
{
bool isFinish = GetIsFinish(groupName.ToString());
if (isFinish)
{
return false;
}
}
for (int i = 0; i < guidanceGroupDefines.Length; i++)
{
guidanceGroupDefine = guidanceGroupDefines[i];
if (guidanceGroupDefine.groupName.ToString() == groupName)
{
if (panelName != guidanceGroupDefine.guidanceDefines[0].panelName)
{
return false;
}
TriggerGuide(groupName, guidanceGroupDefine);
return true;
}
}
return false;
}
async void TriggerGuide(string groupName, GuidanceGroupDefine guidanceGroupDefine)
{
await System.Threading.Tasks.Task.Delay(200);
curSaveData = new GuideSaveData();
curSaveData.groupName = groupName;
GuideSaveDataDic[groupName] = curSaveData;
curGroupDefine = guidanceGroupDefine;
curDefine = curGroupDefine.guidanceDefines[0];
ShowPanel("");
curSaveData.guideSubIndex++;
}
void TriggerGuide(GuidanceGroupDefine group, string curPanelName)
{
string groupName = group.groupName.ToString();
if (!GuideSaveDataDic.TryGetValue(groupName, out var guideSaveData))
{
guideSaveData = new GuideSaveData();
guideSaveData.groupName = groupName;
GuideSaveDataDic.Add(groupName, guideSaveData);
}
if (guideSaveData.isFinish)
{
return;
}
guideSaveData.guideSubIndex = 0;
curSaveData = guideSaveData;
curGroupDefine = group;
curDefine = group.guidanceDefines[0];
ShowPanel(curPanelName);
curSaveData.guideSubIndex++;
}
public void TriggerGuideNext(OnEventTriggerGuide eventTriggerGuide)
{
if (curGroupDefine != null && GuideSaveDataDic.TryGetValue(curGroupDefine.groupName.ToString(), out var guideSaveData))
{
if (curGroupDefine.guidanceDefines.Length <= curSaveData.guideSubIndex || eventTriggerGuide.panelName != curGroupDefine.guidanceDefines[guideSaveData.guideSubIndex].panelName)
{
return;
}
curDefine = curGroupDefine.guidanceDefines[guideSaveData.guideSubIndex];
if (curDefine.completeType == CompleteType.PanelOpen)
{
string uIType = curDefine.completeTypeParameter;
if (!string.IsNullOrEmpty(uIType) && UIManager.Instance.ContainsUI(uIType))
{
curSaveData.guideSubIndex++;
AddIndex();
}
else
{
disposable = GContext.OnEvent<GetUIAsyncEvent>().Subscribe(data =>
{
if (uIType == data.uIType && data.show)
{
curSaveData.guideSubIndex++;
AddIndex();
}
});
}
}
else
{
ShowPanel("");
curSaveData.guideSubIndex++;
}
}
else
{
InspectTriggerGuide(eventTriggerGuide.panelName);
}
}
public void AddIndex(bool is_pass = false)
{
if (curDefine == null)
{
return;
}
if (disposable != null)
{
disposable.Dispose();
disposable = null;
}
if (disposable3 != null)
{
disposable3.Dispose();
disposable3 = null;
}
UIManager.Instance.HideUI(UITypes.GuidancePanel);
bool isAutoNext = curDefine.isAutoNext;
AddIndexEvent addIndexEvent = new AddIndexEvent();
addIndexEvent.isAutoNext = isAutoNext;
if (curGroupDefine.guidanceDefines.Length <= curSaveData.guideSubIndex || is_pass)
{
#if AGG
using (var e = GEvent.GameEvent("guide_complete"))
{
e.AddContent("guide_id", curGroupDefine.groupName.ToString())
.AddContent("is_pass", is_pass);
}
#endif
string panelName = curDefine.panelName;
curDefine = null;
curGroupDefine = null;
curSaveData.isFinish = true;
Save();
if (isAutoNext)
{
InspectTriggerGuide(panelName, panelName);
}
GContext.Publish(new ConditionTypeEvent(ConditionType.CompleteGuide, 1));
addIndexEvent.CompleteGuide = true;
addIndexEvent.guideSubIndex = curSaveData.guideSubIndex;
GContext.Publish(addIndexEvent);
}
else
{
Save();
var define = curGroupDefine.guidanceDefines[curSaveData.guideSubIndex];
if (isAutoNext && define.panelName == curDefine.panelName)
{
curDefine = define;
ShowPanel(CurPanelName);
curSaveData.guideSubIndex++;
}
else if (!isAutoNext)
{
for (int i = curSaveData.guideSubIndex; i < curGroupDefine.guidanceDefines.Length; i++)
{
var _define = curGroupDefine.guidanceDefines[i];
if (_define.isKey)
{
curSaveData.isFinish = false;
break;
}
else
{
curSaveData.isFinish = true;
}
}
}
addIndexEvent.guideSubIndex = curSaveData.guideSubIndex;
GContext.Publish(addIndexEvent);
}
}
async void ShowPanel(string PanelName)
{
if (curDefine.fingerType != FingerType.None)
{
disposable3 = GContext.OnEvent<GuideNextEvent>().Subscribe(GuideNextEvent);
}
CurPanelName = PanelName;
await UIManager.Instance.ShowUI(UITypes.GuidancePanel);
}
public async void ShowGuidancePopupPanel(string nodeName)
{
popupPanelNode = nodeName;
if (!string.IsNullOrEmpty(popupPanelNode))
{
await UIManager.Instance.ShowUI(UITypes.GuidancePopupPanel);
UIManager.Instance.HideUI(UITypes.GuidancePanel);
}
}
void GuideNextEvent(GuideNextEvent guideLongEvent)
{
if (curDefine.fingerType != FingerType.None)
{
AddIndex();
}
}
public bool IsGuide(string panelName)
{
bool isGuide = curDefine != null;
if (!isGuide)
{
InspectTriggerGuide(panelName);
}
return curDefine != null && curDefine.panelName == panelName;
}
public bool IsGuide(string panelName, int index, GroupName groupName)
{
bool isGuide = curDefine != null;
if (isGuide && curGroupDefine.groupName == groupName && curSaveData.guideSubIndex == index)
{
InspectTriggerGuide(panelName);
return true;
}
return false;// curDefine != null && curDefine.panelName == panelName;
}
public void Save()
{
PlayFabMgr.Instance.UpdateUserDataValue("GuideSaveData", JsonMapper.ToJson(GuideSaveDataDic));
}
public void Dispose()
{
disposable?.Dispose();
disposable = null;
disposable2?.Dispose();
disposable2 = null;
disposable3?.Dispose();
disposable3 = null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cab93c5377869549a5340ab4d25bf2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,448 @@
using asap.core;
using asap.playfab.async;
using game;
using PlayFab.ClientModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using tysdk;
namespace GameCore
{
public enum ELeaderboardState : byte
{
Success = 0,
Failed = 1,
Delay = 2
}
public class GetLeaderboardsRequest
{
public string playerId { get; set; }
public bool includeOther { get; set; }
public int? Score { get; set; }
}
/// <summary>
/// Leaderboard Model
/// </summary>
public class GetLeaderboardsResp
{
public ELeaderboardState state { get; set; }
/// <summary>
/// Event Id from table
/// </summary>
public int eventId { get; set; }
/// <summary>
/// Level of Leaderboard eg. T0 T1 T2
/// </summary>
public int rankLevel { get; set; }
///
/// <summary>
/// Max players of this leaderboard
/// </summary>
public int capacity { get; set; }
/// <summary>
/// Num of current member in this leaderboard (Players + Bots)
/// </summary>
//public int Count => data?.Length ?? 0;
/// <summary>
/// Avaliable Rank Datas
/// </summary>
public RankData[] data { get; set; }
}
public class UpdateScoreRequest
{
public string playerId { get; set; }
public float Score { get; set; }
}
public class UpdateScoreResp
{
public ELeaderboardState state { get; set; }
public int rank { get; set; }
public int preRank { get; set; }
public double score { get; set; }
public double preScore { get; set; }
}
public class GetRewardsRequest
{
public string playerId { get; set; }
}
public class GetRewardsResp
{
public bool success { get; set; }
public List<RewardData> rewardDatas { get; set; }
}
//public class ManualUpdateRequest
//{
// public int eventId { get; set; }
//}
public class RewardData
{
public int rankLevel { get; set; }
public int dropId { get; set; }
public int eventId { get; set; }
public RankData[] ranks { get; set; }
}
public class RankData
{
/// <summary>
/// Player PlayFab ID
/// </summary>
public string id { get; set; }
/// <summary>
/// Leaderboard ranking
/// </summary>
public int rank { get; set; }
/// <summary>
/// leaderboard score
/// </summary>
public float score { get; set; }
/// <summary>
/// Is this player myself
/// </summary>
public bool isMe { get; set; }
public bool isBot { get; set; }
public string displayName { get; set; }
public string avatarUrl { get; set; }
}
public class EventRankData
{
}
public class PFRankDataEvent
{
public bool isLocal;
}
public class LeadboardData
{
[Inject]
public IUserService userService { get; set; }
[Inject]
public ICustomServerMgr customServerMgr { get; set; }
public static int LV_MODELING = 100000;
//public const string leadboardLevelName = "Level";
public const string leadboardLevelName = "LevelB";
const int RefreshSeconds = 300;
bool isRefreshing = false;
public List<LeadboardItemData> LeadboardDataList = new List<LeadboardItemData>();
public List<LeadboardItemData> LeadboardContinentDataList = new List<LeadboardItemData>();
public GetLeaderboardsResp curEventRank;
public RewardData eventRankReward;
public cfg.RankInit lastEventRank;
public cfg.FishingEvent fishingEvent;
public cfg.RankTargets rankTarget;
public int lastScore;
public int lastAllScore;
int MeRank = 0;
public bool IsOpenleaderboard;
public async Task SetLeadboardData(List<string> names, List<int> value)
{
List<StatisticUpdate> Statistics = new List<StatisticUpdate>();
for (int i = 0; i < names.Count; i++)
{
Statistics.Add(new StatisticUpdate() { StatisticName = names[i], Value = value[i] });
}
UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
{
Statistics = Statistics,
};
await PlayFabClientAsyncAPI.UpdatePlayerStatisticsAsync(request);
}
public async Task<GetLeaderboardResult> GetLeadboardData(string leaderboardNaem, int maxCount = 50)
{
GetLeaderboardRequest reques = new GetLeaderboardRequest()
{
StartPosition = 0,
MaxResultsCount = maxCount,
StatisticName = leaderboardNaem,
ProfileConstraints = new PlayerProfileViewConstraints()
{
ShowAvatarUrl = true,
ShowLocations = true,
ShowDisplayName = true,
}
};
return await PlayFabClientAsyncAPI.GetLeaderboardAsync(reques);
}
public async void SetLvData()
{
isRefreshing = true;
string localName = GContext.container.Resolve<IUserService>().ContinentCode + leadboardLevelName;
string InfiniteBuildingLevel = GContext.container.Resolve<PlayerData>().InfiniteBuildingLevel;
int.TryParse(InfiniteBuildingLevel, out int InfiniteBuildingLevelInt);
int level = GContext.container.Resolve<PlayerData>().lv * LV_MODELING + InfiniteBuildingLevelInt;
await SetLeadboardData(new List<string> { leadboardLevelName, localName }, new List<int> { level, level });
isRefreshing = false;
}
public async void AwaitSetLvData()
{
if (isRefreshing)
{
return;
}
isRefreshing = true;
await Awaiters.Seconds(RefreshSeconds);
SetLvData();
}
public async void GetLevelLeadboardData(bool islocal = false,/* bool save = false,*/ string name = leadboardLevelName)
{
if (islocal)
{
name = GContext.container.Resolve<IUserService>().ContinentCode + leadboardLevelName;
}
var result = await GetLeadboardData(name);
if (result != null)
{
List<LeadboardItemData> curList = new List<LeadboardItemData>();
var Leaderboard = result.Leaderboard;
if (Leaderboard.Count > 0)
{
for (int i = 0; i < Leaderboard.Count; i++)
{
LeadboardItemData item = new LeadboardItemData();
if (string.IsNullOrEmpty(Leaderboard[i].Profile.DisplayName))
{
Leaderboard[i].Profile.DisplayName = userService.GetDefaultName(Leaderboard[i].PlayFabId);
}
item.SetData(Leaderboard[i]);
userService.SetPlayInfo(Leaderboard[i].PlayFabId, Leaderboard[i].Profile.DisplayName, Leaderboard[i].Profile.AvatarUrl);
curList.Add(item);
}
if (islocal)
{
LeadboardContinentDataList = curList;
}
else
{
LeadboardDataList = curList;
}
GContext.Publish(new PFRankDataEvent() { isLocal = islocal });
}
}
}
#region EventLeaderboard
public async Task<bool> GetLeaderboard(int Score = 0)
{
GetLeaderboardsResp getLeaderboardsResp = null;
GetLeaderboardsRequest getLeaderboardRequest = new GetLeaderboardsRequest()
{
playerId = userService.UserId,
includeOther = true,
Score = Score
};
string json = await customServerMgr.EventRequest("GetLeaderboards", getLeaderboardRequest);
if (!string.IsNullOrEmpty(json) && json != "[]")
{
getLeaderboardsResp = Newtonsoft.Json.JsonConvert.DeserializeObject<GetLeaderboardsResp>(json);
}
if (getLeaderboardsResp != null && getLeaderboardsResp.state == ELeaderboardState.Success)
{
curEventRank = getLeaderboardsResp;
GetRankPlayInfo(curEventRank.data);
}
else if (curEventRank == null || curEventRank.data == null)
{
curEventRank = new GetLeaderboardsResp();
}
if (curEventRank.data == null)
{
curEventRank.data = new RankData[] { new RankData { id = userService.UserId, isMe = true, rank = 1 } };
MeRank = 0;
}
else
{
if (curEventRank.data.Length > 1)
{
for (int i = 0; i < curEventRank.data.Length; i++)
{
if (curEventRank.data[i].isMe)
{
MeRank = curEventRank.data[i].rank;
}
}
}
else
{
MeRank = 0;
}
}
GContext.Publish(new EventRankData());
return curEventRank != null;
}
public int GetMeRank()
{
return MeRank;
}
public List<ItemData> rankItemDatas { set; get; }
public static string NextQueueKey = "EventRankNextQueueKey";
public async Task GetRewards()
{
if (lastEventRank != null && rankItemDatas == null)
{
int dropId = 0;
GetRewardsRequest request = new GetRewardsRequest { playerId = userService.UserId };
string json = await customServerMgr.EventRequest("GetRewards", request);
GetRewardsResp response = null;
if (!string.IsNullOrEmpty(json) && json != "[]")
{
response = Newtonsoft.Json.JsonConvert.DeserializeObject<GetRewardsResp>(json);
}
if (response != null && response.success && response.rewardDatas != null && response.rewardDatas.Count > 0)
{
dropId = response.rewardDatas[0].dropId;
eventRankReward = response.rewardDatas[0];
RankData[] ranks = response.rewardDatas[0].ranks;
GetRankPlayInfo(ranks);
RankData rankData = ranks.Where(x => x.isMe).FirstOrDefault();
float score = rankData.score;
var _tables = GContext.container.Resolve<cfg.Tables>();
var fishingEvent1 = _tables.TbFishingEvent.GetOrDefault(response.rewardDatas[0].eventId);
if (fishingEvent1 != null)
{
fishingEvent = fishingEvent1;
}
var lastEventRank1 = _tables.TbRankInit.GetOrDefault(fishingEvent.RedirectID);
if (lastEventRank1 != null)
{
lastEventRank = lastEventRank1;
}
if (lastEventRank.UnlockPoint > score)
{
return;
}
rankTarget = _tables.TbRankTargets.GetOrDefault(lastEventRank.TargetList[0]);
if (rankTarget != null)
{
lastAllScore = (int)score;
lastScore = lastAllScore;
while (rankTarget != null && rankTarget.NextTarget > 0 && rankTarget.TokenRequired <= lastScore)
{
lastScore -= rankTarget.TokenRequired;
rankTarget = _tables.TbRankTargets.GetOrDefault(rankTarget.NextTarget);
}
}
if (dropId > 0)
{
var fishingStage = GContext.container.ResolveStage("FishingStage") as FishingStage;
if (fishingStage != null)
{
fishingStage.IsNextQueue = true;
fishingStage.NextQueueKey = NextQueueKey;
}
rankItemDatas = GContext.container.Resolve<PlayerItemData>().AddItemByDrop(dropId, true);
if (fishingStage != null)
{
fishingStage.IsNextQueue = false;
fishingStage.NextQueueKey = string.Empty;
}
#if AGG
using (var e = GEvent.GameEvent("last_ranking"))
{
int playerCount = ranks.Where(x => !x.isBot).Count();
int isBotCount = ranks.Length - playerCount;
e.AddContent("ranking_tier", response.rewardDatas[0].rankLevel)
.AddContent("ranking_points", lastAllScore)
.AddContent("get_reward_user", playerCount)
.AddContent("get_reward_robot", isBotCount)
.AddContent("rank", rankData.rank)
.AddContent("dropId", dropId);
if (rankItemDatas != null)
{
for (int i = 0; i < rankItemDatas.Count; i++)
{
if (rankItemDatas[i].id == 1001)
{
e.AddContent("reward_hook", rankItemDatas[i].count);
}
else if (rankItemDatas[i].id == 1002)
{
e.AddContent("reward_cash", rankItemDatas[i].count);
}
}
}
}
#endif
GContext.container.Resolve<IFaceUIService>().AddFaceUIData(fishingEvent.FaceID, fishingEvent.RedirectID, 2);
}
}
}
}
public async void UpdateScore(int score)
{
UpdateScoreResp data = null;
UpdateScoreRequest request = new UpdateScoreRequest { playerId = userService.UserId, Score = score };
string json = await customServerMgr.EventRequest("UpdateScore", request);
if (!string.IsNullOrEmpty(json) && json != "[]")
{
data = Newtonsoft.Json.JsonConvert.DeserializeObject<UpdateScoreResp>(json);
}
if (data != null && data.state == ELeaderboardState.Success)
{
MeRank = data.rank;
//更新主界面排名显示
}
else /*if (data.state == ELeaderboardState.Delay)*/
{
MeRank = 0;
curEventRank = new GetLeaderboardsResp();
curEventRank.data = new RankData[] { new RankData { isMe = true, rank = 1 } };
}
GContext.Publish(new EventRankData());
}
void GetRankPlayInfo(RankData[] RankDatas)
{
Dictionary<int, cfg.Robot> robots = GContext.container.Resolve<cfg.Tables>().TbRobot.DataMap;
foreach (var item in RankDatas)
{
if (!item.isMe && !item.isBot)
{
if (!string.IsNullOrEmpty(item.avatarUrl) || !string.IsNullOrEmpty(item.displayName))
{
userService.SetPlayInfo(item.id, item.displayName, item.avatarUrl);
}
else
{
userService.GetPlayInfo(item.id);
}
}
else if (item.isBot)
{
int b = Convert.ToInt32(item.id, 16);
if (robots.TryGetValue(b, out cfg.Robot robot))
{
userService.SetPlayInfo(item.id, LocalizationMgr.GetText(robot.Name_l10n_key), robot.Avatar);
}
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 163651870986690498be8e1769e5557f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 47fd52e669662284e9c6278c71b71454
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4485d4fb77643b14e82c6497aef5f577
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 647137b625555894883aa3c1f8cb07f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c51b80d81de5c84dbeaa75ff8ee0b67
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,304 @@
using asap.core;
using cfg;
using game;
using LitJson;
using System;
using System.Collections.Generic;
namespace GameCore
{
public class DailySignEvent
{
public int ID;
//领取第几个
public int index;
//签到最后一次是哪一天or链式礼包PackManager.ID
public int lastID;
//结束时间
public string time;
}
public class MonthlySignEvent
{
public int index;
//结束时间
public int Monthly;
public DailySignEvent dailySignEvent;
}
public class OnSignEvent
{
public List<ItemData> itemDataList;
}
public class SigninData
{
private cfg.Tables _tables;
public SigninData(cfg.Tables tables)
{
this._tables = tables;
}
DailySignEvent _newSignEvent = null;
MonthlySignEvent _monthlySignEvent = null;
int _eventSignID = 0;
public DailySignEvent dailySignEvent
{
get => _monthlySignEvent == null ? null : _monthlySignEvent.dailySignEvent;
}
public DailySignEvent newSignEvent
{
get => _newSignEvent;
set => _newSignEvent = value;
}
public MonthlySignEvent monthlySignEvent
{
get => _monthlySignEvent;
set => _monthlySignEvent = value;
}
public int eventSignID => _eventSignID;
public void SetDailySignEvent(FishingEvent t)
{
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
bool isSave = false;
if (_monthlySignEvent == null)
{
_monthlySignEvent = new MonthlySignEvent()
{
index = 0,
Monthly = dateTime.Month,
};
isSave = true;
}
if (_monthlySignEvent.Monthly != dateTime.Month)
{
DailySignEvent data = _monthlySignEvent.dailySignEvent;
_monthlySignEvent = new MonthlySignEvent()
{
index = 0,
Monthly = dateTime.Month,
dailySignEvent = data,
};
isSave = true;
}
int offfset = (int)dateTime.DayOfWeek - 1;
if (t.TimeDefinition is Weekly)
{
Weekly weekly = (Weekly)t.TimeDefinition;
offfset = (int)dateTime.DayOfWeek - weekly.StartTime;
}
if (offfset < 0)
{
offfset = -offfset;
}
else
{
offfset = 7 - offfset;
}
if (_monthlySignEvent.dailySignEvent == null ||
GlobalUtils.TryParseDateTime(_monthlySignEvent.dailySignEvent.time, dateTime).DayOfYear
!= dateTime.Date.AddDays(offfset).DayOfYear)
{
_monthlySignEvent.dailySignEvent = new DailySignEvent()
{
ID = t.RedirectID,
lastID = -1,
index = 0,
time = dateTime.Date.AddDays(offfset).ToString()
};
isSave = true;
}
if (isSave)
{
PlayFabMgr.Instance.UpdateUserDataValue("MonthlySignEvent", JsonMapper.ToJson(_monthlySignEvent));
}
}
public void SetEventSignEvent(FishingEvent t)
{
SignInit signInit = _tables.TbSignInit.GetOrDefault(t.RedirectID);
if (signInit != null)
{
_eventSignID = t.RedirectID;
UITypes.EventSignupPopupPanel_2.SetType(signInit.SpecialSignName);
}
}
public void EventSignEnd()
{
_eventSignID = 0;
UITypes.EventSignupPopupPanel_2.SetType("EventSignupPopupPanel_2");
//GContext.container.Resolve<FishingEventData>().GetEventAndInit(2, 1);
//GContext.container.Resolve<FishingEventData>().GetEventAndInit(2, 3);
}
public void SetNewSignEvent(FishingEvent t)
{
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
if (_tables.TbSignInit.GetOrDefault(t.RedirectID) == null)
{
return;
}
SignInit signInit = _tables.TbSignInit.GetOrDefault(t.RedirectID);
UITypes.EventSignupPopupPanel.SetType(signInit.SpecialSignName);
if (_newSignEvent == null || GlobalUtils.TryParseDateTime(_newSignEvent.time, ZZTimeHelper.UtcNow().UtcNowOffset()).Ticks < dateTime.Ticks)
{
string time = dateTime.AddDays(10).ToString();
if (t.TimeDefinition is FixedTime)
{
if (GContext.container.Resolve<FishingEventData>().FixedTimeEventDic.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 DailySignEvent()
{
ID = t.RedirectID,
lastID = -1,
index = 0,
time = time,
};
PlayFabMgr.Instance.UpdateUserDataValue("NewSignEvent", JsonMapper.ToJson(_newSignEvent));
//GContext.Publish(new TargetEvent(t.ID, 3, 6));
}
SetNewSignRed();
}
public bool NewSignEventIsOpen()
{
return _newSignEvent != null && GlobalUtils.TryParseDateTime(_newSignEvent.time, ZZTimeHelper.UtcNow().UtcNowOffset()).Ticks > ZZTimeHelper.UtcNow().UtcNowOffset().Ticks;
}
public TimeSpan NewSignEventEndTime()
{
return GlobalUtils.TryParseDateTime(_newSignEvent.time, ZZTimeHelper.UtcNow().UtcNowOffset()) - ZZTimeHelper.UtcNow().UtcNowOffset();
}
//签到
public bool OnDailySign(int index, int DropID)
{
if (_monthlySignEvent == null || _monthlySignEvent.dailySignEvent == null)
{
return false;
}
bool isSign = SignEvent(_monthlySignEvent.dailySignEvent, index);
if (isSign)
{
_monthlySignEvent.index++;
List<ItemData> itemDataList = GContext.container.Resolve<PlayerItemData>().AddItemByDrop(DropID, false);
#if AGG
DateTime tomorrow = GlobalUtils.TryParseDateTime(_monthlySignEvent.dailySignEvent.time, ZZTimeHelper.UtcNow().UtcNowOffset());
TimeSpan remaining = tomorrow - ZZTimeHelper.UtcNow().UtcNowOffset();
using (var e = GEvent.GameEvent("user_checkin"))
{
e.AddContent("day_num", 7 - remaining.Days)
.AddContent("day_count", _monthlySignEvent.dailySignEvent.index);
if (itemDataList != null)
{
for (int i = 0; i < itemDataList.Count; i++)
{
e.AddContent($"item_{itemDataList[i].id}", itemDataList[i].count);
}
}
}
#endif
List<MonthlySign> MonthlySignL = _tables.TbMonthlySign.DataList;
List<ItemData> monthlySignReward = null;
for (int i = 0; i < MonthlySignL.Count; i++)
{
if (_monthlySignEvent.index == MonthlySignL[i].SignDayAccount)
{
monthlySignReward = GContext.container.Resolve<PlayerItemData>().AddItemByDrop(MonthlySignL[i].DropID, false);
break;
}
}
//GContext.Publish(new ShowData());
PlayFabMgr.Instance.UpdateUserDataValue("MonthlySignEvent", JsonMapper.ToJson(_monthlySignEvent));
GContext.Publish(new OnSignEvent() { itemDataList = monthlySignReward });
}
return isSign;
}
public bool OnSpecialSign(int ID, int index, int DropID)
{
if (_newSignEvent == null)
{
return false;
}
bool isSign = SignEvent(_newSignEvent, index);
if (isSign)
{
SetNewSignRed();
List<ItemData> itemDataList = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(DropID);
if (itemDataList != null)
{
if (index == 6)
{
SignInit signInit = _tables.TbSignInit.GetOrDefault(ID);
List<int> signDayList = signInit.SignDayList;
SignReward dailySign = _tables.TbSignReward.GetOrDefault(signDayList[^1]);
for (int i = 0; i < itemDataList.Count; i++)
{
itemDataList[i].count *= dailySign.Multiplier;
}
}
GContext.Publish(new ShowData(itemDataList));
GContext.container.Resolve<PlayerItemData>().AddItem(itemDataList);
GContext.Publish(new ShowData());
}
PlayFabMgr.Instance.UpdateUserDataValue("NewSignEvent", JsonMapper.ToJson(_newSignEvent));
GContext.Publish(new OnSignEvent());
#if AGG
DateTime tomorrow = GlobalUtils.TryParseDateTime(_newSignEvent.time, ZZTimeHelper.UtcNow().UtcNowOffset());
TimeSpan remaining = tomorrow - ZZTimeHelper.UtcNow().UtcNowOffset();
using (var e = GEvent.GameEvent("lv25_checkin"))
{
e.AddContent("day_num", _newSignEvent.index)
.AddContent("day_count", 10 - remaining.Days);
if (itemDataList != null)
{
for (int i = 0; i < itemDataList.Count; i++)
{
if (itemDataList[i].id == 1001)
{
e.AddContent("reward_hook", itemDataList[i].count);
}
else if (itemDataList[i].id == 1002)
{
e.AddContent("reward_cash", itemDataList[i].count);
}
}
}
}
#endif
}
return isSign;
}
void SetNewSignRed()
{
RedPointManager.Instance.SetRedPointState("Home.Sign", _newSignEvent.lastID != ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear && _newSignEvent.index < 7);
}
bool SignEvent(DailySignEvent data, int index)
{
if (data.lastID == ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear)
{
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_1"));
return false;
}
if (index == data.index)
{
data.lastID = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear;
data.index++;
return true;
}
return false;
}
public bool DailySignIsOpen()
{
return _monthlySignEvent != null && _monthlySignEvent.dailySignEvent != null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2e7a76fc0d500c47ac73575721c67aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,701 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using asap.core;
using cfg;
using game;
using LitJson;
using Newtonsoft.Json;
using UnityEngine;
using static EventPartnerData;
namespace GameCore
{
public class ChangeSmallGameTargetEvent
{
public OpponentItemData opponentItemData;
public System.Threading.Tasks.TaskCompletionSource<bool> ts;
public bool random;
}
public class SmallGameData
{
private cfg.Tables _tables;
IUserService userService;
ICustomServerMgr customServerMgr;
public SmallGameData(cfg.Tables tables, IUserService userService, ICustomServerMgr customServerMgr)
{
this._tables = tables;
this.userService = userService;
this.customServerMgr = customServerMgr;
BottleCashParamBase = _tables.TbGlobalConfig.BottleCashParamBase;
BottleCashParamDiv = _tables.TbGlobalConfig.BottleCashParamDiv;
BottleCashParamLevel = _tables.TbGlobalConfig.BottleCashParamLevel;
}
public void Init()
{
campData = GContext.container.Resolve<CampDataMM>();
LoginRandomOpponent();
}
CampDataMM campData;
int _heistGameCount = 0;
int _bombGameCount = 0;
int _fishHuntGameCount = 0;
public int HeistGameCount => _heistGameCount;
public int FishHuntGameCount => _fishHuntGameCount;
public int BombGameCount => _bombGameCount;
public int AlbumEventID;
//public UnityEngine.Vector3 image_extra_pos { set; get; }
public void SetHeistGameCount(int value)
{
_heistGameCount = value;
}
public void SaveHeistGameCount()
{
_heistGameCount++;
PlayFabMgr.Instance.UpdateUserDataValue("HeistGameCount", _heistGameCount.ToString());
}
public void SetBombGameCount(int value)
{
_bombGameCount = value;
}
public void SaveBombGameCount()
{
_bombGameCount++;
PlayFabMgr.Instance.UpdateUserDataValue("BombGameCount", _bombGameCount.ToString());
}
public void SetFishHuntGameCount(int value)
{
_fishHuntGameCount = value;
}
public void SaveFishHuntGameCount()
{
_fishHuntGameCount++;
PlayFabMgr.Instance.UpdateUserDataValue("FishHuntGameCount", _fishHuntGameCount.ToString());
}
#region
public List<OpponentItemData> opponentItemDatas = new List<OpponentItemData>();
public List<OpponentItemData> opponentFriendItemDatas = new List<OpponentItemData>();
public List<OpponentItemData> opponentNotFriendItemDatas = new List<OpponentItemData>();
public List<OpponentItemData> opponentFriend = new List<OpponentItemData>();
Dictionary<string, OpponentItemData> opponentFriendDic = new Dictionary<string, OpponentItemData>();
public Dictionary<EnemyType, List<OpponentItemData>> opponentEnemy = new Dictionary<EnemyType, List<OpponentItemData>>();
List<OpponentItemData> opponentItemDatasPre = new List<OpponentItemData>();
List<OpponentItemData> opponentFriendItemDatasPre = new List<OpponentItemData>();
List<OpponentItemData> opponentNotFriendItemDatasPre = new List<OpponentItemData>();
EnemyType curEnemyType = EnemyType.Aquarium;
public Dictionary<string, float> powerData;
public OpponentItemData opponentData;
OpponentItemData nextOpponent;
int GMbobmName = 0;
int BottleCashParamBase;
int BottleCashParamDiv;
int BottleCashParamLevel;
public int RobotMapId;
public int nextRobotMapId;
public void GMSetBomb(string bobmName)
{
GMbobmName = int.Parse(bobmName);
}
public async void LoginRandomOpponent()
{
GetRobotData();
RandomOpponent();
await LoadData();
RandomOpponent();
}
void RandomOpponent()
{
Synchrodata();
nextOpponent = NextOpponent();
LoadNextOpponentResource();
}
public List<OpponentItemData> GetOpponentEnemy()
{
return opponentEnemy.GetValueOrDefault(curEnemyType);
}
public OpponentItemData GetBankHeistOpponent(EnemyType enemyType)
{
this.curEnemyType = enemyType;
if (opponentItemDatasPre == null || opponentItemDatasPre.Count == 0)
{
ClearOpponent();
GetFriendData();
GetRobotData();
}
opponentData = RandomItem();
LoadData();
GetEnemyData(curEnemyType);
if (GMbobmName > 0)
{
opponentData.BombID = GMbobmName;
}
return opponentData;
}
void Synchrodata()
{
if (opponentItemDatasPre != null && opponentItemDatasPre.Count > 0)
{
opponentItemDatas = opponentItemDatasPre;
}
if (opponentFriendItemDatasPre != null && opponentFriendItemDatasPre.Count > 0)
{
opponentFriendItemDatas = opponentFriendItemDatasPre;
}
if (opponentNotFriendItemDatasPre != null && opponentNotFriendItemDatasPre.Count > 0)
{
opponentNotFriendItemDatas = opponentNotFriendItemDatasPre;
}
}
public OpponentItemData RandomItem()
{
OpponentItemData target = nextOpponent;
Synchrodata();
nextOpponent = NextOpponent();
RobotMapId = nextRobotMapId;
LoadNextOpponentResource();
return target;
}
async void LoadNextOpponentResource()
{
if (nextOpponent != null)
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
RobotSetMap();
int mapId;
if (nextOpponent.isRobot)
{
mapId = nextRobotMapId;
}
else
{
mapId = await LoadAquariumResource(nextOpponent.playFabID);
if (mapId > 0)
{
nextRobotMapId = mapId;
}
else
{
mapId = nextRobotMapId;
}
}
Debug.Log($"nextOpponent Next MapID {mapId}");
if (mapId > 0)
{
MapDownloadRes mapData = _tables.TbMapDownloadRes.GetOrDefault(mapId);
if (mapData != null)
{
loadResourceService.Load(mapData.FishRes);
}
}
string bombPrefab = _tables.TbConstruction.GetOrDefault(nextOpponent.BombID)?.BombPrefab;
if (!string.IsNullOrEmpty(bombPrefab))
{
loadResourceService.Load(new List<string>() { bombPrefab });
}
}
}
void RobotSetMap()
{
int curMapId = nextRobotMapId;
var mapDatas = _tables.TbMapData.DataList;
var maxMapID = GContext.container.Resolve<PlayerData>().lastMapId;
//非当前地图
var mapIDs = new List<int>();
for (int i = 0; i < mapDatas.Count; i++)
{
if (mapDatas[i].ID <= maxMapID)
{
if (mapDatas[i].ID != curMapId)
{
mapIDs.Add(mapDatas[i].ID);
}
}
else
{
break;
}
}
if (mapIDs.Count == 0)
{
nextRobotMapId = maxMapID;
}
else
{
nextRobotMapId = mapIDs[UnityEngine.Random.Range(0, mapIDs.Count)];
}
}
async Task<int> LoadAquariumResource(string playFabId)
{
GetAquariumDataRequest request = new GetAquariumDataRequest();
request.playFabId = playFabId;
string result = await customServerMgr.CustomServerPost("aquarium/GetAquariumData", Newtonsoft.Json.JsonConvert.SerializeObject(request));
if (result != null)
{
var resp = JsonConvert.DeserializeObject<GetAquariumDataResp>(result);
if (resp.code == 0)
{
var data = resp.data;
List<AquariumSlotData> slotDatas = data.slotDatas;
if (slotDatas == null)
{
return 0;
}
var time = ZZTimeHelper.UtcNow();
List<AquariumResultData> aquariumResultDatas = data.aquariumResultDatas;
for (int i = 0; i < slotDatas.Count; i++)
{
AquariumSlotData slotData = slotDatas[i];
slotData.index = i;
var HatchTime = slotData.FishHatchTime();
if (HatchTime < time)
{
if (!slotData.IsResult() && aquariumResultDatas.Count > i && !aquariumResultDatas[i].IsResult())
{
return resp.data.mapId;
}
}
}
}
}
return 0;
}
public OpponentItemData NextOpponent()
{
int friendW = Math.Min(100, opponentFriendItemDatas.Count * 20);
if (opponentFriendItemDatas.Count == 0)
{
friendW = 0;
}
int noFriendW = 70;
if (opponentNotFriendItemDatas.Count == 0)
{
noFriendW = 0;
}
int robotW = 30;
int allW = friendW + noFriendW + robotW;
int w = UnityEngine.Random.Range(0, allW);
OpponentItemData target;
if (friendW > 0 && opponentFriendItemDatas.Count > 0 && w < friendW)
{
target = opponentFriendItemDatas[UnityEngine.Random.Range(0, opponentFriendItemDatas.Count)];
target.target_group = 1;
}
else if (noFriendW > 0 && opponentNotFriendItemDatas.Count > 0 && w < friendW + noFriendW)
{
target = opponentNotFriendItemDatas[UnityEngine.Random.Range(0, opponentNotFriendItemDatas.Count)];
target.target_group = 2;
}
else
{
if (opponentItemDatas == null || opponentItemDatas.Count == 0)
{
GetRobotData();
opponentItemDatas = opponentItemDatasPre;
Debug.LogError("opponentItemDatas Count == 0");
}
target = opponentItemDatas[UnityEngine.Random.Range(0, opponentItemDatas.Count)];
target.target_group = 3;
}
return target;
}
void ClearOpponent()
{
Synchrodata();
opponentFriendItemDatasPre = new List<OpponentItemData>();
opponentNotFriendItemDatasPre = new List<OpponentItemData>();
opponentItemDatasPre = new List<OpponentItemData>();
powerData = new Dictionary<string, float>();
opponentFriend = new List<OpponentItemData>();
opponentFriendDic = new Dictionary<string, OpponentItemData>();
}
public async Task LoadData()
{
ClearOpponent();
GetFriendData();
try
{
await GetActiveNotFriendData();
await GetLeaderboardData(curEnemyType);
}
catch (Exception ex)
{
Debug.LogError(ex.Message);
}
GetRobotData();
}
async Task GetActiveNotFriendData()
{
var request = new EventBuildRecommendPlayerRequest();
int lv = GContext.container.Resolve<PlayerData>().lv;
int minLevel = (int)(lv * 0.5f);
if (minLevel < 0)
{
minLevel = 0;
}
request.MinLevel = minLevel;
request.MaxLevel = lv * 2;
request.Exclude = new List<string>();
string json = await customServerMgr.CustomServerPost($"eventpartner/recommend",
Newtonsoft.Json.JsonConvert.SerializeObject(request));
if (!string.IsNullOrEmpty(json) && json != "[]")
{
EventBuildRecommendPlayerResp resp = Newtonsoft.Json.JsonConvert.DeserializeObject<EventBuildRecommendPlayerResp>(json);
if (resp.State == EEventBuildState.Success && resp.Players != null)
{
List<Construction> _dataList = _tables.TbConstruction.DataList;
for (int i = 0; i < resp.Players.Count; i++)
{
if (resp.Players[i].PlayFabId == userService.UserId)
{
continue;
}
OpponentItemData opponentItemData = new OpponentItemData();
opponentItemData.playFabID = resp.Players[i].PlayFabId;
opponentItemData.target_source = 2;
userService.SetPlayInfo(resp.Players[i].PlayFabId, resp.Players[i].DisplayName, resp.Players[i].AvatarUrl);
userService.SetPlayerLv(resp.Players[i].PlayFabId, resp.Players[i].Level);
int level = resp.Players[i].Level;
int id = _dataList[0].ID;
for (int j = _dataList.Count - 1; j >= 0; j--)
{
if (_dataList[j].InitialLevel <= level)
{
id = _dataList[j].ID;
break;
}
}
opponentItemData.BombID = id;
opponentItemData.power = (float)Math.Log10(BottleCashParamBase + level / BottleCashParamLevel) / BottleCashParamDiv;
powerData[opponentItemData.playFabID] = opponentItemData.power;
//opponentItemDatasPre.Add(opponentItemData);
opponentNotFriendItemDatasPre.Add(opponentItemData);
}
}
}
}
void GetFriendData()
{
var FriendList = GContext.container.Resolve<FriendService>().FriendList;
opponentFriendItemDatasPre.Clear();
DateTime dateTime = ZZTimeHelper.UtcNow().Date.AddDays(-1);
if (FriendList != null && FriendList.Count > 0)
{
List<Construction> _dataList = _tables.TbConstruction.DataList;
for (int i = 0; i < FriendList.Count; i++)
{
if (FriendList[i].playFabId == userService.UserId)
{
continue;
}
OpponentItemData opponentItemData = new OpponentItemData();
opponentItemData.playFabID = FriendList[i].playFabId;
opponentItemData.target_source = 1;
//if (FriendList[i].LastLogin != null && FriendList[i].LastLogin > dateTime)
//{
opponentFriendItemDatasPre.Add(opponentItemData);
//}
int level = FriendList[i].value / LeadboardData.LV_MODELING;
int id = _dataList[0].ID;
for (int j = _dataList.Count - 1; j >= 0; j--)
{
if (_dataList[j].InitialLevel <= level)
{
id = _dataList[j].ID;
break;
}
}
opponentItemData.BombID = id;
opponentItemData.power = (float)Math.Log10(BottleCashParamBase + level / BottleCashParamLevel) / BottleCashParamDiv;
powerData[opponentItemData.playFabID] = opponentItemData.power;
//opponentItemDatasPre.Add(opponentItemData);
opponentFriend.Add(opponentItemData);
opponentFriendDic[opponentItemData.playFabID] = opponentItemData;
}
}
}
public async void SetEnemy(EnemyType enemyType, long glod)
{
if (!opponentData.isRobot)
{
SetEnemyIDRequest setEnemyCampIDRequest = new SetEnemyIDRequest()
{
enemyType = enemyType,
playerID = userService.UserId,
albumEventID = AlbumEventID,
enemyID = opponentData.playFabID,
content = glod.ToString()
};
var customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
string json = await customServerMgr.BombRequest("SetEnemyID", setEnemyCampIDRequest);
if (!string.IsNullOrEmpty(json) && json != "[]")
{
SetEnemyIDResponse setCampIDResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<SetEnemyIDResponse>(json);
}
}
}
//向服务器请求仇人列表
async Task GetEnemyData(EnemyType enemyType)
{
GetEnemyIDRequest getEnemyCampIDRequest = new GetEnemyIDRequest()
{
playerID = userService.UserId,
enemyType = enemyType,
albumEventID = AlbumEventID,
};
var customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
string json = await customServerMgr.BombRequest("GetEnemyID", getEnemyCampIDRequest);
if (!string.IsNullOrEmpty(json) && json != "[]")
{
GetEnemyIDResponse getCampIDResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<GetEnemyIDResponse>(json);
if (getCampIDResponse.enemyIDs == null)
{
return;
}
List<EventPopupData> eventPopupDatas = GContext.container.Resolve<ClubService>().eventPopupDatas;
//DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset();
//EventPopupData eventPopupData;
int count;
ReportDataType reportDataType = ReportDataType.Bomb;
switch (enemyType)
{
case EnemyType.Bomb:
reportDataType = ReportDataType.Bomb;
break;
case EnemyType.Heist:
reportDataType = ReportDataType.Heist;
break;
case EnemyType.Aquarium:
reportDataType = ReportDataType.Aquarium;
break;
}
List<OpponentItemData> opponentItemDatas = new List<OpponentItemData>();
opponentEnemy[enemyType] = opponentItemDatas;
eventPopupDatas = eventPopupDatas.Where(x => (int)(x.type) == (int)reportDataType).ToList();
for (int i = 0; i < getCampIDResponse.enemyIDs.Count; i++)
{
if (getCampIDResponse.enemyIDs[i] == userService.UserId)
{
continue;
}
OpponentItemData opponentItemData = new OpponentItemData();
opponentItemData.playFabID = getCampIDResponse.enemyIDs[i];
//if (string.IsNullOrEmpty(getCampIDResponse.avatar[i]) && string.IsNullOrEmpty(getCampIDResponse.displayName[i]))
//{
// userService.GetPlayInfo(opponentItemData.playFabID);
//}
//else
//{
// userService.SetPlayInfo(opponentItemData.playFabID, getCampIDResponse.displayName[i], getCampIDResponse.avatar[i]);
//}
if (getCampIDResponse.enemyType == EnemyType.Bomb)
{
opponentItemData.BombID = getCampIDResponse.campID[i];
}
if (powerData.ContainsKey(opponentItemData.playFabID))
{
opponentItemData.power = powerData[opponentItemData.playFabID];
}
else
{
opponentItemData.power = 1;
}
count = eventPopupDatas.Where(x => x.playerID == opponentItemData.playFabID).Count();
if (reportDataType == ReportDataType.Aquarium)
{
if (count > 1)
{
opponentItemData.info = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistOpponentPopupPanel_3", count);
}
else
{
opponentItemData.info = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistOpponentPopupPanel_5", 1);
}
}
else
{
if (count > 1)
{
opponentItemData.info = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistOpponentPopupPanel_6", count);
}
else
{
opponentItemData.info = LocalizationMgr.GetFormatTextValue("UI_EventBankHeistOpponentPopupPanel_7", 1);
}
}
if (opponentFriendDic.TryGetValue(opponentItemData.playFabID, out OpponentItemData friendData))
{
friendData.info = opponentItemData.info;
}
opponentItemData.target_source = 4;
opponentItemDatas.Add(opponentItemData);
//opponentNotFriendItemDatasPre.Add(opponentItemData);
}
}
}
void GetRobotData()
{
int count = opponentItemDatasPre.Count;
int allCount = 20;
if (count >= 20)
{
allCount = count + 1;
}
var robots = new List<cfg.Robot>(_tables.TbRobot.DataList);
cfg.Robot robot;
int myID = campData.Id;
cfg.TbConstruction tbConstruction = _tables.TbConstruction;
int constructionFirstId = tbConstruction.DataList[0].ID % 1000;
int constructionLastId = tbConstruction.DataList[^1].ID;
int campId;
for (int i = count; i < allCount; i++)
{
robot = robots[UnityEngine.Random.Range(0, robots.Count)];
robots.Remove(robot);
OpponentItemData opponentItemData = new OpponentItemData();
opponentItemData.playFabID = robot.ID.ToString("X");
opponentItemData.target_source = -1;
userService.SetPlayInfo(opponentItemData.playFabID, LocalizationMgr.GetText(robot.Name_l10n_key), robot.Avatar);
//opponentItemData.playName = robot.Name;
//opponentItemData.url = robot.Avatar;
opponentItemData.isRobot = true;
campId = robot.ConstructionOffset + myID;
if (campId < constructionFirstId)
{
campId = constructionFirstId;
}
if (campId > constructionLastId)
{
campId = constructionLastId;
}
opponentItemData.BombID = campId;
opponentItemData.power = (float)Math.Log10(BottleCashParamBase - i) / BottleCashParamDiv;
opponentItemDatasPre.Add(opponentItemData);
}
}
async Task GetLeaderboardData(EnemyType enemyType)
{
FishingEventData _fishingEventData = GContext.container.Resolve<FishingEventData>();
if (!_fishingEventData.IsOpenRank())
{
return;
}
LeadboardData leadboardData = GContext.container.Resolve<LeadboardData>();
if (leadboardData.curEventRank == null)
{
return;
}
Dictionary<int, cfg.Robot> robots = GContext.container.Resolve<cfg.Tables>().TbRobot.DataMap;
GetLeaderboardsResp curEventRank = leadboardData.curEventRank;
int myID = campData.Id;
cfg.TbConstruction tbConstruction = _tables.TbConstruction;
int constructionFirstId = tbConstruction.DataList[0].ID % 1000;
int constructionLastId = tbConstruction.DataList[^1].ID;
int campId = myID;
Dictionary<string, OpponentItemData> playerList = new Dictionary<string, OpponentItemData>();
for (int i = 0; i < curEventRank.data.Length; i++)
{
if (curEventRank.data[i].isMe || curEventRank.data[i].id == userService.UserId)
{
continue;
}
if (curEventRank.data[i].id == null || powerData.ContainsKey(curEventRank.data[i].id))
{
continue;
}
OpponentItemData opponentItemData = new OpponentItemData();
opponentItemData.playFabID = curEventRank.data[i].id;
if (curEventRank.data[i].isBot)
{
int b = Convert.ToInt32(opponentItemData.playFabID, 16);
if (robots.TryGetValue(b, out cfg.Robot robot))
{
campId = robot.ConstructionOffset + myID;
}
if (campId < constructionFirstId)
{
campId = constructionFirstId;
}
if (campId > constructionLastId)
{
campId = constructionLastId;
}
opponentItemData.isRobot = true;
opponentItemData.target_source = -1;
opponentItemDatasPre.Add(opponentItemData);
}
else
{
playerList[opponentItemData.playFabID] = opponentItemData;
opponentItemData.target_source = 3;
userService.GetPlayInfo(opponentItemData.playFabID);
opponentNotFriendItemDatasPre.Add(opponentItemData);
}
opponentItemData.BombID = campId;
opponentItemData.power = (float)Math.Log10(BottleCashParamBase - curEventRank.data[i].rank) / BottleCashParamDiv;
powerData[opponentItemData.playFabID] = opponentItemData.power;
}
if (playerList.Count > 0 && enemyType == EnemyType.Bomb)
{
await GetCampID(playerList);
}
}
async Task GetCampID(Dictionary<string, OpponentItemData> playerList)
{
List<string> playFabIds = playerList.Values.Select(x => x.playFabID).ToList();
GetCampIDRequest getCampIDRequest = new GetCampIDRequest()
{
playerIDs = playFabIds
};
var customServerMgr = GContext.container.Resolve<ICustomServerMgr>();
string json = await customServerMgr.BombRequest("GetCampID", getCampIDRequest);
if (!string.IsNullOrEmpty(json) && json != "[]")
{
GetCampIDResponse getCampIDResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<GetCampIDResponse>(json);
if (getCampIDResponse != null && getCampIDResponse.campIDs != null && getCampIDResponse.campIDs.Count > 0)
{
foreach (var item in getCampIDResponse.campIDs)
{
playerList[item.Key].BombID = item.Value;
}
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aca10482d9302f74dab4311907998f2d
timeCreated: 1693915587

View File

@@ -0,0 +1,645 @@
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;
string userID = GContext.container.Resolve<IUserService>().UserId;
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);
}
PlayerPrefs.DeleteKey($"{triggerPackList[i].ID}_{userID}");
if (triggerPackList[i].mapID <= 0)
{
triggerPackList[i].mapID = GContext.container.Resolve<PlayerData>().currentMapId;
}
if (triggerPackList[i].lastID == 53)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPackList[i].ID, UITypes.MapPackPanel, triggerPackList[i].lastID);
}
else if (triggerPackList[i].lastID == 2)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPackList[i].ID, UITypes.CommerceNoviceGiftPopupPanel, triggerPackList[i].lastID);
}
else if (triggerPackList[i].lastID == 1)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPackList[i].ID, UITypes.GiftPopupPanel_6, triggerPackList[i].lastID);
}
else if (triggerPackList[i].lastID == 5)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPackList[i].ID, UITypes.AdsPackPanel, triggerPackList[i].lastID);
}
//else if (triggerPackList[i].lastID == 4)
//{
// GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(triggerPackList[i].ID, UITypes.GiftPopupPanel_8, 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)
{
string userID = GContext.container.Resolve<IUserService>().UserId;
PlayerPrefs.DeleteKey($"{t.ID}_{userID}");
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.MapPackPanel, t.PackType);
GContext.Publish(new TriggerPackEvent());
}
else if (t.PackType == 2)
{
//SetPack2Panel(t);
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.CommerceNoviceGiftPopupPanel, t.PackType);
GContext.Publish(new TriggerPackEvent());
}
else if (t.PackType == 1)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.GiftPopupPanel_6, t.PackType);
}
//else if (t.PackType == 4)
//{
// GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.GiftPopupPanel_8, t.PackType);
//}
//break;
}
}
}
}
/// <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>().AddGiftFaceUI(_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 || (t.PackType == 4 && !FixedTimeEventExpired(t.ID)))
{
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 || (t.PackType == 4 && !FixedTimeEventExpired(t.ID))))
{
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.TbPriceLevel.DataList.Count)
{
vipLevel = _tables.TbPriceLevel.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)
|| t.PackType == 4)
{
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]);
}
}
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);
PlayerPrefs.DeleteKey(t.ID.ToString());
if (t.PackType == 53)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.MapPackPanel, t.PackType);
}
else if (t.PackType == 2)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.CommerceNoviceGiftPopupPanel, t.PackType);
}
else if (t.PackType == 1)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.GiftPopupPanel_6, t.PackType);
}
//else if (t.PackType == 4)
//{
// GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(t.ID, UITypes.GiftPopupPanel_8, 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
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef4777e4e0a749846b90cd1f0f7f4338
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using asap.core;
using cfg;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class DateTimeExtensions
{
/// <summary>
///游戏本地零点时间 相对于UTC时间的偏移 offset 个小时,计算每周几、每日几时(跨天=每日0时这种到期时间
///或者统一计算需求 调用此方法
///自己记录时间段 比如从当前时间往后推一段时间不需要 调用此方法
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static DateTime UtcNowOffset(this DateTime dateTime)
{
var offset = GContext.container.Resolve<Tables>().TbGlobalConfig.GlobalTimeOffset;
return dateTime.AddHours(-offset);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc29202e7de2fd849a6f3a865a2bdff6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,104 @@
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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a29eafb56952d4940a8a80ce760c3485
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,600 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using asap.core;
using cfg;
using game;
using GameCore;
using Newtonsoft.Json;
using UnityEngine;
namespace DataCenter
{
// EventPartnerGather 游戏数据结构
public class EventPartnerGatherData
{
public bool FirstOpen = true;
public int EventId;
public DateTime StartTime;
public DateTime EndTime;
// 核心游戏数据
public int CurrentPoints = 0; // 当前积分
public int CurrentMiningProgress = 0; // 挖矿进度
public int TrainProgress = 0; // 火车进度 (0-5节点)
public List<int> CompletedNodes = new List<int>(); // 已完成的节点
// 好友系统数据(第二阶段)
public List<FriendData> Friends = new List<FriendData>();
public int InvitedCount = 0;
// 奖励记录
public List<int> CollectedRewards = new List<int>();
public bool IsFinished = false;
public float BonusPercent = 0f;
public DateTime BonusExpireUtc = DateTime.MinValue;
public class FriendData
{
public string Id;
public string Name;
public int MiningProgress;
public int ContributionPoints;
public bool IsActive;
}
}
// EventPartnerGather 管理器
public class EventPartnerGatherManager
{
public const string SaveKey = "EventPartnerGatherData";
[Inject] public Tables _tables { get; set; }
private FishingEvent _fishingEvent;
// 检查数据是否改变过
private bool _isEventDataChanged = false;
public EventPartnerGatherData GatherData { get; private set; }
// 数据
public EventPartnerMain2 EventPartnerMain2Data { get; private set; }
// 抽奖数据
public List<EventPartnerSpinPoint> EventPartnerSpinPointList { get; private set; }
// 模型数据,目前开来需要构造模型从表里读取
public EventPartnerInit EventPartnerInitData { get; private set; }
// 累分状态
private readonly List<int> _nodeCumulativeSteps = new List<int>();
// 配置数据(后续从表格读取)
public int MaxTrainNodes => 5;
public int PointsPerMining => 10;
public int PointsPerNode => 100;
public bool IsFirstOpen
{
get => GatherData?.FirstOpen ?? false;
set
{
if (GatherData != null && GatherData.FirstOpen)
{
GatherData.FirstOpen = false;
SaveData();
}
}
}
public void UpdateEventData(FishingEvent fishingEvent)
{
Log($"UpdateEventData: {fishingEvent?.ID}");
_fishingEvent = fishingEvent;
InitializeData();
// }
}
public void CheckInit()
{
Init();
}
public void Init()
{
Log("Init()-> ");
if (GatherData == null && _fishingEvent != null)
{
CreateNewData();
}
//TODO:LF 等上面触发完成之后,移走
//TODO:LF:后面优化 2025-09-17
InitializeData();
ValidateAndUpdateData();
}
private void CreateNewData()
{
var limitedTime = (LimitedTime)_fishingEvent.TimeDefinition;
var startTime = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow());
var endTime = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow());
GatherData = new EventPartnerGatherData
{
FirstOpen = true,
EventId = _fishingEvent.ID,
StartTime = startTime,
EndTime = endTime,
CurrentPoints = 0,
CurrentMiningProgress = 0,
TrainProgress = 0
};
SaveData();
}
private void InitializeData()
{
Log("InitializeData() -> ");
if (_fishingEvent == null) return;
var redirectId = _fishingEvent.RedirectID;
var eventPartnerDataList = _tables.TbEventPartnerMain2.DataList;
EventPartnerMain2Data = eventPartnerDataList.FirstOrDefault(data => data.ID == redirectId);
var allSpinPoints = _tables.TbEventPartnerSpinPoint.DataList;
var ids = EventPartnerMain2Data?.SpinPoint;
if (ids != null && ids.Count > 0)
{
var filtered = new List<EventPartnerSpinPoint>();
foreach (var id in ids)
{
var sp = _tables.TbEventPartnerSpinPoint.GetOrDefault(id);
if (sp != null) filtered.Add(sp);
}
EventPartnerSpinPointList = filtered;
}
else
{
EventPartnerSpinPointList = new List<EventPartnerSpinPoint>();
}
_nodeCumulativeSteps.Clear();
if (EventPartnerMain2Data?.StagePoint != null && EventPartnerMain2Data.StagePoint.Count > 0)
{
int sum = 0;
for (int i = 0; i < EventPartnerMain2Data.StagePoint.Count; i++)
{
sum += EventPartnerMain2Data.StagePoint[i];
_nodeCumulativeSteps.Add(sum);
}
}
var eventPartnerInitDataList = _tables.TbEventPartnerInit.DataList;
// foreach (var eventPartnerInitData in eventPartnerInitDataList.Where(data => data.ID == redirectId))
// {
// EventPartnerInitData = eventPartnerInitData;
// }
EventPartnerInitData = eventPartnerInitDataList.FirstOrDefault(data => data.ID == redirectId);
// 检查是否需要重置数据
if (GatherData != null && !IsTimeValid())
{
HandleEventEnd();
GatherData = null;
}
}
private void ValidateAndUpdateData()
{
if (GatherData == null) return;
// 验证时间有效性
if (!IsTimeValid())
{
HandleEventEnd();
}
}
public bool IsTimeValid()
{
if (GatherData == null) return false;
var now = ZZTimeHelper.UtcNow();
return now >= GatherData.StartTime && now <= GatherData.EndTime;
}
public TimeSpan GetRemainingTime()
{
if (GatherData == null)
return TimeSpan.Zero;
return GatherData.EndTime - ZZTimeHelper.UtcNow();
}
public bool CheckOpen()
{
if (GatherData == null) return false;
if (!IsTimeValid()) return false;
if (GatherData.IsFinished) return false;
return true;
}
// 核心游戏逻辑
// 抽奖数据
public EventPartnerSpinPoint GetSpinPointElem()
{
// if (EventPartnerSpinPointList is { Count: > 0 })
// {
// // 根据权重,生成字典
// var dict = EventPartnerSpinPointList.ToDictionary(elem => elem, elem => elem.Weight);
// var elem = OfferChainsChestManager.WeightedRandom(dict);
// Log($"GetSpinPointElem -> {elem.ID}");
// return elem;
// }
return null;
}
public void AddPoints(int points)
{
if (GatherData == null)
{
Log("错误GatherData 为空,无法添加积分");
return;
}
if (GatherData.IsFinished)
{
Log("警告:游戏已结束,无法添加积分");
return;
}
if (points <= 0)
{
Log($"警告:尝试添加无效积分值:{points}");
return;
}
EnsureBonusValid();
float mult = 1f + Mathf.Max(0f, GatherData.BonusPercent);
int eff = Mathf.Max(0, Mathf.RoundToInt(points * mult));
// 防止积分溢出
long newPoints = (long)GatherData.CurrentPoints + eff;
if (newPoints > int.MaxValue)
{
Log($"警告:积分即将溢出,限制在最大值");
GatherData.CurrentPoints = int.MaxValue;
}
else
{
GatherData.CurrentPoints += eff;
}
Log($"AddPoints: {eff}, TotalPoints: {GatherData.CurrentPoints}");
SaveData();
GContext.Publish(new EventPartnerGatherPointsUpdate { Points = GatherData.CurrentPoints });
// 检查是否需要触发自动挖矿
CheckAutoMining();
}
private void CheckAutoMining()
{
// 每累积一定积分自动触发挖矿
bool dataChanged = false;
while (GatherData.CurrentPoints >= PointsPerMining)
{
GatherData.CurrentPoints -= PointsPerMining;
GatherData.CurrentMiningProgress++;
dataChanged = true;
// 检查节点完成
CheckNodeProgress();
}
// 如果数据有变化,发布更新事件
if (dataChanged)
{
SaveData();
PublishDataUpdateEvents();
}
}
private void CheckNodeProgress()
{
int completedNodes = 0;
if (_nodeCumulativeSteps != null && _nodeCumulativeSteps.Count > 0)
{
for (int i = 0; i < _nodeCumulativeSteps.Count; i++)
{
if (GatherData.CurrentMiningProgress >= _nodeCumulativeSteps[i]) completedNodes++;
else break;
}
}
if (completedNodes > GatherData.TrainProgress)
{
int target = Mathf.Min(completedNodes, MaxTrainNodes);
for (int idx = GatherData.TrainProgress; idx < target; idx++)
{
CompleteTrainNode(idx);
}
GatherData.TrainProgress = target;
if (GatherData.TrainProgress >= MaxTrainNodes)
{
HandleGameComplete();
}
}
}
private void CompleteTrainNode(int nodeIndex)
{
Log($"CompleteNode: {nodeIndex}");
if (!GatherData.CompletedNodes.Contains(nodeIndex))
{
GatherData.CompletedNodes.Add(nodeIndex);
// 发放节点奖励
DistributeNodeReward(nodeIndex);
}
}
private void DistributeNodeReward(int nodeIndex)
{
// 使用现有的奖励系统
var dropId = GetNodeRewardDropId(nodeIndex);
if (dropId > 0)
{
var playerItemData = GContext.container.Resolve<PlayerItemData>();
var rewards = playerItemData.GetItemDataByDropId(dropId);
playerItemData.AddItem(rewards);
GContext.Publish(new ShowData(rewards));
GatherData.CollectedRewards.Add(dropId);
SaveData();
}
}
private int GetNodeRewardDropId(int nodeIndex)
{
// 根据节点返回对应的掉落ID后续从配置表读取
return 10000 + nodeIndex;
}
private void HandleGameComplete()
{
Log("Game Complete!");
GatherData.IsFinished = true;
// 发放最终大奖
DistributeFinalReward();
SaveData();
GContext.Publish(new EventPartnerGatherComplete());
}
private void DistributeFinalReward()
{
var dropId = GetFinalRewardDropId();
if (dropId > 0)
{
var playerItemData = GContext.container.Resolve<PlayerItemData>();
var rewards = playerItemData.GetItemDataByDropId(dropId);
playerItemData.AddItem(rewards);
GContext.Publish(new ShowData(rewards));
}
}
private int GetFinalRewardDropId()
{
// 最终奖励掉落ID后续从配置表读取
return 99999;
}
private void HandleEventEnd()
{
if (GatherData == null || GatherData.IsFinished) return;
Log("Event Ended");
// 结算未领取的奖励
if (GatherData.TrainProgress >= MaxTrainNodes && !GatherData.IsFinished)
{
HandleGameComplete();
}
ClearData();
}
public int ResolveSpinAndGetPoints(EventPartnerSpinPoint p)
{
if (p == null || p.SpinPointParam == null) return 0;
switch (p.SpinPointParam)
{
case NormalSpinPoint n:
return Mathf.Max(0, n.SpinPoints);
case FreeSpinPoint f:
return Mathf.Max(0, f.SpinPoints);
case MoreSpinPoint m:
ApplyBonus(m.BonusPercent, m.BonusDuration);
return 0;
}
return 0;
}
private void ApplyBonus(float percent, int durationSec)
{
if (GatherData == null) return;
GatherData.BonusPercent = Mathf.Max(0f, percent);
GatherData.BonusExpireUtc = ZZTimeHelper.UtcNow().AddSeconds(Mathf.Max(0, durationSec));
SaveData();
GContext.Publish(new EventPartnerGatherRefreshEvent());
}
private void EnsureBonusValid()
{
if (GatherData == null) return;
if (GatherData.BonusPercent > 0f && ZZTimeHelper.UtcNow() > GatherData.BonusExpireUtc)
{
GatherData.BonusPercent = 0f;
GatherData.BonusExpireUtc = DateTime.MinValue;
SaveData();
GContext.Publish(new EventPartnerGatherRefreshEvent());
}
}
public bool IsBonusActive()
{
return GatherData != null && GatherData.BonusPercent > 0f && ZZTimeHelper.UtcNow() <= GatherData.BonusExpireUtc;
}
private void SaveData()
{
if (GatherData != null)
{
PlayFabMgr.Instance.UpdateUserDataValue(SaveKey, JsonConvert.SerializeObject(GatherData));
}
}
public void LoadData(string dataValue)
{
if (!string.IsNullOrEmpty(dataValue))
{
GatherData = JsonConvert.DeserializeObject<EventPartnerGatherData>(dataValue);
}
}
private void ClearData()
{
GatherData = null;
SaveData();
}
// 进入游戏场景
public void EnterGatherScene()
{
Log("EnterGatherScene() ");
IsFirstOpen = false;
GContext.Publish(new UnloadActToNextAct("EventPartnerGatherAct", UITypes.CloudTransitionPanel, 0.5f));
}
// 开始采矿
public void StartMining()
{
// throw new NotImplementedException();
Log("StartMining()");
((EventPartnerGatherAct)_act)?.OnEnterGather();
}
private static void Log(object t)
{
Debug.Log($"<color=cyan>EventPartnerGatherManager-> {t} </color>");
}
private AGameAct _act;
public void SetGameAct(AGameAct act)
{
_act = act;
}
// 组件绑定管理
private UI.PartnerGather.Mining.EventPartnerMiningSceneController _miningController;
private UI.PartnerGather.Mining.EventPartnerDrawMiningPanel _drawPanel;
/// <summary>
/// 设置挖矿场景控制器引用
/// </summary>
public void SetMiningController(UI.PartnerGather.Mining.EventPartnerMiningSceneController controller)
{
_miningController = controller;
Log($"设置挖矿控制器: {controller?.name ?? "null"}");
}
/// <summary>
/// 设置抽奖UI面板引用
/// </summary>
public void SetDrawPanel(UI.PartnerGather.Mining.EventPartnerDrawMiningPanel panel)
{
_drawPanel = panel;
Log($"设置抽奖面板: {panel?.name ?? "null"}");
}
/// <summary>
/// 获取挖矿控制器引用
/// </summary>
public UI.PartnerGather.Mining.EventPartnerMiningSceneController GetMiningController()
{
return _miningController;
}
/// <summary>
/// 获取抽奖面板引用
/// </summary>
public UI.PartnerGather.Mining.EventPartnerDrawMiningPanel GetDrawPanel()
{
return _drawPanel;
}
/// <summary>
/// 通知所有绑定组件刷新数据显示
/// </summary>
public void RefreshAllUI()
{
if (GatherData == null) return;
// 刷新抽奖面板
if (_drawPanel != null)
{
_drawPanel.SetPoints(GatherData.CurrentPoints);
_drawPanel.SetMiningProgress(GatherData.CurrentMiningProgress);
_drawPanel.SetTrainProgress(GatherData.TrainProgress, MaxTrainNodes);
}
Log("已刷新所有UI组件数据");
}
/// <summary>
/// 发布所有相关的数据更新事件
/// </summary>
private void PublishDataUpdateEvents()
{
if (GatherData == null) return;
// 发布积分更新事件
GContext.Publish(new EventPartnerGatherPointsUpdate { Points = GatherData.CurrentPoints });
// 发布挖矿进度更新事件
GContext.Publish(new EventPartnerGatherMiningProgressUpdate { Progress = GatherData.CurrentMiningProgress });
// 发布火车进度更新事件
GContext.Publish(new EventPartnerGatherTrainProgressUpdate { Progress = GatherData.TrainProgress, MaxNodes = MaxTrainNodes });
// 刷新绑定的UI组件
RefreshAllUI();
Log($"已发布数据更新事件 - 积分:{GatherData.CurrentPoints}, 挖矿进度:{GatherData.CurrentMiningProgress}, 火车进度:{GatherData.TrainProgress}");
}
// 有可能会激活不应该在OnEnable 中调用Init();
public void CheckForOnEnable()
{
//throw new NotImplementedException();
}
}
// 事件定义
public class EventPartnerGatherPointsUpdate
{
public int Points;
}
public class EventPartnerGatherMiningProgressUpdate
{
public int Progress;
}
public class EventPartnerGatherTrainProgressUpdate
{
public int Progress;
public int MaxNodes;
}
public class EventPartnerGatherComplete { }
public class EventPartnerGatherRefreshEvent { }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f95f8f9583c44b42b1dc962c27e1ab2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eb55f075247d59545972b20331a48298
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a820a96497d1fb840b4d55f4bda2a44f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,936 @@
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using System.Linq;
using UniRx;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.U2D;
using UnityEngine.UI;
namespace game
{
public class EventScratchTicketDataManager
{
#if UNITY_EDITOR
private bool m_IsCheckCondition = true;
private bool m_IsSyncData = true;
private int m_DefaultToken = 100;
#else
private bool m_IsCheckCondition = true;
private bool m_IsSyncData = true;
private int m_DefaultToken = 0;
#endif
#region
public int TempRecordRewardTaskID { get; set; } = 0;
public int TempRecordRewardTaskConsumedToken { get; set; } = 0;
public void SyncTempRecordData()
{
ClearRecordList();
TempRecordRewardTaskID = m_ScratchTicketData.EventScratchRewardTaskID;
TempRecordRewardTaskConsumedToken = m_ScratchTicketData.RewardTaskConsumedToken;
}
public void RecordStatisticalData()
{
int fromToken = TempRecordRewardTaskConsumedToken;
int taskID = TempRecordRewardTaskID;
EventScratchReward curScratchReward = GetEventScratchReward(taskID);
int count = m_RecordList.Count;
for (int i = 0; i < count; i++)
{
var data = m_RecordList[i];
fromToken += 1;
if (fromToken >= curScratchReward.TokenRequired)
{
data.MilestoneTask = curScratchReward.TaskID;
fromToken = 0;
taskID = curScratchReward.NextTask;
curScratchReward = GetEventScratchReward(taskID);
}
#if AGG
using (var e = GEvent.GameEvent("event_scratchticket"))
{
e.AddContent("ticket_id", data.TicketID)
.AddContent("ticketfinish_id", data.TicketFinishID)
.AddContent("scratch_type", data.ScratchType)
.AddContent("milestone_task", data.MilestoneTask);
}
#endif
}
#if UNITY_EDITOR
Debug.LogError("--- RecordStatisticalData m_RecordList: " + Newtonsoft.Json.JsonConvert.SerializeObject(m_RecordList));
#endif
}
private List<EventScratchTicketRecordData> m_RecordList = new List<EventScratchTicketRecordData>();
public void InitRecordList()
{
ClearRecordList();
}
public void ClearRecordList()
{
m_RecordList?.Clear();
TempRecordRewardTaskID = 0;
TempRecordRewardTaskConsumedToken = 0;
}
public EventScratchTicketRecordData AddRecordData()
{
EventScratchTicketRecordData data = new EventScratchTicketRecordData();
m_RecordList.Add(data);
return data;
}
public EventScratchTicketRecordData GetRecordData(int index)
{
return m_RecordList[index];
}
#endregion
#region
private EventScratchTicketData m_ScratchTicketData;
public EventScratchTicketData ScratchTicketData { get { return m_ScratchTicketData; } }
public EventScratchMain GetFreshScratchTicketData()
{
// 获取当前开放并符合解锁条件的刮刮乐活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(7, 3, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int scratchMainID = fishingEvent.RedirectID;
if (scratchMainID < 0) return null;
// 获取当前刮刮乐活动数据
EventScratchMain scratchMain = m_TbEventScratchMain.GetOrDefault(scratchMainID);
if (scratchMain == null) return null;
int token = m_DefaultToken;
if (m_ScratchTicketData != null) m_ScratchTicketData.Clear();
m_ScratchTicketData = null;
token = GContext.container.Resolve<FishingEventData>().GetInitWelcomeGift2(eventID);
m_ScratchTicketData = new EventScratchTicketData();
m_ScratchTicketData.EventID = eventID;
m_ScratchTicketData.ScratchMainID = scratchMainID;
m_ScratchTicketData.IsOver = false;
m_ScratchTicketData.Token = token;
m_ScratchTicketData.ConsumedToken = 0;
m_ScratchTicketData.LuckyValue = 0f;
m_ScratchTicketData.EventScratchCardID = 0;
m_ScratchTicketData.TotalConsumedToken = 0;
m_ScratchTicketData.ChainPackProgress = 0;
m_ScratchTicketData.StampRewardDict = new Dictionary<int, EventScratchTicketOwnedStampRewardData>();
EventScratchReward eventScratchReward = m_TbEventScratchReward.DataList[0];
m_ScratchTicketData.EventScratchRewardTaskID = eventScratchReward.TaskID;
m_ScratchTicketData.RewardTaskConsumedToken = 0;
m_ScratchTicketData.StampRewardList.Clear();
ClearSaveData(EventScratchTicketConfig.key_first_in);
GContext.container.Resolve<FishingEventData>().SaveTransitionData(m_ScratchTicketData.EventID, m_ScratchTicketData.Token);
UpdateLuckyValueAndWeight();
foreach (var item in scratchMain.GuidanceGroupList)
{
GContext.container.Resolve<GuideDataCenter>().ClearGuide(item);
}
// 同步数据
SyncData();
return scratchMain;
}
public EventScratchMain GetNextScratchTicketData()
{
// 获取当前开放并符合解锁条件的刮刮乐活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(7, 3, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int scratchMainID = fishingEvent.RedirectID;
if (scratchMainID < 0) return null;
// 获取当前刮刮乐活动数据
EventScratchMain scratchMain = m_TbEventScratchMain.GetOrDefault(scratchMainID);
if (scratchMain == null) return null;
m_ScratchTicketData.EventID = eventID;
m_ScratchTicketData.ScratchMainID = scratchMainID;
m_ScratchTicketData.IsOver = false;
m_ScratchTicketData.ConsumedToken = 0;
UpdateLuckyValueAndWeight();
// 同步数据
SyncData();
return scratchMain;
}
public EventScratchMain ContinueGame()
{
if (m_ScratchTicketData == null) return GetFreshScratchTicketData();
// 获取当前开放并符合解锁条件的刮刮乐活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(7, 3, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int scratchMainID = fishingEvent.RedirectID;
if (scratchMainID < 0) return null;
if (eventID != m_ScratchTicketData.EventID || scratchMainID != m_ScratchTicketData.ScratchMainID) return GetFreshScratchTicketData();
// 获取当前刮刮乐活动数据
EventScratchMain scratchMain = m_TbEventScratchMain.GetOrDefault(scratchMainID);
if (scratchMain == null) return null;
return scratchMain;
}
public List<float> m_PointWeightList = new List<float>();
public EventScratchCard UpdateLuckyValueAndWeight()
{
if (m_TbEventScratchCard == null) return null;
m_PointWeightList.Clear();
float luckyValue = m_ScratchTicketData.LuckyValue;
int count = m_TbEventScratchCard.DataList.Count;
float total = 0;
for (int i = 0; i < count; ++i)
{
EventScratchCard item = m_TbEventScratchCard.DataList[i];
float weight = item.Weight + luckyValue * item.LuckParameter;
total += weight;
float tmp = total;
m_PointWeightList.Add(tmp);
}
float randomValue = UnityEngine.Random.Range(0f, total);
int index = FindInsertionIndex(m_PointWeightList, randomValue);
EventScratchCard target = m_TbEventScratchCard.DataList[index];
if (float.MaxValue - target.DeltaLuck <= m_ScratchTicketData.LuckyValue)
{
m_ScratchTicketData.LuckyValue = 0;
}
else
{
m_ScratchTicketData.LuckyValue += target.DeltaLuck;
if (m_ScratchTicketData.LuckyValue < 0f)
{
m_ScratchTicketData.LuckyValue = 0f;
}
}
m_ScratchTicketData.EventScratchCardID = target.ID;
return target;
}
public EventScratchCard GetCurrentEventScratchCard()
{
if (m_ScratchTicketData == null) return null;
return GetEventScratchCard(m_ScratchTicketData.EventScratchCardID);
}
public int FindInsertionIndex(List<float> sortedList, float target)
{
if (sortedList == null || sortedList.Count == 0)
{
Debug.LogError("---- EventScratchTicketDataManager->FindInsertionIndex 数组为空");
return -1;
}
if (target < sortedList[0])
{
return 0;
}
if (target >= sortedList[sortedList.Count - 1])
{
return -1;
}
// 使用二分查找算法
int left = 0;
int right = sortedList.Count - 1;
int result = -1;
while (left <= right)
{
int mid = left + (right - left) / 2;
if (sortedList[mid] > target)
{
if (mid > 0 && target > sortedList[mid - 1] && target < sortedList[mid])
{
result = mid;
break;
}
right = mid - 1;
}
else
{
if (mid < sortedList.Count - 1 && target >= sortedList[mid] && target < sortedList[mid + 1])
{
result = mid + 1;
break;
}
left = mid + 1;
}
}
return result;
}
public EventScratchMain GetCurrentEventScratchMain()
{
if (m_ScratchTicketData == null) return GetFreshScratchTicketData();
return m_TbEventScratchMain.GetOrDefault(m_ScratchTicketData.ScratchMainID);
}
private EventScratchTicketChainPackData m_ChainPackData;
public EventScratchTicketChainPackData GetChainPackData()
{
if (m_ChainPackData == null)
{
EventScratchMain scratchMain = GetCurrentEventScratchMain();
if (scratchMain == null) return null;
var chainList = m_Tables.TbEventPackManager[scratchMain.PackId].VIPPackList[0];
var expireTime = GetExpireTime;
var chainListIdSet = chainList.ToHashSet();
var packs = m_Tables.TbPack.DataList.Where(p => chainListIdSet.Contains(p.ID)).ToArray();
m_ChainPackData = new EventScratchTicketChainPackData(chainList, expireTime, packs, m_ScratchTicketData.EventID, m_ScratchTicketData.ChainPackProgress);
RedPointManager.Instance.SetRedPointState(m_ChainPackData.RedPointKey, m_ChainPackData.DoNeedPackRedPoint);
}
return m_ChainPackData;
}
public void InitChainPackData()
{
ClearChainPackData();
}
public void ClearChainPackData()
{
if (m_ChainPackData != null)
{
m_ChainPackData = null;
}
}
private EventBreakNormalPackInfo m_NormalPackData;
public EventBreakNormalPackInfo GetNormalPackData()
{
if (m_NormalPackData == null)
{
EventScratchMain scratchMain = GetCurrentEventScratchMain();
if (scratchMain == null) return null;
var expireTime = GetExpireTime;
var packList = m_Tables.TbEventPackManager[scratchMain.PackId2].VIPPackList[0];
m_NormalPackData = new EventBreakNormalPackInfo
{
EventId = m_ScratchTicketData.EventID,
PackLeft = m_Tables.TbPack[packList[0]],
PackRight = m_Tables.TbPack[packList[1]],
ExpireTime = expireTime,
};
}
return m_NormalPackData;
}
private void InitNormalPackData()
{
ClearNormalPackDatas();
}
private void ClearNormalPackDatas()
{
m_NormalPackData = null;
}
public void InitRewardBagData()
{
GContext.container.Resolve<IDeferredRewardStashService>().Reset();
//List<int> rewardList = new List<int>();
//EventScratchMain curScratchMain = GetCurrentEventScratchMain();
//foreach (var item in curScratchMain.CardList)
//{
// var card = GetEventScratchCard(item);
// if (card.DropReward > 0)
// {
// rewardList.Add(card.DropReward);
// }
//}
//EventScratchReward curReward = GetEventScratchReward(m_ScratchTicketData.EventScratchRewardTaskID);
//if (curReward.DropReward > 0)
//{
// rewardList.Add(curReward.DropReward);
//}
//GContext.Publish(new RewardStashService.EventStashDropList { DropList = rewardList });
}
public void ClearRewardBagData()
{
}
public void SetChainProgress(int progress)
{
m_ScratchTicketData.ChainPackProgress = progress;
SyncData();
}
public int GetChainProgress()
{
return m_ScratchTicketData.ChainPackProgress;
}
public void AddStampReward(int cardID)
{
m_ScratchTicketData.StampRewardList.Add(cardID);
SyncData();
}
public int GetStampRewardNum()
{
return m_ScratchTicketData.StampRewardList.Count;
}
public EventScratchCard GetFirstStampReward()
{
return GetEventScratchCard(m_ScratchTicketData.StampRewardList[0]);
}
public void RemoveFirstStampReward()
{
m_ScratchTicketData.StampRewardList.RemoveAt(0);
SyncData();
}
public void ClearStampReward()
{
m_ScratchTicketData.StampRewardList.Clear();
SyncData();
}
private List<int> m_ScratchStampList = new List<int>();
public List<int> ScratchStampList { get { return m_ScratchStampList; } }
private void InitScratchStampList()
{
m_ScratchStampList.Clear();
}
public void ClearScratchStampList()
{
m_ScratchStampList.Clear();
}
public void AddScratchStamp(int cardID)
{
m_ScratchStampList.Add(cardID);
}
public EventScratchCard GetFirstScratchStamp()
{
return GetEventScratchCard(m_ScratchStampList[0]);
}
#endregion
#region
public int GetToken()
{
if (m_ScratchTicketData != null)
return m_ScratchTicketData.Token;
return 0;
}
public void AddToken(int count)
{
if (m_ScratchTicketData != null)
{
m_ScratchTicketData.Token += count;
}
else
{
if (m_ScratchTicketData == null) return;
m_ScratchTicketData.Token += count;
}
if (m_ScratchTicketData.Token > 0) RedPointManager.Instance.SetRedPointState(RedPointName.Home_ScratchTicket, true);
else RedPointManager.Instance.SetRedPointState(RedPointName.Home_ScratchTicket, false);
FishingScratchTicketAct.Publish<EventScratchTicketTokenUpdateData>(new EventScratchTicketTokenUpdateData());
GContext.container.Resolve<FishingEventData>().SaveTransitionData(m_ScratchTicketData.EventID, m_ScratchTicketData.Token);
SyncData();
}
public bool ConsumeTokens(int count)
{
bool isEnough = IsEnough(count);
if (isEnough == false) return false;
m_ScratchTicketData.ConsumedToken += count;
m_ScratchTicketData.TotalConsumedToken += count;
AddToken(-count);
return isEnough;
}
public bool IsEnough(int spend)
{
if (m_ScratchTicketData == null) return false;
return (m_ScratchTicketData.Token - spend) >= 0;
}
#endregion
#region
public void ActivateEvent(FishingEvent fishingEvent)
{
if (fishingEvent == null) return;
if (!Init()) return;
if (m_ScratchTicketData == null) GetFreshScratchTicketData();
else FixScratchTicketData();
}
public void GetDataFromServer(string json)
{
if (string.IsNullOrEmpty(json))
{
GameDebug.LogWarning("EventScratchTicket get data from server has encountered empty data.");
return;
}
try
{
m_ScratchTicketData = Newtonsoft.Json.JsonConvert.DeserializeObject<EventScratchTicketData>(json);
}
catch (Exception e)
{
GameDebug.LogWarning("EventScratchTicket deserialize data has failed. Exception: " + e.ToString());
return;
}
if (!Init()) return;
}
public int FixScratchTicketData()
{
if (m_ScratchTicketData == null) return 0;
// 获取当前开放并符合解锁条件的刮刮乐活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(7, 3, m_IsCheckCondition);
if (fishingEvent == null) return ClearData();
int eventID = fishingEvent.ID;
int scratchMainID = fishingEvent.RedirectID;
if (scratchMainID < 0) return ClearData();
if (eventID != m_ScratchTicketData.EventID || scratchMainID != m_ScratchTicketData.ScratchMainID) return ClearData();
return 0;
}
public DateTime GetExpireTime
{
get => DateTime.Parse((m_Tables.TbFishingEvent[m_ScratchTicketData.EventID].TimeDefinition as LimitedTime).EndTime);
}
public TimeSpan RemainingTime
{
get => GetExpireTime - ZZTimeHelper.UtcNow();
}
public int ClearData()
{
if (m_ScratchTicketData == null) return 0;
m_ScratchTicketData.Clear();
m_ScratchTicketData = null;
return 0;
}
public void SyncData()
{
if (!m_IsSyncData) return;
PlayFabMgr.Instance.UpdateUserDataValue(EventScratchTicketConfig.SAVE_DATA_KEY, Newtonsoft.Json.JsonConvert.SerializeObject(m_ScratchTicketData));
}
#endregion
#region
public bool Init()
{
InitTables();
return true;
}
public void StartData()
{
ClearUIData();
InitUIData();
InitChainPackData();
InitNormalPackData();
InitRewardBagData();
InitSpriteDict();
InitScratchStampList();
InitRecordList();
}
public void StopData()
{
ClearUIData();
ClearChainPackData();
ClearNormalPackDatas();
ClearSpriteAtlas();
ClearRewardBagData();
ClearSpriteDict();
ClearScratchStampList();
ClearRecordList();
}
#endregion
#region UI
private UIType m_UIPanel = null, m_InfoPanel = null, m_RewardPanel = null, m_ChainPackPanel = null, m_PackPanel = null;
public void ClearUIData()
{
m_UIPanel = null;
m_InfoPanel = null;
m_RewardPanel = null;
m_ChainPackPanel = null;
m_PackPanel = null;
}
public void InitUIData()
{
GetUIPanel();
GetInfoPanel();
GetChainPackPanel();
GetPackPanel();
}
public UIType GetUIPanel()
{
if (m_UIPanel == null)
{
var data = GetCurrentEventScratchMain();
m_UIPanel = new UIType(data.UIPanel);
}
return m_UIPanel;
}
public UIType GetRewardPanel()
{
if (m_RewardPanel == null)
{
var data = GetCurrentEventScratchMain();
m_RewardPanel = new UIType(data.RewardPanel);
}
return m_RewardPanel;
}
public UIType GetInfoPanel()
{
if (m_InfoPanel == null)
{
var data = GetCurrentEventScratchMain();
m_InfoPanel = new UIType(data.InfoPanel);
}
return m_InfoPanel;
}
public UIType GetChainPackPanel()
{
if (m_ChainPackPanel == null)
{
var data = GetCurrentEventScratchMain();
m_ChainPackPanel = new UIType(data.ChainPackPanel);
}
return m_ChainPackPanel;
}
public UIType GetPackPanel()
{
if (m_PackPanel == null)
{
var data = GetCurrentEventScratchMain();
m_PackPanel = new UIType(data.PackPanel);
}
return m_PackPanel;
}
#endregion
#region
private SpriteAtlas m_SpriteAtlas;
public SpriteAtlas SpriteAtlas
{
get { return m_SpriteAtlas; }
set { m_SpriteAtlas = value; }
}
public void ClearSpriteAtlas()
{
m_SpriteAtlas = null;
}
private Dictionary<string, Sprite> m_SpriteDict;
private void InitSpriteDict()
{
if (m_SpriteDict != null)
{
m_SpriteDict.Clear();
m_SpriteDict = null;
}
m_SpriteDict = new Dictionary<string, Sprite>();
}
public void AddSprite(string name, Sprite sprite)
{
m_SpriteDict.Add(name, sprite);
}
public Sprite GetSprite(string name)
{
return m_SpriteDict[name];
}
private void ClearSpriteDict()
{
if (m_SpriteDict == null) return;
foreach (var pair in m_SpriteDict)
{
Addressables.Release(pair.Value);
}
m_SpriteDict.Clear();
m_SpriteDict = null;
}
#endregion
#region Table Data
private Tables m_Tables;
private TbEventScratchMain m_TbEventScratchMain;
private TbEventScratchCard m_TbEventScratchCard;
private TbEventScratchReward m_TbEventScratchReward;
private TbEventScratchConfig m_TbEventScratchConfig;
private TbItem m_TbItem;
private void InitTables()
{
m_Tables = GContext.container.Resolve<Tables>();
if (m_Tables == null) return;
m_TbEventScratchMain = m_Tables.TbEventScratchMain;
m_TbEventScratchCard = m_Tables.TbEventScratchCard;
m_TbEventScratchReward = m_Tables.TbEventScratchReward;
m_TbEventScratchConfig = m_Tables.TbEventScratchConfig;
m_TbItem = m_Tables.TbItem;
}
public Item GetItem(int itemID)
{
return m_TbItem.GetOrDefault(itemID);
}
public EventScratchReward GetEventScratchReward(int taskID)
{
return m_TbEventScratchReward.GetOrDefault(taskID);
}
public EventScratchReward GetEventScratchFinalReward()
{
int count = m_TbEventScratchReward.DataList.Count;
return m_TbEventScratchReward.DataList[count - 1];
}
public EventScratchCard GetEventScratchCard(int cardID)
{
return m_TbEventScratchCard.GetOrDefault(cardID);
}
#endregion
#region
public string GetSaveKey(string key)
{
if (m_ScratchTicketData == null) return key;
return m_ScratchTicketData.EventID + "-" + m_ScratchTicketData.ScratchMainID + "-" + key;
}
public bool HasSaveKey(string key)
{
return PlayerPrefs.HasKey(GetSaveKey(key));
}
public void SaveData(string key, string value)
{
PlayerPrefs.SetString(GetSaveKey(key), value);
PlayerPrefs.Save();
}
public void ClearSaveData(string key)
{
PlayerPrefs.DeleteKey(GetSaveKey(key));
}
public string GetSaveData(string key)
{
return PlayerPrefs.GetString(GetSaveKey(key));
}
#endregion
#region
public bool IsRedDotDisplayed()
{
if (m_ScratchTicketData == null) return false;
return m_ScratchTicketData.Token > 0;
}
#endregion
}
public enum EventScratchTicketScratchType
{
TypeInvalid,
TypeScratch1,
TypeScratch5,
TypeTemporary
}
public class EventScratchTicketData
{
public int EventID { get; set; }
public int ScratchMainID { get; set; }
public bool IsOver { get; set; }
public int Token { get; set; }
public int ConsumedToken { get; set; }
public int RewardTaskConsumedToken { get; set; }
public int EventScratchRewardTaskID { get; set; }
public int EventScratchCardID { get; set; }
public float LuckyValue { get; set; }
public int TotalConsumedToken { get; set; }
public int ChainPackProgress { get; set; }
public List<int> StampRewardList = new List<int>();
public Dictionary<int, EventScratchTicketOwnedStampRewardData> StampRewardDict { get; set; }
public void Clear()
{
if (StampRewardDict != null)
{
StampRewardDict.Clear();
}
StampRewardList.Clear();
}
public void ClearAllLocalData()
{
Clear();
}
}
public class EventScratchTicketConfig
{
public const string SAVE_DATA_KEY = "estdk"; // event scratch ticket data key
public const string key_first_in = "scratch_kfcw"; // 本地存储数据key
public static Vector2 ConvertUiPosition(RectTransform from, RectTransform to, Camera camera)
{
Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(camera, from.position);
RectTransformUtility.ScreenPointToLocalPointInRectangle(
to,
screenPoint,
camera,
out Vector2 localPoint);
return localPoint;
}
public static Vector2 ScreenToGraphicLocalPoint(Graphic graphic, Vector2 screenPoint)
{
var canvas = graphic.canvas.rootCanvas;
var camera = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera;
var rt = graphic.rectTransform;
return RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, screenPoint, camera, out var result) ? result : default;
}
}
public class EventScratchTicketTokenUpdateData
{
}
public class EventScratchTicketRewardTaskUpdateData
{
public EventScratchTicketScratchType ScratchType;
public int Token;
}
public class EventScratchTicketRewardDisplayUpdateData
{
public int TaskID;
public int FromToken;
public int TargetToken;
public int LevelToken;
public float FromRatio;
public float TargetRatio;
public EventScratchReward Reward;
}
public class EventScratchTicketChangeScratchTypeData
{
public EventScratchTicketScratchType ScratchType;
}
public class EventScratchTicketRevealedAllData
{
public EventScratchTicketScratchType ScratchType;
}
public class EventScratchTicketStampRewardUpdateData
{
}
public class EventScratchTicketStartStampRewardCountUpdateData
{
}
public class EventScratchTicketStopStampRewardCountUpdateData
{
}
public class EventScratchTicketOwnedStampRewardData
{
public int EventScratchCardID;
public int Count;
}
public class EventScratchTicketStampRewardFlyData
{
public EventScratchTicketScratchType ScratchType;
public Vector3 SrcPosition;
//public Vector3 DestPosition;
public Vector3 LocalScale;
public float IconSize;
}
public class EventScratchTicketRewardEmptyData
{
public EventScratchTicketScratchType ScratchType;
}
public class EventScratchTicketUpdateEventScratchCardData
{
}
public class EventScratchTicketPanelPlayEndAnimData
{
public EventScratchTicketScratchType ScratchType;
}
public class EventScratchTicketPlayScratchType5
{
}
public class EventScratchTicketStartMaskData
{
}
public class EventScratchTicketOutData
{
public EventScratchTicketScratchType ScratchType;
}
public class EventScratchTicketRecordData
{
public int TicketID;
public int TicketFinishID;
public int ScratchType;
public int MilestoneTask;
public void SetScratchType(EventScratchTicketScratchType type)
{
if (type == EventScratchTicketScratchType.TypeScratch1)
{
ScratchType = 1;
}
else if (type == EventScratchTicketScratchType.TypeScratch5)
{
ScratchType = 2;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7efa42ab0e113b04fbc2709ace598fc1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,763 @@
using asap.core;
using Castle.Core.Internal;
using cfg;
using GameCore;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
namespace game
{
public class EventWashingData
{
private const string LocalKeySetKey = "ewdlksk"; // EventWashingData LocalKeySetKey 首字母
public int EventID { get; set; }
public int WashingID { get; set; }
public int StageID { get; set; }
public int StageIndex { get; set; }
public int StageCount { get; set; }
public int StepID { get; set; }
public int StepIndex { get; set; }
public int StepCount { get; set; }
public List<float> StepItems { get; set; }
public int StepEnergyConsume { get; set; }
public float Percent { get; set; } // 数值范围0-1
public float OmitPercent { get; set; }
public float Energy { get; set; } // 数值范围0-1
public float EnergyConsumptionSpeed { get; set; }
public bool IsOver { get; set; }
public int Token { get; set; }
public int ConsumedToken { get; set; }
public bool IsAllGameOver { get; set; }
public EventWashingData()
{
EventID = -1;
WashingID = -1;
StageID = -1;
StepID = -1;
Percent = 0;
IsOver = false;
Token = 0;
StepItems = new List<float>();
IsAllGameOver = false;
Token = 0;
}
public void Clear()
{
ClearAllLocalData();
StepItems.Clear();
StepItems = null;
}
public void AddLocalDataKey(string group, string key)
{
LocalStepData stepData = null;
List<string> list = null;
if (PlayerPrefs.HasKey(LocalKeySetKey) == true)
{
string data = PlayerPrefs.GetString(LocalKeySetKey);
try
{
stepData = Newtonsoft.Json.JsonConvert.DeserializeObject<LocalStepData>(data);
}
catch (Exception e)
{
Debug.LogError(e.Message);
stepData = new LocalStepData();
}
if (stepData.LocalDatas.TryGetValue(group, out list))
{
list.Add(key);
}
else
{
list = new List<string>();
list.Add(key);
stepData.LocalDatas.Add(group, list);
}
PlayerPrefs.SetString(LocalKeySetKey, Newtonsoft.Json.JsonConvert.SerializeObject(stepData));
}
else
{
stepData = new LocalStepData();
list = new List<string>();
list.Add(key);
stepData.LocalDatas.Add(group, list);
PlayerPrefs.SetString(LocalKeySetKey, Newtonsoft.Json.JsonConvert.SerializeObject(stepData));
}
PlayerPrefs.Save();
}
public void ClearLocalDataExceptGroup(string group)
{
if (PlayerPrefs.HasKey(LocalKeySetKey) == false) return;
string data = PlayerPrefs.GetString(LocalKeySetKey);
LocalStepData stepData = null;
try
{
stepData = Newtonsoft.Json.JsonConvert.DeserializeObject<LocalStepData>(data);
}
catch (Exception e)
{
Debug.LogError(e.Message);
return;
}
int count = 0;
foreach (var item in stepData.LocalDatas)
{
if (string.IsNullOrEmpty(item.Key) == false && item.Key.Equals(group) == false)
{
var list = item.Value;
count = list.Count;
for (int i = 0; i < count; ++i)
{
if (PlayerPrefs.HasKey(list[i]) == true) PlayerPrefs.DeleteKey(list[i]);
}
}
}
PlayerPrefs.Save();
}
public void ClearAllLocalData()
{
if (PlayerPrefs.HasKey(LocalKeySetKey) == false) return;
string data = PlayerPrefs.GetString(LocalKeySetKey);
LocalStepData stepData = null;
try
{
stepData = Newtonsoft.Json.JsonConvert.DeserializeObject<LocalStepData>(data);
}
catch (Exception e)
{
Debug.LogError(e.Message);
return;
}
int count = 0;
foreach (var item in stepData.LocalDatas)
{
if (string.IsNullOrEmpty(item.Key) == false)
{
var list = item.Value;
count = list.Count;
for (int i = 0; i < count; ++i)
{
if (PlayerPrefs.HasKey(list[i]) == true) PlayerPrefs.DeleteKey(list[i]);
}
}
}
PlayerPrefs.Save();
}
}
public class LocalStepData
{
public Dictionary<string, List<string>> LocalDatas = new Dictionary<string, List<string>>();
}
public class EventWashingDataManager
{
private Tables m_Tables;
private TbEventWashing m_TbEventWashing;
private TbEventWashingStage m_TbEventWashingStage;
private TbEventWashingStep m_TbEventWashingStep;
private EventWashing m_EventWashing = null;
private EventWashingData m_WashingData = null;
#if UNITY_EDITOR
private bool m_IsCheckCondition = true;
private int m_DefaultToken = 0;
#else
private bool m_IsCheckCondition = true;
private int m_DefaultToken = 0;
#endif
public EventWashingData WashingData { get => m_WashingData; }
private UIType m_InfoPopupPanel = null;
public UIType GetCurrentInfoPopupPanel()
{
if (m_InfoPopupPanel == null)
{
var data = GetCurrentEventWashing();
m_InfoPopupPanel = new UIType(data.PanelID);
}
return m_InfoPopupPanel;
}
#region
/// <summary>
/// 初始化
/// </summary>
public bool Init()
{
m_Tables = GContext.container.Resolve<Tables>();
if (m_Tables == null) return false;
m_TbEventWashing = m_Tables.TbEventWashing;
m_TbEventWashingStage = m_Tables.TbEventWashingStage;
m_TbEventWashingStep = m_Tables.TbEventWashingStep;
return true;
}
public bool InitGameData()
{
if (m_WashingData == null) GetFreshEventStep();
GetCurrentEventStep();
return true;
}
public void ClearActData()
{
m_InfoPopupPanel = null;
}
public EventWashing GetCurrentEventWashing()
{
if (m_WashingData == null) return null;
EventWashing washing = m_TbEventWashing.GetOrDefault(m_WashingData.WashingID);
return washing;
}
public void ActivateEvent(FishingEvent fishingEvent)
{
if (fishingEvent == null) return;
if (!Init()) return;
if (m_WashingData == null) GetFreshEventStep();
else FixWashingData();
}
/// <summary>
/// 从服务器获取数据
/// </summary>
public void GetDataFromServer(string json)
{
if (json.IsNullOrEmpty())
{
GameDebug.LogError("EventWashing get data from server has encountered empty data.");
return;
}
try
{
m_WashingData = Newtonsoft.Json.JsonConvert.DeserializeObject<EventWashingData>(json);
}
catch (Exception e)
{
GameDebug.LogError("EventWashing deserialize data has failed. Exception: " + e.ToString());
return;
}
if (!Init()) return;
//FixWashingData();
}
public void SyncData()
{
PlayFabMgr.Instance.UpdateUserDataValue(EventWashingConfig.SAVE_DATA_KEY, Newtonsoft.Json.JsonConvert.SerializeObject(m_WashingData));
}
public string GetShipName()
{
if (m_WashingData == null) return "";
int stageID = m_WashingData.StageID;
EventWashingStage stage = m_TbEventWashingStage.GetOrDefault(stageID);
if (stage == null) return "";
return LocalizationMgr.GetText(stage.Name_l10n_key);
}
public TimeSpan RemainingTime
{
get => DateTime.Parse((m_Tables.TbFishingEvent[m_WashingData.EventID].TimeDefinition as LimitedTime).EndTime)
- ZZTimeHelper.UtcNow();
}
public int FixWashingData()
{
if (m_WashingData == null) return 0;
// 获取当前开放并符合解锁条件的洗游艇活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
if (fishingEvent == null) return ClearWashingData();
int eventID = fishingEvent.ID;
int washingID = fishingEvent.RedirectID;
if (washingID < 0) return ClearWashingData();
if (eventID != m_WashingData.EventID || washingID != m_WashingData.WashingID) return ClearWashingData();
return 0;
}
private int ClearWashingData()
{
if (m_WashingData == null) return 0;
m_WashingData.Clear();
m_WashingData = null;
return 0;
}
public void GoToStep(int stageID, int stepID)
{
// 获取当前开放并符合解锁条件的洗游艇活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
if (fishingEvent == null)
{
Debug.LogError("=== 找不到 洗游艇 对应的 type=4 & subType=4且符合条件的活动。");
return;
}
int eventID = fishingEvent.ID;
int washingID = fishingEvent.RedirectID;
if (washingID < 0)
{
Debug.LogError("=== 洗游艇ID出错活动ID为" + eventID + ", 洗游艇ID:" + washingID);
return;
}
// 获取当前洗游艇活动数据
EventWashing washing = m_TbEventWashing.GetOrDefault(washingID);
if (washing == null)
{
Debug.LogError("=== 洗游艇找不到游艇数据washingID:" + washingID);
return;
}
// 获取游艇数据
int stageCount = washing.StageList.Count;
if (stageCount == 0)
{
Debug.LogError("=== 洗游艇对应StageList出错washingID:" + washingID);
return;
}
int stageIndex = -1;
for (int i = 0; i < stageCount; i++)
{
if (washing.StageList[i] == stageID)
{
stageIndex = i;
break;
}
}
if (stageIndex < 0)
{
Debug.LogError("=== 洗游艇stageID找不到对应数据stageID:" + stageID);
return;
}
EventWashingStage stage = m_TbEventWashingStage.GetOrDefault(stageID);
if (stage == null)
{
Debug.LogError("=== 洗游艇stepID找不到对应数据stageID:" + stageID);
return;
}
// 获取步骤数据
int stepCount = stage.StepList.Count;
if (stepCount == 0)
{
Debug.LogError("=== 洗游艇StepList出错StageID:" + stageID);
return;
}
int stepIndex = 0;
for (int i = 0; i < stepCount; i++)
{
if (stage.StepList[i] == stepID)
{
stepIndex = i;
break;
}
}
if (stepIndex < 0)
{
Debug.LogError("=== 洗游艇stepID找不到对应数据stepID:" + stepID);
return;
}
EventWashingStep eventWashingStep = m_TbEventWashingStep.GetOrDefault(stepID);
int token = 0;
if (m_WashingData != null) token = m_WashingData.Token;
m_WashingData = new EventWashingData();
m_WashingData.EventID = eventID;
m_WashingData.WashingID = washingID;
m_WashingData.StageID = stageID;
m_WashingData.StageIndex = stageIndex;
m_WashingData.StageCount = stageCount;
m_WashingData.StepID = stepID;
m_WashingData.StepIndex = stepIndex;
m_WashingData.StepCount = stepCount;
m_WashingData.StepItems.Clear();
m_WashingData.StepEnergyConsume = eventWashingStep.EnergyConsume;
m_WashingData.Percent = 0f;
m_WashingData.OmitPercent = 0f;
m_WashingData.IsOver = false;
m_WashingData.Token = token;
// 同步数据
SyncData();
}
public void ResetRefreshData()
{
ClearWashingData();
//if (m_WashingData != null)
//{
// m_WashingData.Token = 0;
// m_WashingData.ClearAllLocalData();
//}
//GetFreshEventStep();
}
public bool IsCurrentStepID(int stepID)
{
if (m_WashingData == null) return false;
return m_WashingData.StepID == stepID;
}
//public string GetBgm()
//{
// // 获取当前开放并符合解锁条件的洗游艇活动ID
// FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
// FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
// if (fishingEvent == null) return null;
// int eventID = fishingEvent.ID;
// int washingID = fishingEvent.RedirectID;
// if (washingID < 0) return null;
// // 获取当前洗游艇活动数据
// EventWashing washing = m_TbEventWashing.GetOrDefault(washingID);
// return washing.Bgm;
//}
#endregion
#region
public bool IsRedDotDisplayed()
{
if (m_WashingData == null) return false;
return m_WashingData.Token > 0 && m_WashingData.IsAllGameOver == false;
}
#endregion
#region
/// <summary>
/// 消费token
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
public bool ConsumeTokens(int count)
{
bool isEnough = IsEnough(count);
if (isEnough == false) return false;
m_WashingData.ConsumedToken += count;
AddToken(-count);
#if AGG
using (var e = GEvent.GameEvent("event_washing"))
{
e.AddContent("step_id", m_WashingData.StepID)
.AddContent("independent_id", m_WashingData.ConsumedToken);
}
#endif
return isEnough;
}
public void AddToken(int count)
{
if (m_WashingData != null)
{
m_WashingData.Token += count;
}
else
{
//m_WashingData = new EventWashingData();
//m_WashingData.Token = count;
GetFreshEventStep();
if (m_WashingData == null) return;
m_WashingData.Token += count;
}
if (m_WashingData.Token > 0) RedPointManager.Instance.SetRedPointState(RedPointName.Home_Washing, true);
else RedPointManager.Instance.SetRedPointState(RedPointName.Home_Washing, false);
FishingYachtAct.Publish<EventWashingTokenUpdateData>(new EventWashingTokenUpdateData());
GContext.container.Resolve<FishingEventData>().SaveTransitionData(m_WashingData.EventID, m_WashingData.Token);
SyncData();
}
public int GetToken()
{
if (m_WashingData != null )
return m_WashingData.Token;
return 0;
}
public bool IsEnough(int spend)
{
if (m_WashingData == null) return false;
return (m_WashingData.Token - spend) >= 0;
}
public void SetEnergy(float energy, float speed)
{
if (m_WashingData == null) return;
if (energy < 0) m_WashingData.Energy = 0f;
else if (energy > 1f) m_WashingData.Energy = 1f;
else m_WashingData.Energy = energy;
if (speed < 0f) m_WashingData.EnergyConsumptionSpeed = 0f;
else m_WashingData.EnergyConsumptionSpeed = speed;
}
public void UpdateToken(float deltaTime)
{
if (m_WashingData != null)
{
float step = 1f / m_WashingData.StepEnergyConsume;
float nextEnergy = 1f - math.frac(m_WashingData.Percent / step);
if (m_WashingData.Energy < nextEnergy) m_WashingData.Energy = 0f;
if (m_WashingData.Energy > 0) m_WashingData.Energy = nextEnergy;
if (m_WashingData.Energy < 0) m_WashingData.Energy = 0;
}
}
public bool IsUpdateTokenOver()
{
if (m_WashingData == null) return true;
float step = 1f / m_WashingData.StepEnergyConsume;
int belongStep = (int)math.floor(m_WashingData.Percent / step) + 1;
if (belongStep > m_WashingData.StepEnergyConsume) m_WashingData.IsOver = true;
if (belongStep > m_WashingData.ConsumedToken && belongStep <= m_WashingData.StepEnergyConsume) return true;
return false;
}
public bool IsGameOver()
{
if (m_WashingData == null) return true;
return m_WashingData.IsOver;
}
#endregion
#region
public string GetPreLoadStepResName()
{
if (WashingData == null)
{
GetFreshEventStep();
}
else
{
GetCurrentEventStep();
}
string res = string.Format("GC_{0:D}_{1:D}_{2:D}", m_WashingData.WashingID, m_WashingData.StageID, m_WashingData.StepID);
return res;
}
public EventWashingStep GetFreshEventStep(bool isSyncData = true)
{
// 获取当前开放并符合解锁条件的洗游艇活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int washingID = fishingEvent.RedirectID;
if (washingID < 0) return null;
// 获取当前洗游艇活动数据
EventWashing washing = m_TbEventWashing.GetOrDefault(washingID);
if (washing == null) return null;
// 获取游艇数据
int stageCount = washing.StageList.Count;
if (stageCount == 0) return null;
int stageIndex = 0;
int stageID = washing.StageList[stageIndex];
EventWashingStage stage = m_TbEventWashingStage.GetOrDefault(stageID);
if (stage == null) return null;
// 获取步骤数据
int stepCount = stage.StepList.Count;
if (stepCount == 0) return null;
int stepIndex = 0;
int stepID = stage.StepList[stepIndex]; // 步骤ID
EventWashingStep eventWashingStep = m_TbEventWashingStep.GetOrDefault(stepID);
int token = m_DefaultToken;
if (m_WashingData != null) m_WashingData.ClearAllLocalData();
token = GContext.container.Resolve<FishingEventData>().GetInitWelcomeGift(eventID);
m_WashingData = new EventWashingData();
m_WashingData.EventID = eventID;
m_WashingData.WashingID = washingID;
m_WashingData.StageID = stageID;
m_WashingData.StageIndex = stageIndex;
m_WashingData.StageCount = stageCount;
m_WashingData.StepID = stepID;
m_WashingData.StepIndex = stepIndex;
m_WashingData.StepCount = stepCount;
m_WashingData.StepItems.Clear();
m_WashingData.StepEnergyConsume = eventWashingStep.EnergyConsume;
m_WashingData.Percent = 0f;
m_WashingData.OmitPercent = 0f;
m_WashingData.IsOver = false;
m_WashingData.Token = token;
m_WashingData.ConsumedToken = 0;
m_WashingData.IsAllGameOver = false;
GContext.container.Resolve<FishingEventData>().SaveTransitionData(m_WashingData.EventID, m_WashingData.Token);
// 同步数据
if (isSyncData == true) SyncData();
return eventWashingStep;
}
public bool HavePreEventStep()
{
if (m_WashingData == null) return false;
if (m_WashingData.StageIndex > 0) return true;
if (m_WashingData.StepIndex > 0) return true;
return false;
}
public bool HaveNextEventStep()
{
if (m_WashingData == null) return false;
if (m_WashingData.StageIndex < m_WashingData.StageCount - 1) return true;
if (m_WashingData.StepIndex < m_WashingData.StepCount - 1) return true;
return false;
}
public EventWashingStep GetNextEventStep(bool isSyncData = true)
{
// 获取当前开放并符合解锁条件的洗游艇活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int washingID = fishingEvent.RedirectID;
if (washingID < 0) return null;
if (washingID != m_WashingData.WashingID) return GetFreshEventStep();
// 获取当前洗游艇活动数据
EventWashing eventWashing = m_TbEventWashing.GetOrDefault(washingID);
if (eventWashing == null) return null;
bool haveNextStep = HaveNextEventStep();
if (haveNextStep == false) return null; // 所有活动结束
if (m_WashingData.StepIndex < m_WashingData.StepCount - 1)
{
m_WashingData.StepIndex += 1;
}
else
{
// 换船
m_WashingData.StageIndex += 1;
m_WashingData.StepIndex = 0;
}
int stageIndex = m_WashingData.StageIndex;
int stageCount = eventWashing.StageList.Count;
int stageID = eventWashing.StageList[stageIndex];
EventWashingStage eventWashingStage = m_TbEventWashingStage.GetOrDefault(stageID);
if (eventWashingStage == null) return null;
int stepIndex = m_WashingData.StepIndex;
int stepCount = eventWashingStage.StepList.Count;
int stepID = eventWashingStage.StepList[stepIndex];
EventWashingStep eventWashingStep = m_TbEventWashingStep.GetOrDefault(stepID);
m_WashingData.EventID = eventID;
m_WashingData.WashingID = washingID;
m_WashingData.StageID = stageID;
m_WashingData.StageIndex = stageIndex;
m_WashingData.StageCount = stageCount;
m_WashingData.StepID = stepID;
m_WashingData.StepIndex = stepIndex;
m_WashingData.StepCount = stepCount;
m_WashingData.StepItems.Clear();
m_WashingData.StepEnergyConsume = eventWashingStep.EnergyConsume;
m_WashingData.Percent = 0f;
m_WashingData.OmitPercent = 0f;
m_WashingData.IsOver = false;
m_WashingData.ConsumedToken = 0;
// 同步数据
if (isSyncData == true) SyncData();
return eventWashingStep;
}
public EventWashingStep GetCurrentEventStep()
{
// 获取当前开放并符合解锁条件的洗游艇活动ID
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
FishingEvent fishingEvent = fishingEventData.GetEventByTypeAndSubType(4, 4, m_IsCheckCondition);
if (fishingEvent == null) return null;
int eventID = fishingEvent.ID;
int washingID = fishingEvent.RedirectID;
if (washingID < 0) return null;
if (eventID != m_WashingData.EventID || washingID != m_WashingData.WashingID) return GetFreshEventStep();
return m_TbEventWashingStep.GetOrDefault(m_WashingData.StepID);
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6861d7250341bbb48b4531aa05370263
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,424 @@
using asap.core;
using cfg;
using game;
using GameCore;
using LitJson;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[Serializable]
public class FishingBoxData
{
public Dictionary<int, int> FishingBoxs = new();
public Dictionary<int, int> FishingNewBoxs = new();
public Dictionary<int, int> FishingBoxOpenNum = new();
public int FishingBoxScore;
public int CurFishingBoxLevel;
public FishingBoxData()
{
var firstItemID = FishingBoxDataProvier.firstFishingBoxID;
for (int i = 0; i < FishingBoxDataProvier.QualityCount; i++)
{
FishingBoxs.Add(firstItemID + i, 0);
FishingNewBoxs.Add(firstItemID + i, 0);
}
}
public void InitData(string data)
{
if (string.IsNullOrEmpty(data) == false)
{
var boxData = Newtonsoft.Json.JsonConvert.DeserializeObject<FishingBoxData>(data);
FishingBoxs = boxData.FishingBoxs;
FishingNewBoxs = boxData.FishingNewBoxs;
FishingBoxOpenNum = boxData.FishingBoxOpenNum;
FishingBoxScore = boxData.FishingBoxScore;
CurFishingBoxLevel = boxData.CurFishingBoxLevel;
var firstItemID = FishingBoxDataProvier.firstFishingBoxID;
for (int i = 0; i < FishingBoxDataProvier.QualityCount; i++)
{
if (!FishingBoxs.ContainsKey(firstItemID + i))
{
FishingBoxs.Add(firstItemID + i, 0);
}
if (!FishingNewBoxs.ContainsKey(firstItemID + i))
{
FishingNewBoxs.Add(firstItemID + i, 0);
}
}
}
}
public void SetFishingBoxCount(int itemID, int value)
{
if (value < 0)
GContext.Publish(new ConditionTypeEvent { type = ConditionType.OpenFishBoxCount, count = -value });
if (FishingNewBoxs.ContainsKey(itemID))
{
FishingNewBoxs[itemID] += value;
}
else
{
FishingNewBoxs.Add(itemID, value);
}
Save();
}
public void Save()
{
PlayFabMgr.Instance.UpdateUserDataValue("FishingBoxData", JsonMapper.ToJson(this));
}
public int GetFishingBoxCount(int itemID)
{
if (FishingNewBoxs.ContainsKey(itemID))
{
return FishingNewBoxs[itemID];
}
return 0;
}
public int GetNextValidFishingBoxSelectedID()
{
foreach (var box in FishingBoxs)
{
var id = box.Key;
if (box.Value > 0)
{
return id;
}
}
return -1;
}
public void AddBoxOpenCount(int itemID, int count)
{
if (FishingBoxOpenNum.ContainsKey(itemID))
{
FishingBoxOpenNum[itemID] += count;
}
else
FishingBoxOpenNum.Add(itemID, count);
Save();
}
public int GetFishingBoxOpenCount(int itemID)
{
if (FishingBoxOpenNum.ContainsKey(itemID))
{
return FishingBoxOpenNum[itemID];
}
return 1;
}
}
public class FishingBoxDataProvier
{
public static int QualityCount;
public static int firstFishingBoxID;
public int EventTipID;
public bool IsUnclocked;
public bool CanSwitchBox;
private int _curSelectedID;
/// <summary>
/// 0-4
/// </summary>
private int _curSelectedQuality;
private int maxOpenCount;
public int CurSelectedID
{
get
{
return _curSelectedID;
}
set
{
_curSelectedID = value;
_curSelectedQuality = GetQualityByID(value);
}
}
//public int CurSelectedQuality
//{
// get
// {
// return _curSelectedQuality;
// }
// set
// {
// _curSelectedQuality = value;
// if (_curSelectedQuality < 0 || _curSelectedQuality > QualityCount - 1)
// {
// _curSelectedQuality += QualityCount;
// _curSelectedQuality %= QualityCount;
// }
// _curSelectedID = GetIDByQuality(_curSelectedQuality);
// }
//}
//public int CurBoxLevel
//{
// get
// {
// var level = Data.CurFishingBoxLevel;
// if (level == 0)
// {
// Data.CurFishingBoxLevel = 1;
// Data.Save();
// }
// var len = _boxLevels.Count;
// if (level > len)
// {
// Data.CurFishingBoxLevel = 1;
// Data.Save();
// }
// return Data.CurFishingBoxLevel;
// }
// set
// {
// var count = value;
// if (value == 0)
// {
// count = 1;
// }
// var len = _boxLevels.Count;
// if (value > len)
// {
// count = 1;
// }
// Data.CurFishingBoxLevel = count;
// Data.Save();
// }
//}
public FishingBoxData Data;
public FishingBoxDataProvier(Tables table)
{
firstFishingBoxID = table.TbBox.DataList[0].ID;
QualityCount = table.TbBox.DataList.Count;
_items = table.TbItem.DataMap;
_itemDropPackages = table.TbItemDropPackage.DataMap;
_boxLevels = table.TbBoxLevel.DataMap;
_boxInits = table.TbBoxInit.DataMap;
_boxes = table.TbBox.DataMap;
maxOpenCount = table.TbGlobalConfig.BoxMaxOpenCount;
Data = GContext.container.Resolve<FishingBoxData>();
}
#region TablesData
private Dictionary<int, Item> _items;
private Dictionary<int, ItemDropPackage> _itemDropPackages;
private Dictionary<int, BoxLevel> _boxLevels;
private Dictionary<int, Box> _boxes;
private Dictionary<int, BoxInit> _boxInits;
#endregion
public void Init()
{
CanSwitchBox = true;
CurSelectedID = Data.GetNextValidFishingBoxSelectedID() == -1 ? firstFishingBoxID : Data.GetNextValidFishingBoxSelectedID();
}
#region Get Function
public List<int> GetFishingBoxDropID(int itemID = -1)
{
if (itemID == -1)
{
itemID = CurSelectedID;
}
Data.AddBoxOpenCount(itemID, 1);
if (_boxInits.ContainsKey(itemID))
{
var boxInit = _boxInits[itemID];
var openCout = Data.GetFishingBoxOpenCount(itemID);
if (openCout <= boxInit.DropChange.Count && openCout != 0)
{
return _itemDropPackages[boxInit.DropChange[openCout - 1]].DropList;
}
}
return _itemDropPackages[itemID].DropList;
}
//public string GetFishingBoxName(int itemID = -1)
//{
// if (itemID == -1)
// {
// return LocalizationMgr.GetFormatTextValue(_items[CurSelectedID].Name_l10n_key);
// }
// return LocalizationMgr.GetFormatTextValue(_items[itemID].Name_l10n_key);
//}
//public string GetFishingBoxRewardTitle(int itemID = -1)
//{
// if (itemID == -1)
// {
// return LocalizationMgr.GetFormatTextValue(_itemDropPackages[CurSelectedID].Desc_l10n_key);
// }
// return LocalizationMgr.GetFormatTextValue(_itemDropPackages[itemID].Desc_l10n_key);
//}
//public string GetFishingBoxDesc(int itemID = -1)
//{
// if (itemID == -1)
// {
// return LocalizationMgr.GetFormatTextValue(_items[CurSelectedID].Desc_l10n_key);
// }
// return LocalizationMgr.GetFormatTextValue(_items[itemID].Desc_l10n_key);
//}
//public string GetFishingBoxTitleImg(int itemID = -1)
//{
// var name = "bg_fishingbox_title_";
// if (itemID == -1)
// {
// return name + (CurSelectedQuality + 1);
// }
// return name + (GetQualityByID(itemID) + 1);
//}
//public string GetFishingBoxTipImg(int itemID = -1)
//{
// var name = "bg_fishingbox_tips_";
// if (itemID == -1)
// {
// return name + (CurSelectedQuality + 1);
// }
// return name + (GetQualityByID(itemID) + 1);
//}
//public string GetFishingBoxIcon(int itemID = -1)
//{
// if (itemID == -1)
// {
// return _items[CurSelectedID].Icon;
// }
// return _items[itemID].Icon;
//}
public int GetQualityByID(int itemID)
{
return _items[itemID].Quality;
}
public int GetIDByQuality(int quality)
{
return firstFishingBoxID + quality;
}
//public void SetBoxRewardScore(int itemID, int count)
//{
// ChangeCurScore(_boxes[itemID].PointsGain * count);
//}
//InfoBar
//public void GetRewardsInfo(List<FishingBoxInfoBar.RewardItemInfo> infos, int itemID = -1)
//{
// foreach (var info in infos)
// {
// info.Tran.gameObject.SetActive(false);
// }
// ItemDropPackage fishingBox;
// if (itemID == -1)
// {
// fishingBox = _itemDropPackages[CurSelectedID];
// }
// else
// fishingBox = _itemDropPackages[CurSelectedID];
// var uiService = GContext.container.Resolve<IUIService>();
// for (int i = 0; i < fishingBox.ItemDisplay.Count; i++)
// {
// var item = _items[fishingBox.ItemDisplay[i]];
// var name = LocalizationMgr.GetFormatTextValue(item.Name_l10n_key);
// var desc = "";
// var prob = fishingBox.ProbDisplay[i] * 100;
// if (item.Type == 1 && item.SubType == 2)
// {
// var bate = GContext.container.Resolve<PlayerItemData>().GetExtraCoinMag(1);
// var nums = fishingBox.CountDisplay[i].Split('-').ToList();
// var descs = nums.Select(x => int.Parse(x) * bate).ToList();
// for (int j = 0; j < descs.Count - 1; j++)
// {
// desc += Mathf.Round(descs[j] / 10) * 10 + "-";
// }
// desc += Mathf.Round(descs[descs.Count - 1] / 10) * 10 + " " + prob + "%";
// }
// else
// {
// desc = fishingBox.CountDisplay[i] + " " + prob + "%";
// }
// infos[i].Reset(name, desc);
// uiService.SetImageSprite(infos[i].Img, item.Icon);
// infos[i].Tran.gameObject.SetActive(true);
// }
//}
//ProgressBar
//public int GetCurScore()
//{
// return Data.FishingBoxScore;
//}
//public int GetRequriedScore()
//{
// return _boxLevels[CurBoxLevel].PointsRequired;
//}
public void ChangeCurScore(int value)
{
Data.FishingBoxScore += value;
Data.Save();
}
//public string GetBoxRewardIcon()
//{
// var id = _boxLevels[CurBoxLevel].BoxID;
// return _items[id].Icon;
//}
//public int GetBoxRewardID()
//{
// return _boxLevels[CurBoxLevel].BoxID;
//}
//public void OnGetBoxReward()
//{
// Data.FishingBoxScore -= _boxLevels[CurBoxLevel].PointsRequired;
// Data.SetFishingBoxCount(_boxLevels[CurBoxLevel].BoxID, 1);
// CurBoxLevel = CurBoxLevel + 1;
//}
//SelectedBar
public int GetBoxCount(int itemID = -1)
{
if (itemID == -1)
{
return Data.GetFishingBoxCount(CurSelectedID);
}
return Data.GetFishingBoxCount(itemID);
}
//public int GetBoxToOpenCount(int itemID = -1)
//{
// var count = GetBoxCount(itemID);
// return count > maxOpenCount ? maxOpenCount : count;
//}
#endregion
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48b61c535184ba44e82bd053ec191cd9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: de9575b0d03b416582f13ec56af90985
timeCreated: 1753427944

View File

@@ -0,0 +1,94 @@
using asap.core;
using cfg;
using LitJson;
using System;
namespace GameCore
{
public partial class FishingEventData
{
string Pack1A1DataKey = "Pack1A1Data";
public TriggerPackBuyData Pack1A1Data;
bool isFace;
void GiftFace1A1(int packType, int eventID)
{
if (isFace)
{
return;
}
if (Pack1A1Data == null || Pack1A1Data.index < 2 || Pack1A1Data.lastID != eventID)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(eventID, UITypes.GiftPopupPanel_10, packType, true);
}
}
public void SetPack1A1(FishingEvent t)
{
if (Pack1A1Data == null)
{
string json_duelData = PlayFabMgr.Instance.GetLocalData(Pack1A1DataKey);
if (json_duelData != null)
{
Pack1A1Data = Newtonsoft.Json.JsonConvert.DeserializeObject<TriggerPackBuyData>(json_duelData);
}
}
EventPackManager eventPackDataRead = _tables.TbEventPackManager.DataMap[t.RedirectID];
GiftFace1A1(eventPackDataRead.PackType, t.ID);
if (Pack1A1Data != null && Pack1A1Data.lastID == t.ID)
{
return;
}
Pack1A1Data = new TriggerPackBuyData()
{
ID = eventPackDataRead.ID,
lastID = t.ID,//活动id
index = 0,
vipLevel = GContext.container.Resolve<PlayerData>().PriceLv,
mapID = GContext.container.Resolve<PlayerData>().lastMapId,
};
RedPointManager.Instance.SetRedPointState(HomeBtnOneOnePack.redKey, false);
PlayFabMgr.Instance.UpdateUserDataValue(Pack1A1DataKey, JsonMapper.ToJson(Pack1A1Data));
}
public void SetPack1A1Index(int index)
{
if (Pack1A1Data == null || index < Pack1A1Data.index)
{
return;
}
Pack1A1Data.index = index;
if (Pack1A1Data.index >= 2)
{
//购买完 特殊处理
GContext.Publish(new TargetEvent(Pack1A1Data.lastID, 3, 8));
}
RedPointManager.Instance.SetRedPointState(HomeBtnOneOnePack.redKey, Pack1A1Data.index == 1);
PlayFabMgr.Instance.UpdateUserDataValue(Pack1A1DataKey, JsonMapper.ToJson(Pack1A1Data));
}
public int GetPack1A1Index()
{
isFace = true;
if (Pack1A1Data == null)
{
return 100;
}
return Pack1A1Data.index;
}
public EventPackManager Get1A1EventPackManager()
{
if (Pack1A1Data == null)
{
return null;
}
return _tables.TbEventPackManager.DataMap[Pack1A1Data.ID];
}
public DateTime GetEvent1A1EndTime()
{
if (Pack1A1Data == null)
{
return ZZTimeHelper.UtcNow().UtcNowOffset(); ;
}
return GetEventEndTime(Pack1A1Data.lastID);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bccb51f7c4075e740945fa0564171a60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,163 @@
using asap.core;
using cfg;
using LitJson;
using System;
using System.Collections.Generic;
namespace GameCore
{
public class Pack1A2Data
{
public Pack1A2Data(int ID,
//活动id
int eventId,
int vipLevel)
{
this.ID = ID;
this.lastID = eventId;
this.index = 0;
this.vipLevel = vipLevel;
}
public int ID;
//领取第几个
public int index;
public int lastID;
//触发当时VIP等级
public int vipLevel;
public int rodDstId;
public int rodSrcId;
}
public partial class FishingEventData
{
string Pack1A2DataKey = "Pack1A2Data";
public Pack1A2Data Pack1A2Data;
bool isFace12;
void GiftFace1A2(EventPackManager packManager, int eventID)
{
if (isFace12)
{
return;
}
if (Pack1A2Data == null)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(eventID, UITypes.GiftPopupPanel_11, packManager.PackType, true);
}
else
{
List<int> packIDs = packManager.VIPPackList[Pack1A2Data.vipLevel];
if (Pack1A2Data.lastID != eventID || packIDs.Count > Pack1A2Data.index)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(eventID, UITypes.GiftPopupPanel_11, packManager.PackType, true);
}
}
}
public void SetPack1A2(FishingEvent t)
{
if (Pack1A2Data == null)
{
string json_duelData = PlayFabMgr.Instance.GetLocalData(Pack1A2DataKey);
if (json_duelData != null)
{
Pack1A2Data = Newtonsoft.Json.JsonConvert.DeserializeObject<Pack1A2Data>(json_duelData);
}
}
EventPackManager eventPackDataRead = _tables.TbEventPackManager.DataMap[t.RedirectID];
GiftFace1A2(eventPackDataRead, t.ID);
if (Pack1A2Data != null && Pack1A2Data.lastID == t.ID)
{
return;
}
Pack1A2Data = new Pack1A2Data(
eventPackDataRead.ID,
t.ID,//活动id
GContext.container.Resolve<PlayerData>().PriceLv
);
SetRodDstId();
RedPointManager.Instance.SetRedPointState(HomeBtnOneTwoPack.redKey, false);
PlayFabMgr.Instance.UpdateUserDataValue(Pack1A2DataKey, JsonMapper.ToJson(Pack1A2Data));
}
void SetRodDstId()
{
Pack1A2Data.rodSrcId = 330040000;
Item item = _tables.TbItem.GetOrDefault(Pack1A2Data.rodSrcId);
Drop drop = _tables.TbDrop.GetOrDefault(item.RedirectID);
List<int> rodIDs = drop.DropList.DropIDList;
int level = -1;
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
for (int i = 0; i < rodIDs.Count; i++)
{
int curLevel = playerFishData.GetRodLevel(rodIDs[i]);
if (curLevel > level)
{
level = curLevel;
Pack1A2Data.rodDstId = rodIDs[i];
}
}
}
public void SetPack1A2Index()
{
if (Pack1A2Data == null)
{
return;
}
Pack1A2Data.index++;
PlayFabMgr.Instance.UpdateUserDataValue(Pack1A2DataKey, JsonMapper.ToJson(Pack1A2Data));
SetChainPackRed();
}
void SetChainPackRed()
{
bool isRed = false;
EventPackManager eventPackManager = Get1A2EventPackManager();
List<int> packIDs = eventPackManager.VIPPackList[Pack1A2Data.vipLevel];
if (packIDs.Count > Pack1A2Data.index)
{
var pack = _tables.TbPack.GetOrDefault(packIDs[Pack1A2Data.index]);
isRed = _tables.TbIAPItemList.GetOrDefault(pack.IAPID) == null;
}
else
{
//购买完 特殊处理
GContext.Publish(new TargetEvent(Pack1A2Data.lastID, 6, 1));
}
RedPointManager.Instance.SetRedPointState(HomeBtnOneTwoPack.redKey, isRed);
}
public int GetPack1A2Index()
{
isFace12 = true;
if (Pack1A2Data == null)
{
return 100;
}
return Pack1A2Data.index;
}
public EventPackManager Get1A2EventPackManager()
{
if (Pack1A2Data == null)
{
return null;
}
return _tables.TbEventPackManager.DataMap[Pack1A2Data.ID];
}
public DateTime GetEvent1A2EndTime()
{
if (Pack1A2Data == null)
{
return ZZTimeHelper.UtcNow().UtcNowOffset(); ;
}
return GetEventEndTime(Pack1A2Data.lastID);
}
public List<ItemData> Get1A2ItemDatasBuyPack(int dropID)
{
List<ItemData> itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(dropID);
for (int i = 0; i < itemDatas.Count; i++)
{
if (itemDatas[i].id == Pack1A2Data.rodSrcId)
{
itemDatas[i].id = Pack1A2Data.rodDstId;
}
}
return itemDatas;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce6ba0b399cd2f944a1214835e9747af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,279 @@
using asap.core;
using cfg;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace GameCore
{
public partial class FishingEventData : IDisposable
{
void GetTransitionDataPVP(int subType = 0)
{
FishingEvent fishingEvent = null;
if (transitionDataDic != null)
{
foreach (var item in transitionDataDic)
{
FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(item.Key);
if (fe != null && (subType == fe.SubType || subType == 0) && fe.Type == 5 && !Condition(fe))
{
fishingEvent = fe;
int count = transitionDataDic[fishingEvent.ID];
if (count > 0)
{
PvpEventCycleItem cycle = _tables.TbPvpEventCycleItem.
DataList.Find(x => x.Type == fe.Type && x.SubType == fe.SubType);
if (cycle != null)
{
SetTransitionData(fishingEvent.ID, cycle.EventName_l10n_key, cycle.ItemId, cycle.EventEndSettlement);
}
}
else
{
transitionDataDic.Remove(fishingEvent.ID);
SaveTransitionData();
}
break;
}
}
}
}
public int GetInitWelcomeGiftPVP(int eventID)
{
int welcomeGift = 0;
if (eventID > 0)
{
FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(eventID);
if (fe != null)
{
PvpEventCycleItem cycle = _tables.TbPvpEventCycleItem.
DataList.Find(x => x.Type == fe.Type && x.SubType == fe.SubType);
if (cycle != null)
{
welcomeGift = cycle.WelcomeGift;
}
}
}
return welcomeGift;
}
public int GetRedDotPVP(int eventID)
{
int redDot = 10;
if (eventID > 0)
{
FishingEvent fe = _tables.TbFishingEvent.GetOrDefault(eventID);
if (fe != null)
{
PvpEventCycleItem cycle = _tables.TbPvpEventCycleItem.
DataList.Find(x => x.Type == fe.Type && x.SubType == fe.SubType);
if (cycle != null)
{
redDot = cycle.RedDot;
}
}
}
return redDot;
}
#region SoloData
public DuelData duelData { get; private set; }
int rankTierChangeState = 0;
EventSolomain rankTierChangeSolomain;
public int PVPToken { private set; get; }//pvp商店代币
public void SetRankTierChange(bool isUp, EventSolomain eventSolomain)
{
rankTierChangeState = isUp ? 1 : 2;
rankTierChangeSolomain = eventSolomain;
}
public async void ShowRankTierChange()
{
if (rankTierChangeState > 0 && rankTierChangeSolomain != null)
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.EventFishingDuelRankChangePopupPanel);
EventFishingDuelRankChangePopupPanel changePopupPanel = go.GetComponent<EventFishingDuelRankChangePopupPanel>();
changePopupPanel.SetRank(rankTierChangeState == 1, rankTierChangeSolomain);
rankTierChangeState = 0;
rankTierChangeSolomain = null;
}
}
public void SoloCheckClaimReward()
{
string json_duelData = PlayFabMgr.Instance.GetLocalData(FishingDuelManager.SoloDataKey);
if (json_duelData != null)
{
duelData = Newtonsoft.Json.JsonConvert.DeserializeObject<DuelData>(json_duelData);
int fishingEventID = GContext.container.Resolve<FishingEventData>().GetEvent(5, 1);
if (duelData.rewardEventID > 0 && duelData.preProgress > 0 && duelData.rewardEventID != fishingEventID)
{
GContext.container.Resolve<IFaceUIService>().AddFaceCustomUIData(UITypes.EventFishingDuelSettlementPanel, true);
//_ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelSettlementPanel);
}
//GetTransitionDataPVP(1);
}
}
//领取赛季奖励
public void ClaimReward()
{
if (duelData.rewardEventID > 0 && duelData.preProgress > 0)
{
duelData.soloTimes = 0;
duelData.rewardEventID = 0;
duelData.preProgress = 0;
string json_duelData = Newtonsoft.Json.JsonConvert.SerializeObject(duelData);
PlayFabMgr.Instance.UpdateUserDataValue(FishingDuelManager.SoloDataKey, json_duelData);
}
}
public void GMAddSoloProgress(int count)
{
if (duelData != null)
{
duelData.progress = count;
SaveDuelData();
}
}
public void InitSoloData(FishingEvent t)
{
string json_duelData = PlayFabMgr.Instance.GetLocalData(FishingDuelManager.SoloDataKey);
if (json_duelData != null)
{
duelData = Newtonsoft.Json.JsonConvert.DeserializeObject<DuelData>(json_duelData);
}
else
{
duelData = new DuelData();
duelData.progress = _tables.TbEventSoloConfig.InitTrophy;
}
if (t.ID != duelData.eventID)
{
duelData.eventID = t.ID;
int min = GetInitWelcomeGiftPVP(t.ID);
if (duelData.tickets < min)
{
duelData.tickets = min;
}
duelData.soloTimes = 0;
duelData.rePVPToken = 0;
duelData.buyItem.Clear();
int reset = duelData.progress - _tables.TbEventSoloConfig.MinTrophy;
if (reset > 0)
{
//duelData.progress = _tables.TbEventSoloConfig.SettlementTrophy +
// (int)(reset * _tables.TbEventSoloConfig.SettlementTrophyMultiplier);
var data = _tables.TbEventSolomain.DataList;
var solomain = data[0];
if (duelData.progress > 0)
{
for (int i = data.Count - 1; i >= 0; i--)
{
if (duelData.progress >= data[i].TrophyRange[0])
{
solomain = data[i];
break;
}
}
}
duelData.progress -= solomain.SettleDeducTrophy;
}
//duelData.progress /= _tables.TbEventSoloConfig.TrophyMutiple;
//duelData.progress *= _tables.TbEventSoloConfig.TrophyMutiple;
if (duelData.progress < _tables.TbEventSoloConfig.MinTrophy)
{
duelData.progress = _tables.TbEventSoloConfig.MinTrophy;
}
//GContext.Publish(new TargetEvent(t.ID, 5, 1));
SaveDuelData();
}
}
public void AddDuelTickets(int tickets)
{
if (duelData != null)
{
if (tickets < 0)
{
duelData.soloTimes++;
if (duelData.soloTimes >= _tables.TbEventSoloConfig.ClaimRewardMatchCount)
{
duelData.rewardEventID = duelData.eventID;
duelData.preProgress = duelData.progress;
}
}
duelData.tickets += tickets;
//SaveTransitionData(duelData.eventID, duelData.tickets);
SaveDuelData();
}
}
public int GetDuelTickets()
{
if (duelData != null)
{
return duelData.tickets;
}
return 0;
}
public bool BuyPVPItem(int id)
{
if (duelData != null && !duelData.buyItem.ContainsKey(id))
{
duelData.buyItem[id] = 1;
SaveDuelData();
return true;
}
return false;
}
public bool IsBuyPVPItem(int id)
{
if (duelData != null && duelData.buyItem.ContainsKey(id))
{
return true;
}
return false;
}
public DateTime SetPVPShopTime()
{
DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset().Date;
int offfset = (int)dateTime.DayOfWeek - 1;
if (offfset < 0)
{
offfset = -offfset;
}
else
{
offfset = 7 - offfset;
}
DateTime endTime = dateTime.AddDays(offfset);
if (endTime.DayOfYear != duelData.pvpShopTimeDay)
{
if (duelData.pvpShopTimeDay != -1)
{
duelData.buyItem.Clear();
}
duelData.pvpShopTimeDay = endTime.DayOfYear;
SaveDuelData();
}
return endTime;
}
public void AddPVPToken(int value)
{
PVPToken += value;
PlayFabMgr.Instance.UpdateUserDataValue("PVPToken", PVPToken.ToString());
if (value < 0 && duelData != null)
{
duelData.rePVPToken -= value;
SaveDuelData();
}
}
public void SaveDuelData()
{
string json_duelData = Newtonsoft.Json.JsonConvert.SerializeObject(duelData);
PlayFabMgr.Instance.UpdateUserDataValue(FishingDuelManager.SoloDataKey, json_duelData);
}
#endregion SoloData
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d549bdbf90b685042bc0a1c31c63c525
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using cfg;
using System.Collections.Generic;
public struct GeneralEventPackData
{
public int currentEventID;
public int redirectID;
public int VIPLvlWhenEventActivate;
public int purchaseCount;
public bool doNeedTrigger;
public bool isTriggered;
public int savingProgress;
public int discountLvl;
public int visualProgress;
public int visualDiscountLvl;
#region rodSelection
public int rodID;
public int lastPackIDBought;
public int packID;
#endregion
#region SelectionPack
public List<int> selections;
#endregion
public GeneralEventPackData(int eventID = 0, int redirectID = 0,
int vip = 0, int purchaseCount = 0, bool doNeedTrigger = false,
bool isTriggered = false, int savingProgress = 0, int discountLvl = 0,
int visualProgress = 0, int visualDiscountLvl = 0, int rodID = 0,
int lastPackIDBought = 0, int packID = 0, List<int> selections = null)
{
currentEventID = eventID;
this.redirectID = redirectID;
VIPLvlWhenEventActivate = vip;
this.purchaseCount = purchaseCount;
this.doNeedTrigger = doNeedTrigger;
this.isTriggered = isTriggered;
this.savingProgress = savingProgress;
this.discountLvl = discountLvl;
this.visualProgress = visualProgress;
this.visualDiscountLvl = visualDiscountLvl;
this.rodID = rodID;
this.lastPackIDBought= lastPackIDBought;
this.packID = packID;
this.selections = selections;
}
}
public interface IEventPackData
{
public void LoadData(string s);
public void LoadData(GeneralEventPackData d);
public bool UpdateData(FishingEvent e);
public void SaveData();
public bool IsPackActivated { get; }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc0cb74ad61cb5a409e95606033c6033
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,487 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using asap.core;
using cfg;
using game;
using GameCore;
using Newtonsoft.Json;
using UnityEngine;
namespace DataCenter
{
// 锁链礼包
public class TOfferChainsData
{
public class TItem
{
public int Id;
public int Item;
public int Number;
// 0 可选1 高亮 2 糊了 ,锁链隐藏 应该转换成Enum
public int Status;
// public int SKUId;
}
public bool FirstOpen; // 是否首次打开
public int EventId; // 默认存一下ID
public DateTime StartTime; // 开始时间
public DateTime EndTime;// 结束时间
public int ItemId = -1;
// 当前抽奖次数,必须抽了才会更新
public int LotteryNum;
public List<TItem> Items;
public bool Finished;
public int ChestReward;
public List<int> RewardList; // 当前获得的奖励Item
}
public class OfferChainsChestManager
{
public const string SaveKey = "OfferChainsChestData";
[Inject] public Tables _tables { get; set; }
// 计入当前Event
private FishingEvent _fishingEvent;
//
public EventOfferChainsChestMain OfferChainsChestMain { get; set; }
public List<EventOfferChainsChestRewards> OfferChainsChestRewards { get; set; }
// 当前可保存数据
public TOfferChainsData OfferChainsData { get; private set; }
public List<int> ValidIds;
public bool IsFirstOpen
{
get => OfferChainsData.FirstOpen;
set
{
if (OfferChainsData.FirstOpen)
{
OfferChainsData.FirstOpen = false;
DoSave();
}
}
}
public void UpdateEventData(FishingEvent fishingEvent)
{
Log($"Refresh - > {fishingEvent}");
_fishingEvent = fishingEvent;
UpdateLocalData();
}
private void UpdateLocalData()
{
//选择当前的 Main
var redirectId = _fishingEvent.RedirectID;
var configList = _tables.TbEventOfferChainsChestMain.DataList;
foreach (var eventChallenge in configList.Where(eventChallenge => eventChallenge.ID == redirectId))
{
OfferChainsChestMain = eventChallenge;
break;
}
OfferChainsChestRewards = _tables.TbEventOfferChainsChestRewards.DataList;
// SkuIds = OfferChainsChestMain.IapList;
}
public void Init()
{
Log("Init-> ");
if (OfferChainsData == null)
{
if (_fishingEvent == null) // 不存在Event
{
return;
}
InitOfferChainsData();
}
UpdateOfferChainsData();
}
//
private void ProcessLastOne()
{
if (OfferChainsData != null)
{
if(!IsTimeAllow())
{
Settle();
ClearOfferChainsData();
}
else if (IsCanGetFinalReward())
{
Settle(); // 补充一下最终大奖
}
}
}
private void UpdateOfferChainsData()
{
// 更新可用数据
UpdateTime();
UpdateOfferChainsItems();
UpdateLotteryItemId();
}
private void InitOfferChainsData()
{
var limitedTime = (LimitedTime)_fishingEvent.TimeDefinition;
var startTime = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow());
var endTime = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow());
OfferChainsData = new TOfferChainsData
{
FirstOpen = true,
EventId = _fishingEvent.ID,
StartTime = startTime,
EndTime = endTime,
Items = new List<TOfferChainsData.TItem>(),
RewardList = new List<int>(),
ChestReward = OfferChainsChestMain.ChestReward, // 最终大奖存储下,方便额外的处理
};
for (var i = 0; i < OfferChainsChestRewards.Count; ++i)
{
var item = new TOfferChainsData.TItem
{
Id = OfferChainsChestRewards[i].ID,
Item = OfferChainsChestRewards[i].Item,
Number = OfferChainsChestRewards[i].Number,
Status = 0,
// SKUId = OfferChainsChestMain.IapList[i],
};
OfferChainsData.Items.Add(item);
}
}
public bool IsTimeAllow()
{
var now = ZZTimeHelper.UtcNow();
var startTime = OfferChainsData.StartTime;
var endTime = OfferChainsData.EndTime;
#if UNITY_EDITOR
var timeOpened = (now - startTime).TotalSeconds;
var timeEnded = ( endTime -now).TotalSeconds;
Log($"StartTime: {startTime} Now: {now} EndTime:{endTime} TimeOpened:{timeOpened} TimeToEnd:{timeEnded} Other: {1800000- timeOpened} IsTimeAllow => {now <= endTime}");
#endif
return now >= startTime && now <= endTime;
}
public void CheckInit()
{
ProcessLastOne();
Init();
}
// ReSharper disable Unity.PerformanceAnalysis
private static void Log(object t)
{
Debug.Log($"<color=yellow>OfferChainsChestManager -> {t} </color>");
}
public bool CheckOpen()
{
//
if (OfferChainsData == null) return false;
//
if (!IsTimeAllow()) return false;
if (OfferChainsChestMain == null)
{
return false;
}
if (IsFinished())
{
return false;
}
return true;
}
public bool IsFinished()
{
return OfferChainsData?.Finished ?? false;
}
private void DoSave()
{
PlayFabMgr.Instance.UpdateUserDataValue(SaveKey, JsonConvert.SerializeObject(OfferChainsData));
}
public void LoadChainsChestData(string dataValue)
{
OfferChainsData = JsonConvert.DeserializeObject<TOfferChainsData>(dataValue);
}
// 进入游戏舞台
public async void OnEnterGameAct()
{
Log("OnEnterGameAct()");
IsFirstOpen = false;
await UIManager.Instance.ShowUI(new UIType(OfferChainsChestMain.UIPanel));
}
private static T WeightedRandom<T>(Dictionary<T, int> weightTable)
{
// 1. 计算总权重
var totalWeight = weightTable.Values.Sum();
// 2. 生成随机数
var randomValue = UnityEngine.Random.Range(0, totalWeight);
// 3. 线性遍历选择
var currentWeight = 0;
foreach (var (key, value) in weightTable)
{
currentWeight += value;
if (randomValue < currentWeight)
return key;
}
return default; // 理论上不会执行到这里
}
// 活动当前的抽奖索引
private int CalcLotteryItemId()
{
var lotteryNum = OfferChainsData.LotteryNum;
// var validIds = (from item in OfferChainsData.Items where item.Status == 0 select item.Id).ToList();
ValidIds = (from item in OfferChainsData?.Items where item.Status == 0 select item.Id).ToList();
if (ValidIds.Count <= 0)
{
return -1;
}
if (OfferChainsChestRewards == null)
{
return -1;
}
//
// while (true)
// {
var dict = OfferChainsChestRewards.Where(
item => ValidIds.Contains(item.ID) && item.LimitConfig <= lotteryNum)
.ToDictionary(elem => (elem.ID, elem.LimitConfig), elem => elem.Weight);
var (elemId, limitConfig) = WeightedRandom(dict);
Log($"CalcLotteryItemId -> {lotteryNum} {elemId} {limitConfig}");
// if (limitConfig >0 && lotteryNum > limitConfig )
return elemId;
// }
}
public int GetLotteryItemId()
{
if (OfferChainsData.ItemId == -1)
{
UpdateLotteryItemId();
}
return OfferChainsData.ItemId;
}
private void UpdateOfferChainsItems()
{
if (OfferChainsData != null && _fishingEvent != null && OfferChainsData.EventId == _fishingEvent.ID)
{
var items = OfferChainsData.Items;
if (OfferChainsChestRewards is { Count: > 0 })
{
for (int i = 0; i < items.Count; ++i)
{
EventOfferChainsChestRewards reward = null;
if (i < OfferChainsChestRewards.Count)
{
reward = OfferChainsChestRewards[i];
}
if (reward != null)
{
items[i].Id = reward.ID;
items[i].Item = reward.Item;
items[i].Number = reward.Number;
}
}
}
if (OfferChainsChestMain != null)
{
OfferChainsData.ChestReward = OfferChainsChestMain.ChestReward;
}
}
// for (var i = 0; i < OfferChainsChestRewards.Count; ++i)
// {
// var item = new TOfferChainsData.TItem
// {
// Id = OfferChainsChestRewards[i].ID,
// Item = OfferChainsChestRewards[i].Item,
// Number = OfferChainsChestRewards[i].Number,
// Status = 0,
// };
// OfferChainsData.Items.Add(item);
// }
}
private void UpdateTime()
{
if (OfferChainsData != null && _fishingEvent != null && OfferChainsData.EventId == _fishingEvent.ID)
{
var limitedTime = (LimitedTime)_fishingEvent.TimeDefinition;
var startTime = GlobalUtils.TryParseDateTime(limitedTime.StartTime, ZZTimeHelper.UtcNow());
var endTime = GlobalUtils.TryParseDateTime(limitedTime.EndTime, ZZTimeHelper.UtcNow().AddDays(-1));
OfferChainsData.StartTime = startTime;
OfferChainsData.EndTime = endTime;
}
}
private void UpdateLotteryItemId()
{
// ValidIds = (from item in OfferChainsData?.Items where item.Status == 0 select item.Id).ToList();
var targetId = CalcLotteryItemId();
OfferChainsData.ItemId = targetId;
DoSave();
}
public void FinishLottery(int targetId)
{
Log($"FinishLottery -> {targetId}");
var lastItem = OfferChainsData.Items.SingleOrDefault(it => it.Id == targetId);
if (lastItem is {Status: not 2})
{
lastItem.Status = 2;
// OfferChainsData.LotteryNum += 1;
// OfferChainsData.RewardList.Add(targetId);
UpdateLotteryItemId();
}
}
public bool IsCanGetFinalReward()
{
return OfferChainsData.LotteryNum >= OfferChainsData.Items.Count
&& !OfferChainsData.Finished;
}
public void ClearOfferChainsData()
{
OfferChainsData = null;
DoSave();
}
public TOfferChainsData.TItem GetTItemById(int targetId)
{
var lastItem = OfferChainsData.Items.FirstOrDefault(it => it.Id == targetId);
return lastItem;
}
public int GetDropIdById(int id)
{
var item = GetTItemById(id);
var itemData = _tables.TbItem.GetOrDefault(item.Item);
return itemData.RedirectID;
}
public void OnGetFinalReward()
{
// var item = _tables.TbItem.GetOrDefault(OfferChainsChestMain.ChestReward);
var item = _tables.TbItem.GetOrDefault(OfferChainsData.ChestReward);
var itemFinal = GContext.container.Resolve<PlayerItemData>()
.GetItemDropPackageItemList(item.RedirectID, 1);
GContext.container.Resolve<PlayerItemData>().AddItem(itemFinal);
GContext.Publish(new ShowData(itemFinal));
GContext.Publish(new ShowData());
OfferChainsData.Finished = true;
DoSave();
GContext.Publish(new OfferChainsRefreshEvent());
}
public float GetProbability(int id)
{
var theIdWeight = OfferChainsChestRewards .FirstOrDefault(item => item.ID == id)?.Weight ?? 0;
var weightTable = OfferChainsChestRewards
.Where(item => !IsItemFinished(item.ID) )
.Select(item => item.Weight ).ToList();
var totalWeight = weightTable.Sum();
return (float)Math.Round((float)theIdWeight / totalWeight * 100, 2);
}
private bool IsItemFinished(int itemID)
{
var lastItem = OfferChainsData.Items.SingleOrDefault(it => it.Id == itemID);
return lastItem?.Status == 2;
}
public TimeSpan GetTimeRemain()
{
if (OfferChainsData != null)
{
return OfferChainsData.EndTime - ZZTimeHelper.UtcNow();
}
// 活动未开始
return ZZTimeHelper.UtcNow().AddDays(-1) - ZZTimeHelper.UtcNow();
}
public void Settle()
{
if (IsCanGetFinalReward())
{
OnGetFinalReward();
}
}
public bool UIRunning { get; set; } = false;
public void OnBuySuccess()
{
Log("OnBuySuccess -> ");
OfferChainsData.RewardList.Add(OfferChainsData.ItemId);
OfferChainsData.LotteryNum += 1;
if (IsCanGetFinalReward())
{
OfferChainsData.RewardList.Add(OfferChainsData.ChestReward);
}
EventTracking();
//NEXT TURN
if (UIRunning)
{ // 播放动画逻辑交给UI
return;
}
// 补单,直接给奖励
FinishLottery(OfferChainsData.ItemId);
Settle();
}
public void EventTracking()
{
//var price = GetPayAmountById(OfferChainsData.ItemId);
var price = GetIapItemListThisTime(OfferChainsData.LotteryNum -1)?.PaymentAmount ??0F;
var itemEnt = GetTItemById(OfferChainsData.ItemId);
var rewardStr = string.Join(',', OfferChainsData.RewardList);
var number = OfferChainsData.LotteryNum;
#if AGG
using (var e = GEvent.TackEvent("offer_chainchest"))
{
e.AddContent("event_id", OfferChainsData.EventId);
e.AddContent("number",number);
e.AddContent("price", price);
e.AddContent("reward",OfferChainsData.ItemId);
e.AddContent("reward_claimed_list", rewardStr);
}
#endif
Log($"EventTracking: event_id: {OfferChainsData.EventId} number: {number} price: {price} " +
$"reward :{OfferChainsData.ItemId} reward_claimed_list :{rewardStr}" );
}
public IAPItemList GetIapItemListThisTime()
{
return GetIapItemListThisTime(OfferChainsData.LotteryNum);
}
private IAPItemList GetIapItemListThisTime(int index)
{
// var index = OfferChainsData.LotteryNum;
index = Mathf.Clamp(index, 0, OfferChainsChestMain.IapList.Count -1);
var iapId = OfferChainsChestMain.IapList[index];
var iAPItemList = _tables.TbIAPItemList.GetOrDefault(iapId);
return iAPItemList;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c38c5f67434448fb8bf8f3a674b14567
timeCreated: 1755334538

View File

@@ -0,0 +1,192 @@
using asap.core;
using GameCore;
using cfg;
using UnityEngine;
using System.Collections.Generic;
using System;
using game;
using System.Linq;
public class PiggyBankPackData
{
private readonly Tables _tables = GContext.container.Resolve<Tables>();
private readonly TbEventPackManager _epm
= GContext.container.Resolve<Tables>().TbEventPackManager;
private struct Data
{
public int currentEventID;
public int purchaseCount;
public int VIPLvlWhenEventActivate;
public bool doNeedTrigger;
public bool isTriggered;
public int savingProgress;
public int redirectID;
public Data(int eventID = 0, int v = 0, bool b = false, int rid = 0)
{
currentEventID = eventID;
purchaseCount = 0;
VIPLvlWhenEventActivate = v;
doNeedTrigger = b;
savingProgress = 0;
isTriggered = false;
redirectID = rid;
}
}
private Data _data;
public bool IsWithinEventTime
{
get
{
if (!_tables.TbFishingEvent.DataMap.Keys.Contains(_data.currentEventID))
return false;
var et = DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).EndTime);
var st = DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).StartTime);
return ZZTimeHelper.UtcNow() >= st && ZZTimeHelper.UtcNow() < et;
}
}
public bool IsPackActivated { get => _data.isTriggered && _tables.TbFishingEvent.DataMap.Keys.Contains(_data.currentEventID) && IsWithinEventTime && _data.purchaseCount < _epm[RedirectID].MaxCount; }
public bool DoNeedUpdate { get => _data.doNeedTrigger; set => _data.doNeedTrigger = value; }
public int CurrentEventID { get => _data.currentEventID; }
public int PurchaseCount { get => _data.purchaseCount; }
public int VIPLvlWhenEventActivated { get => _data.VIPLvlWhenEventActivate; }
public int Progress { get => _data.savingProgress; }
public bool IsFull { get => _data.savingProgress >= Target; }
public int ActivateItemId
{
get => _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]]
.ActivateItemId;
}
public string ActiveItemImg { get => _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]].ActiveItemImg; }
public int EventItemId
{
get
{
SpecialPack specialPack = GetSpecialPack();
if (specialPack != null)
{
return specialPack.EventItemId;
}
return 0;
}
}
SpecialPack GetSpecialPack()
{
var TbEventPackManager = _tables.TbEventPackManager.GetOrDefault(_data.redirectID);
if (TbEventPackManager == null)
{
return null;
}
return _tables.TbSpecialPack.GetOrDefault(TbEventPackManager.VIPPackList[_data.VIPLvlWhenEventActivate][0]);
}
public int Target
{
get => _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]]
.EventItemRequire[0];
}
public int CanBuyCount
{
get => _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]]
.CanBuyCount;
}
//public int RedirectID { get => _tables.TbFishingEvent[_data.currentEventID].RedirectID; }
public int RedirectID { get => _data.redirectID; }
public int RewardDropID
{
get => _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]]
.DropID[0];
}
public List<int> FishingScoreList
{
get => _tables.TbSpecialPack[_epm[RedirectID].VIPPackList[_data.VIPLvlWhenEventActivate][0]]
.EventItemGet;
}
public TimeSpan RemainingTime
{
get
{
return DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).EndTime)
- ZZTimeHelper.UtcNow();
}
}
public int MaxCount { get => _epm[RedirectID].MaxCount; }
public void LoadData(string s)
{
_data = Newtonsoft.Json.JsonConvert.DeserializeObject<Data>(s);
//_data.redirectID = 0;
if (_data.redirectID == 0)
{
_data.redirectID = 4055001;
}
}
public void UpdateData(cfg.FishingEvent e)
{
if (_epm[_tables.TbFishingEvent[e.ID].RedirectID].PackType != 2)
{
Debug.LogError($"Fishing event ID {e.ID} is not a piggyBank event.");
return;
}
if (_data.currentEventID != e.ID)
_data = new Data(e.ID, GContext.container.Resolve<PlayerData>().PriceLv, true, e.RedirectID);
if (_data.redirectID != e.RedirectID)
{
_data.redirectID = e.RedirectID;
Debug.Log("working!!!!!!!!!!");
}
SaveData();
}
public void SaveData()
{
PlayFabMgr.Instance.UpdateUserDataValue("PiggyBankPackData",
Newtonsoft.Json.JsonConvert.SerializeObject(_data));
}
public bool AddProgress(int fishTier, int magnification)
{
if (!IsPackActivated || fishTier < 1 || fishTier > 5)
{
//Debug.LogError($"Fish Tier {fishTier} not defined in TbSpedialPack");
return false;
}
var TbSpecialPack = _tables.TbSpecialPack[_epm[RedirectID].VIPPackList[_data.VIPLvlWhenEventActivate][0]];
int progress = TbSpecialPack.EventItemGet[fishTier - 1] * magnification;
if (progress > 0 && _data.savingProgress < Target)
{
int curProgress = _data.savingProgress;
_data.savingProgress += progress;
GContext.Publish(new TargetAddData(TbSpecialPack.EventItemId, curProgress, progress));
if (_data.savingProgress >= Target)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(_data.currentEventID, UITypes.GiftPiggyBankPopupPanel, 0, true);
_data.savingProgress = Target;
SaveData();
return true;
}
SaveData();
}
return false;
}
public void AddPurchase()
{
_data.purchaseCount++;
SaveData();
}
public void TriggerPack()
{
DoNeedUpdate = false;
_data.isTriggered = true;
_data.savingProgress += _tables.TbSpecialPack[_epm[RedirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]].EventItemCountFirst;
SaveData();
}
}
public class PiggyBankProgressEvent
{
public int type;//0: 初始化 1增加动画
public int addProgress;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 50bb7a99f5731804a9109b30fce969b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,681 @@
using asap.core;
using cfg;
using LitJson;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace GameCore
{
public class RodGSAData
{
public int GloveID;
public Dictionary<int, int> RodToSkin = new Dictionary<int, int>();
public List<int> GloveIds = new List<int>();
public List<int> SkinIds = new List<int>();
public List<int> GloveNewIds = new List<int>();
public List<int> SkinNewIds = new List<int>();
}
public partial class PlayerFishData
{
#region
public RodGSAData rodAccessoriesData;
string InitRodAccessoriesDataKey = "InitRodAccessoriesData";
public GloveData GetGloveData
{
get
{
return _tables.TbGloveData.GetOrDefault(rodAccessoriesData.GloveID);
}
}
public void InitRodAccessoriesData()
{
if (rodAccessoriesData == null || rodAccessoriesData.GloveID == 0)
{
rodAccessoriesData = new RodGSAData();
rodAccessoriesData.GloveID = _tables.TbGlobalConfig.InitGloveID;
rodAccessoriesData.GloveIds = new List<int>() { _tables.TbGlobalConfig.InitGloveID };
}
}
/// <summary>
/// 获取鱼杆对应的皮肤
/// </summary>
/// <param name="rodId"></param>
/// <returns></returns>
public int GetRodSkin(int rodId)
{
if (rodAccessoriesData.RodToSkin.ContainsKey(rodId))
{
return rodAccessoriesData.RodToSkin[rodId];
}
return rodId;
}
/// <summary>
/// 设置鱼杆对应的皮肤
/// </summary>
/// <param name="rodId"></param>
/// <param name="skinId"></param>
public void SetRodSkin(int rodId, int skinId)
{
if (skinId <= 0)
{
skinId = rodId;
}
rodAccessoriesData.RodToSkin[rodId] = skinId;
SaveInitRodAccessoriesData();
}
public void InitRodAccessoriesData(string value)
{
rodAccessoriesData = Newtonsoft.Json.JsonConvert.DeserializeObject<RodGSAData>(value);
}
public void SaveInitRodAccessoriesData()
{
string value = Newtonsoft.Json.JsonConvert.SerializeObject(rodAccessoriesData);
PlayFabMgr.Instance.UpdateUserDataValue(InitRodAccessoriesDataKey, value);
}
/// <summary>
/// 手是否解锁
/// </summary>
/// <param name="gloveId"></param>
/// <returns></returns>
public bool IsGloveUnlocked(int gloveId)
{
return rodAccessoriesData.GloveIds.Contains(gloveId);
}
/// <summary>
/// 皮肤是否解锁
/// </summary>
/// <param name="skinId"></param>
/// <returns></returns>
public bool IsSkinUnlocked(int skinId)
{
return rodAccessoriesData.SkinIds.Contains(skinId);
}
/// <summary>
/// 解锁手
/// </summary>
/// <param name="gloveId"></param>
public void UnlockGlove(int gloveId)
{
if (!IsGloveUnlocked(gloveId))
{
rodAccessoriesData.GloveIds.Add(gloveId);
rodAccessoriesData.GloveNewIds.Add(gloveId);
SaveInitRodAccessoriesData();
}
else
{
Debug.LogError("手投放重复:" + gloveId);
}
}
/// <summary>
/// 解锁皮肤
/// </summary>
/// <param name="skinId"></param>
public void UnlockSkin(int skinId)
{
if (!IsSkinUnlocked(skinId))
{
rodAccessoriesData.SkinIds.Add(skinId);
rodAccessoriesData.SkinNewIds.Add(skinId);
SaveInitRodAccessoriesData();
}
else
{
Debug.LogError("鱼杆皮肤投放重复:" + skinId);
}
}
/// <summary>
/// 获取是否是没查看过的手
/// </summary>
/// <param name="skinId"></param>
/// <returns></returns>
public bool IsNewGlove(int skinId)
{
return rodAccessoriesData.GloveNewIds.Contains(skinId);
}
/// <summary>
/// 是否是没查看过的皮肤
/// </summary>
/// <param name="skinId"></param>
/// <returns></returns>
public bool IsNewSkin(int skinId)
{
bool isNew = rodAccessoriesData.SkinNewIds.Contains(skinId);
if (isNew)
{
rodAccessoriesData.SkinNewIds.Remove(skinId);
}
return isNew;
}
/// <summary>
/// 取消new标记 手
/// </summary>
/// <param name="gloveId"></param>
public void RemoveGloveNewId()
{
if (rodAccessoriesData.GloveNewIds.Count > 0)
{
rodAccessoriesData.GloveNewIds.Clear();
SaveInitRodAccessoriesData();
}
}
#endregion
#region
//合成或强化鱼竿
bool EnhanceConsumed(int quality, int fragmentID, int rquiredFragments)
{
if (rodData.TryGetValue(fragmentID, out int rodCount) && rodCount >= rquiredFragments)
{
rodData[fragmentID] -= rquiredFragments;
#if AGG
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", fragmentID)
.AddContent("state_info", "cost")
.AddContent("change_num", rquiredFragments);
}
#endif
return true;
}
else
{
rquiredFragments -= rodCount;
RodFragmentExchange rodFragmentExchange = _tables.TbRodFragmentExchange.GetOrDefault(quality);
int fragment = 0;
if (rodFragmentExchange != null)
{
rquiredFragments *= rodFragmentExchange.ExchangeRate;
fragment = GContext.container.Resolve<PlayerFishData>().GetRodPiece(rodFragmentExchange.GeneralFragmentID);
}
if (fragment >= rquiredFragments)
{
if (rodData.ContainsKey(fragmentID))
{
rodData[fragmentID] = 0;
}
rodData[rodFragmentExchange.GeneralFragmentID] -= rquiredFragments;
#if AGG
if (rodCount > 0)
{
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", fragmentID)
.AddContent("state_info", "cost")
.AddContent("change_num", rodCount);
}
}
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", rodFragmentExchange.GeneralFragmentID)
.AddContent("state_info", "cost")
.AddContent("change_num", rquiredFragments);
}
#endif
return true;
}
}
return false;
}
public void AscendRod(int id)
{
RodData _rodData = _tables.TbRodData.GetOrDefault(id);
if (_rodData != null)
{
bool isUp = false;
RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
int rquiredFragments;
int fragmentID = rodAscend.FragmentID;
int quality = _rodData.Quality;
if (rodData.ContainsKey(id))
{
rquiredFragments = rodAscend.AscentTransformed[rodData[id] + 1];
if (rodData[id] < rodAscend.AscentTransformed.Count - 1 && EnhanceConsumed(quality, fragmentID, rquiredFragments))
{
isUp = true;
rodData[id] += 1;
}
}
else
{
rquiredFragments = rodAscend.AscentTransformed[0];
if (rodData.TryGetValue(fragmentID, out int rodCount) && rodCount >= rquiredFragments)
{
rodData[fragmentID] -= rquiredFragments;
#if AGG
using (var e = GEvent.GameEvent("item_change", gaSend: false))
{
e.AddContent("item_id", fragmentID)
.AddContent("state_info", "cost")
.AddContent("change_num", rquiredFragments);
}
#endif
isUp = true;
rodData.Add(id, 0);
}
}
if (isUp)
{
#if AGG
using (var e = GEvent.GameEvent("rod_upgrade"))
{
e.AddContent("rod_id", id)
.AddContent("rod_level", GetRodLevel(id))
.AddContent("resin_consume", 0)
.AddContent("rod_star", rodData[id])
.AddContent("rod_chips_consume", rquiredFragments);
}
#endif
PlayFabMgr.Instance.UpdateUserDataValue("RodData", JsonMapper.ToJson(rodData));
//鱼竿红点数据修改
CheckRodRedPointUp();
//合成鱼竿
CheckAllRodUpLevel();
}
}
}
#endregion
#region 耀
Dictionary<int, int> _honorlevel = new Dictionary<int, int>();
public int GetHonorLevel(int honorId)
{
if (_honorlevel.TryGetValue(honorId, out int level))
{
return level;
}
return 0;
}
public int GetHonorLevelAttribute(int quality, int starAdd = 0)
{
RodRodLevelPeak rodLevelPeak = _tables.TbRodRodLevelPeak.GetOrDefault(quality);
//星级对属性的加成 某几个属性加多少加到多少星
int level = GetHonorLevel(quality) + starAdd;
if (rodLevelPeak != null && level > 0)
{
List<int> peakBasicStats = rodLevelPeak.PeakBasicStats;
int value;
int count = peakBasicStats.Count;
if (level > count)
{
value = peakBasicStats[count - 1];
value += (level - count) * (peakBasicStats[count - 1] - peakBasicStats[count - 2]);
}
else
{
value = peakBasicStats[level - 1];
}
return value;
}
return 0;
}
public void HonorLevelUp(RodData rodData)
{
PlayerData playerData = GContext.container.Resolve<PlayerData>();
RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
int quality = rodData.Quality;
int fragmentID = rodAscend.FragmentID;
RodRodLevelPeak rodLevelPeak = _tables.TbRodRodLevelPeak.GetOrDefault(rodData.Quality);
if (rodLevelPeak == null)
{
Debug.LogError($"[FishingRodHonorlevelPanel]OnClickUpGray: No RodRodLevelPeak data found for Quality {quality}");
return;
}
int currentHonorLevel = GetHonorLevel(rodData.Quality);
if (currentHonorLevel >= rodLevelPeak.ItemConsume.Count)
{
currentHonorLevel = rodLevelPeak.ItemConsume.Count - 1;
}
int requiredItems = rodLevelPeak.ItemConsume[currentHonorLevel];
int fragmentItems = rodLevelPeak.FragmentConsume[currentHonorLevel];
if (playerData.pearl >= requiredItems && EnhanceConsumed(quality, fragmentID, fragmentItems))
{
playerData.SetPearl(playerData.pearl - requiredItems);
if (_honorlevel.ContainsKey(quality))
{
_honorlevel[quality]++;
}
else
{
_honorlevel[quality] = 1;
}
SaveHonorLevelData();
}
}
string HonorLevelDataKey = "HonorLevelData";
public void SaveHonorLevelData()
{
string value = Newtonsoft.Json.JsonConvert.SerializeObject(_honorlevel);
PlayFabMgr.Instance.UpdateUserDataValue(HonorLevelDataKey, value);
}
#endregion 耀
#region
//计算升级和强化后的属性
public List<int> GetRodAttribute(int id, bool isMax = false, int levelAdd = 0, int starAdd = 0)
{
RodData rodData = _tables.TbRodData.GetOrDefault(id);
RodAscend rodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
RodLevelup rodLevelup = _tables.TbRodLevelup.GetOrDefault(rodData.LevelupID);
int star = isMax ? rodAscend.MaxAscent : GetRodPiece(rodData.ID) + starAdd;
int level = isMax ? rodLevelup.MaxLevel - 1 : GetRodLevel(rodData.ID) + levelAdd;
List<int> list = new List<int>();
for (int i = 0; i < rodData.InitialBasicStats.Count; i++)
{
list.Add(0);
}
//星级对属性的加成 某几个属性加多少加到多少星
var AscentBasicStats = rodAscend.AscentBasicStat;
var AscentBasicStatList = rodAscend.AscentBasicStatList;
int index;
for (int i = 0; i < star; i++)
{
var AscentBasicStat = AscentBasicStats[i];
int count = AscentBasicStat.Count;
for (int j = 0; j < count; j++)
{
//InitialBasicStats 中第 AscentBasicStat[j] 个值加 i 星的值 累加
index = AscentBasicStat[j] - 1;
list[index] = AscentBasicStatList[i][j];
}
}
//等级对属性的加成 每个属性升到多少级
var levelupBasicStats = rodLevelup.LevelupBasicStats;
for (int j = 0; j < list.Count; j++)
{
list[j] += levelupBasicStats[j][level] + rodData.InitialBasicStats[j];
}
list[0] += GetHonorLevelAttribute(rodData.Quality);
return list;
}
#region
//获取鱼竿某一星级各个词条的等级
public int[] GetPerkLevel(int perkIDListCount, int star, List<int> DefaultPerk, List<int> PerkUnlockOrder)
{
int[] lv = new int[perkIDListCount];
for (int i = 0; i < DefaultPerk.Count; i++)
{
lv[DefaultPerk[i] - 1]++;
}
for (int i = 0; i < star; i++)
{
if (PerkUnlockOrder[i] <= perkIDListCount)
{
//每一星升级的是第几个特性
lv[PerkUnlockOrder[i] - 1]++;
}
}
return lv;
}
//获取鱼竿某一星级能解锁的词条ID及值
public Dictionary<int, string> GetRodDuelPerk(int id, int star)
{
RodData rodData = _tables.TbRodData.GetOrDefault(id);
RodAscend curRodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
int perkIDListCount = curRodAscend.PerkIDList.Count;
int[] lv = GetPerkLevel(perkIDListCount, star, curRodAscend.DefaultPerk, curRodAscend.PerkUnlockOrder);
Dictionary<int, string> RodPerkDic = new Dictionary<int, string>();
for (int i = 0; i < perkIDListCount; i++)
{
int level = lv[i];
if (level > 0)
{
var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(curRodAscend.PerkIDList[i]);
if (rodEngancePerk.DuelPerk)
{
List<string> PerkDataList = curRodAscend.PerkDataList[i];
if (level > PerkDataList.Count)
{
Debug.LogError($"GetRodPerk: rod {id} perkID {curRodAscend.PerkIDList[i]} level {level} is out of range (1 - {PerkDataList.Count})");
}
else
{
RodPerkDic[curRodAscend.PerkIDList[i]] = PerkDataList[level - 1];
}
}
}
}
return RodPerkDic;
}
//获取鱼竿某一星级能解锁的词条类型及值
public Dictionary<RodPerkType, string> GetRodPerk(int id, int star)
{
RodData rodData = _tables.TbRodData.GetOrDefault(id);
RodAscend curRodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
int perkIDListCount = curRodAscend.PerkIDList.Count;
int[] lv = GetPerkLevel(perkIDListCount, star, curRodAscend.DefaultPerk, curRodAscend.PerkUnlockOrder);
Dictionary<RodPerkType, string> RodPerkDic = new Dictionary<RodPerkType, string>();
for (int i = 0; i < curRodAscend.PerkDataList.Count; i++)
{
int level = lv[i];
if (level > 0)
{
var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(curRodAscend.PerkIDList[i]);
//第i条第lv[i]级 直接读数值
List<string> PerkDataList = curRodAscend.PerkDataList[i];
if (level > PerkDataList.Count)
{
Debug.LogError($"GetRodPerk: rod {id} perkID {curRodAscend.PerkIDList[i]} level {level} is out of range (1 - {PerkDataList.Count})");
}
else
{
RodPerkDic[rodEngancePerk.PerkType] = PerkDataList[level - 1];
}
}
}
return RodPerkDic;
}
//获取鱼竿某一星级能解锁的词条类型及等级
public Dictionary<RodPerkType, (int, int)> GetRodPerkLevel(int id, int star)
{
RodData rodData = _tables.TbRodData.GetOrDefault(id);
RodAscend curRodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
int perkIDListCount = curRodAscend.PerkIDList.Count;
int[] lv = GetPerkLevel(perkIDListCount, star, curRodAscend.DefaultPerk, curRodAscend.PerkUnlockOrder);
Dictionary<RodPerkType, (int, int)> RodPerkDic = new Dictionary<RodPerkType, (int, int)>();
for (int i = 0; i < perkIDListCount; i++)
{
int level = lv[i];
if (level > 0)
{
var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(curRodAscend.PerkIDList[i]);
RodPerkDic[rodEngancePerk.PerkType] = (curRodAscend.PerkIDList[i], level);
}
}
return RodPerkDic;
}
//解析词条的值
public float GetRodPerkValue(RodPerkType rodPerkType, Dictionary<RodPerkType, string> RodPerkDic)
{
if (RodPerkDic.TryGetValue(rodPerkType, out string perk))
{
if (perk.Contains('|'))
{
Debug.LogError($"GetRodPerkValue: rodPerkType {rodPerkType} perk {perk} cannot convert to float directly");
string[] values = perk.Split('|');
return float.Parse(values[0]);
}
return float.Parse(perk);
}
return 0;
}
public static string GetPerkDesc(RodPerkType rodPerkType, string des, string value)
{
var values = value.Split('|');
string str = LocalizationMgr.GetText(des);
try
{
switch (rodPerkType)
{
case RodPerkType.BattlePerk_AllToAtkSpeed:
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(values[0]).ToPercentageString(), values[1], float.Parse(values[2]).ToPercentageString());
break;
case RodPerkType.BattlePerk_ComboToExDmg:
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(values[0]).ToPercentageString(), values[1]);
break;
case RodPerkType.BattlePerk_FishSkillToAtkSpeed:
case RodPerkType.BattlePerk_FishEscapeToAtkSpeed:
str = LocalizationMgr.GetFormatTextValue(des, values[0], float.Parse(values[1]).ToPercentageString());
break;
case RodPerkType.BattlePerk_PiercingAddDamage:
str = LocalizationMgr.GetFormatTextValue(des, values[1], float.Parse(values[0]).ToPercentageString());
break;
case RodPerkType.BattlePerk_PiercingToCombo:
case RodPerkType.BattlePerk_TensionToCrit:
case RodPerkType.BattlePerk_PiercingCritDmg:
case RodPerkType.FactoryLabel_ScaleG:
case RodPerkType.FactoryLabel_Ilmarinen:
case RodPerkType.FactoryLabel_ChromaCast:
case RodPerkType.FactoryLabel_Victoria:
case RodPerkType.FactoryLabel_Sakura:
case RodPerkType.FactoryLabel_Titan:
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(values[0]).ToPercentageString(), float.Parse(values[1]).ToPercentageString());
break;
case RodPerkType.BattlePerk_ComboToCombo:
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(values[0]).ToPercentageString(), float.Parse(values[1]).ToPercentageString(), float.Parse(values[2]).ToPercentageString());
break;
case RodPerkType.NewPiercingZone:
break;
default:
if (!value.Contains('|'))
{
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(value).ToPercentageString());
}
else
{
str = LocalizationMgr.GetFormatTextValue(des, float.Parse(values[0]).ToPercentageString(), float.Parse(values[1]).ToPercentageString());
Debug.LogError($"GetPerkDesc error: no case for rodPerkType: {rodPerkType}, des: {des}, value: {value}");
}
break;
}
}
catch (Exception e)
{
Debug.LogError($"GetPerkDesc error: {e.Message}, rodPerkType: {rodPerkType}, des: {des}, value: {value}");
}
return str;
}
/// <summary>
/// 设置星级展示
/// </summary>
/// <param name="star"></param>
/// <param name="MaxAscent"></param>
/// <param name="star_empty_list"></param>
/// <param name="star_empty_image"></param>
/// <param name="starList"></param>
/// <param name="isUp"></param>
/// <returns></returns>
public static int SetRodStar(int star,
int MaxAscent,
List<GameObject> star_empty_list,
List<Image> star_empty_image,
List<StarItem> starList, bool isUp = false)
{
if (star > MaxAscent || star < 0)
{
Debug.LogError($"SetRodStar: star {star} is out of range (0 - {MaxAscent})");
star = MaxAscent;
}
int Quality = MaxAscent / 3;
if (MaxAscent > 15)
{
Debug.LogError("MaxAscent >> show == 15");
Quality = MaxAscent / 4;
}
if (Quality > 5)
{
Debug.LogError("MaxAscent >> show == 20");
Quality = 5;
}
int show = star;
int startIndex = 0;
if (star > Quality * 3)
{
show = star - Quality * 3;
startIndex = 3;
}
else if (star > Quality * 2)
{
show = star - Quality * 2;
startIndex = 2;
}
else if (star > Quality)
{
show = star - Quality;
startIndex = 1;
}
int index = startIndex;
for (int i = 0; i < starList.Count; i++)
{
starList[i].gameObject.SetActive(i < Quality);
star_empty_list[i].SetActive(i < Quality);
if (i < show)
{
starList[i].SetStar(startIndex + 1);
}
else if (i < Quality)
{
starList[i].SetStar(startIndex);
}
if (star_empty_image != null)
{
if (index > 0)
{
if (index > 3)
{
Debug.LogError("SetRodStar index > 3, index = " + index);
index = 3;
}
star_empty_image[i].gameObject.SetActive(true);
star_empty_image[i].sprite = starList[i].Star[index - 1].sprite;
}
else
{
star_empty_image[i].gameObject.SetActive(false);
}
}
}
if (isUp)
{
if (show > 0)
{
starList[show - 1].PlayAni();
if (star_empty_image != null)
{
index = startIndex;
if (index > 0)
{
star_empty_image[show - 1].gameObject.SetActive(true);
star_empty_image[show - 1].sprite = starList[show - 1].Star[index - 1].sprite;
}
else
{
star_empty_image[show - 1].gameObject.SetActive(false);
}
}
}
}
return Quality;
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 822fb88a18da500448d7abac6af61831
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,236 @@
using UnityEngine;
using asap.core;
using cfg;
using GameCore;
using System;
using System.Collections.Generic;
using UnityEngine.Assertions;
public class RodSelectionPackData
{
private GeneralEventPackData _data;
private readonly TbEventPackManager _epm = GContext.container.Resolve<Tables>().TbEventPackManager;
private readonly Tables _tables = GContext.container.Resolve<Tables>();
private readonly PlayerFishData _pfd = GContext.container.Resolve<PlayerFishData>();
private TbRodData _rodData = GContext.container.Resolve<Tables>().TbRodData;
private TbRodLevelup _rodLvlUp = GContext.container.Resolve<Tables>().TbRodLevelup;
private readonly TbRodAscend _rodAscend = GContext.container.Resolve<Tables>().TbRodAscend;
private readonly TbSpecialPack _spp = GContext.container.Resolve<Tables>().TbSpecialPack;
private readonly PlayerItemData _pid = GContext.container.Resolve<PlayerItemData>();
private readonly TbDrop _drop = GContext.container.Resolve<Tables>().TbDrop;
private readonly TbItem _item = GContext.container.Resolve<Tables>().TbItem;
public int CurrentEventID => _data.currentEventID;
public TimeSpan RemainingTime =>
DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime).EndTime) -
ZZTimeHelper.UtcNow();
public bool IsWithinEventTime
{
get
{
if (CurrentEventID == 0) return false;
return RemainingTime.TotalSeconds > 0;
}
}
public bool IsPackActivated
{
get
{
bool res = _tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID)
&& _epm.DataMap.ContainsKey(_data.redirectID)
&& _epm[_data.redirectID].PackType == 4
&& IsWithinEventTime
&& _data.purchaseCount < _epm[_data.redirectID].MaxCount;
/*Debug.Log(_tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID));
Debug.Log(_epm.DataMap.ContainsKey(_data.redirectID));
Debug.Log(_epm[_data.redirectID].PackType == 3);
Debug.Log(IsWithinEventTime);
Debug.Log(_data.isTriggered);
Debug.Log(_data.purchaseCount < _epm[_data.redirectID].MaxCount);*/
return res;
}
}
public int RedirectID => _data.redirectID;
private List<int> PackList => _epm[_data.redirectID].VIPPackList[0];
public List<int> PackRodList =>
_drop[_item[_drop[_epm[_data.redirectID].VIPPackList[0][0]].DropList.DropIDList[0]].RedirectID].DropList
.DropIDList;
public List<ItemData> RewardList
{
get
{
Assert.AreNotEqual(_data.rodID, -1, "Default rod not found. Maybe loot pool is empty.");
var rewards = _pid.GetItemDataByDropId(_spp[_data.packID].DropID[0]);
rewards[0] = new ItemData(_data.rodID, (int)rewards[0].count);
return rewards;
}
}
public int DropID => _spp[_data.packID].DropID[0];
public int PurchaseCount => _data.purchaseCount;
public int MaxPurchaseCount => _epm[RedirectID].MaxCount;
public int IAPID => _spp[_data.packID].IAPID[0];
public int RodID { get => _data.rodID; set => _data.rodID = value; }
public int FragmentID => _rodAscend[_item[RodID].RedirectID].FragmentID;
public void SaveData()
{
//Debug.LogError("Testing, data not saved for debug purpose.");
PlayFabMgr.Instance.UpdateUserDataValue("GeneralEventPackData",
Newtonsoft.Json.JsonConvert.SerializeObject(_data));
}
public void LoadData(GeneralEventPackData data)
{
_data = data;
if (IsPackActivated)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(_data.currentEventID,
UITypes.GiftRodSelectionPopupPanel, _epm[RedirectID].PackType, true);
}
}
public bool UpdateData(FishingEvent e)
{
if (_epm[_tables.TbFishingEvent[e.ID].RedirectID].PackType != 4)
{
Debug.LogError($"Fishing event ID {e.ID} is not a rod-select pack event");
return false;
}
if (_data.currentEventID != e.ID)
{
GeneralEventPackData oldData = _data;
int r = GetDefaultRodID(e);
_data = new GeneralEventPackData(
eventID: e.ID,
redirectID: e.RedirectID,
rodID: r,
lastPackIDBought: oldData.lastPackIDBought,
packID: GetPackID(oldData.lastPackIDBought, r, e),
purchaseCount: 0);
SaveData();
return true;
}
return false;
}
int star, fragCount, lvl;
private int GetDefaultRodID(FishingEvent e)
{
int defaultRodID, rid;
List<int> rodsInPack =
_drop[_item[_drop[_epm[e.RedirectID].VIPPackList[0][0]].DropList.DropIDList[0]].RedirectID].DropList.DropIDList;
defaultRodID = rodsInPack[0];
foreach (var rod in rodsInPack)
{
rid = _item[rod].RedirectID;
GetRodActualStats(rod, out star, out fragCount, out lvl);
//bool a = !_pfd.NotRod(rid);
//int b = _pfd.GetRodPiece(rid);
//int c = _rodAscend[rid].MaxAscent;
if (!_pfd.NotRod(rid) && star < _rodAscend[rid].MaxAscent)
{
defaultRodID = rod;
break;
}
}
GetRodActualStats(defaultRodID, out star, out fragCount, out lvl);
foreach (var rod in rodsInPack)
{
int currentStar, currentFragCount, currentLvl;
//if (defaultRodID == rodsInPack[0])
// defaultRodID = rod;
rid = _item[rod].RedirectID;
GetRodActualStats(rod, out currentStar, out currentFragCount, out currentLvl);
//Debug.Log($"{rod} debug!!!!!!!!!!!!!");
//Debug.Log(!_pfd.NotRod(rid));
//Debug.Log(_pfd.GetRodPiece(rid) < _rodAscend[rid].MaxAscent);
//Debug.Log(_pfd.GetRodPiece(rid) > _pfd.GetRodPiece(GetRodRedirectID(defaultRodID)));
if (!_pfd.NotRod(rid)//if player has this rod, its not fully enhanced and has higher stars than current
&& currentStar < _rodAscend[rid].MaxAscent
&& currentLvl > lvl)
{
defaultRodID = rod;
GetRodActualStats(defaultRodID, out star, out fragCount, out lvl);
}
}
return defaultRodID;
}
private int GetPackID(int lastPack, int defaultRodID, FishingEvent e = null)
{
List<int> packList;
if (e != null)
packList = _epm[e.RedirectID].VIPPackList[0];
else
packList = PackList;
GetRodActualStats(defaultRodID, out star, out fragCount, out lvl);
if (_pfd.NotRod(GetRodRedirectID(defaultRodID))
|| star >= _rodAscend[GetRodRedirectID(defaultRodID)].MaxAscent)
{
return packList[0] > lastPack - 1 ? packList[0] : lastPack - 1;
}
//int starLvl = _pfd.GetRodPiece(GetRodRedirectID(defaultRodID));
int fragmentID = _rodAscend[GetRodRedirectID(defaultRodID)].FragmentID;
//int fragCount = _pfd.GetRodPiece(fragmentID);
//int nextLvlStarPieces =
// _rodAscend[GetRodRedirectID(defaultRodID)].AscentTransformed[star + 1] - fragCount;
foreach (int packID in packList)
{
if (fragCount <= _spp[packID].EventItemRequire[0])
{
return packID > lastPack - 1 ? packID : lastPack - 1;
}
}
Debug.LogWarning($"Get Pack ID error. Rod {defaultRodID} is neither owned nor needing enhancement.");
return packList[0] > lastPack - 1 ? packList[0] : lastPack - 1;
}
public void AddPurchase()
{
_data.purchaseCount++;
_data.lastPackIDBought = _data.packID;
SaveData();
}
private int GetRodRedirectID(int rodItemID)
{
return _item[rodItemID].RedirectID;
}
/// <summary>
/// Get potential level and frags needed for next level of a rod.
/// </summary>
/// <param name="rodID">Rod id in Item table</param>
/// <param name="actualStar">The potential star after spending all the fragments</param>
/// <param name="actualNextStarFrag">Fragments needed for next level. Means nothing
/// if actualStar reaches maximum enhancement</param>
/// <param name="level">Get Actual rod level</param>
private void GetRodActualStats(int rodID, out int actualStar, out int actualNextStarFrag, out int level)
{
Assert.IsTrue(_item.DataMap.ContainsKey(rodID));
int rid = _item[rodID].RedirectID;
int star = _pfd.GetRodPiece(rid);
int lvl = _pfd.GetRodLevel(rid);
if (star >= _rodAscend[rid].MaxAscent)
{
actualStar = star;
actualNextStarFrag = 0;
level = lvl;
return;
}
int fragID = _rodAscend[rid].FragmentID;
int fragCount = _pfd.GetRodPiece(fragID);
int nextStarFrag = _rodAscend[rid].AscentTransformed[star + 1];
while (fragCount >= nextStarFrag)
{
fragCount -= nextStarFrag;
star++;
if (star >= _rodAscend[rid].MaxAscent)
{
//nextStarFrag = 0;
break;
}
nextStarFrag = _rodAscend[rid].AscentTransformed[star + 1];
}
actualStar = star;
actualNextStarFrag = nextStarFrag - fragCount;
level = lvl;
return;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8ce1cf0016ed5c046a2f502db697fd2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
using UnityEngine;
using System;
using cfg;
using asap.core;
using System.Collections.Generic;
using GameCore;
public class SelectionPackData
{
private GeneralEventPackData _data = new GeneralEventPackData();
private Tables _tables = GContext.container.Resolve<Tables>();
private TbSpecialPack _spp = GContext.container.Resolve<Tables>().TbSpecialPack;
private TbEventPackManager _epm = GContext.container.Resolve<Tables>().TbEventPackManager;
public TimeSpan RemainingTime
{
get => DateTime.Parse((_tables.TbFishingEvent[_data.currentEventID].TimeDefinition as LimitedTime)
.EndTime) - ZZTimeHelper.UtcNow();
}
public int CurrentEventID => _data.currentEventID;
public int PurchaseCount { get => _data.purchaseCount; }
public int MaxPurchaseCount { get => _tables.TbEventPackManager[_data.redirectID].MaxCount; }
public int IAPID { get => _spp[_epm[_data.redirectID].VIPPackList[_data.VIPLvlWhenEventActivate][0]].IAPID[0]; }
public bool IsPackActivated
{
get
{
return _tables.TbFishingEvent.DataMap.ContainsKey(_data.currentEventID)
&& _epm.DataMap.ContainsKey(_data.redirectID)
&& _epm[_data.redirectID].PackType == 5
&& RemainingTime.TotalSeconds > 0
&& _data.purchaseCount < _epm[_data.redirectID].MaxCount;
}
}
public int RedirectID { get => _data.redirectID; }
public List<int> Selections => _data.selections;
public int PackID { get => _epm[_data.redirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]; }
public List<int> DropIDList => _spp[_epm[_data.redirectID]
.VIPPackList[_data.VIPLvlWhenEventActivate][0]].DropID;
public bool IsFullySelected
{
get
{
for (int i = 0; i < _spp[PackID].DropID.Count; i++)
if (_data.selections[i] == -1) return false;
return true;
}
}
public List<ItemData> RewardSelected
{
get
{
if (!IsFullySelected)
return null;
List<ItemData> res = new List<ItemData>();
for (int i = 0; i < _spp[PackID].DropID.Count; i++)
{
DropPackageList d = _tables.TbDrop[_spp[PackID].DropID[i]].DropList;
res.Add(new ItemData(d.DropIDList[_data.selections[i]],
d.DropCountList[_data.selections[i]]));
}
return res;
}
}
public void LoadData(GeneralEventPackData data)
{
_data = data;
//Debug.LogError("Debug data process in action!");
//_data.purchaseCount = 0;
//_data.selections = new List<int> { -1, -1, -1, -1 };
if (IsPackActivated)
{
GContext.container.Resolve<IFaceUIService>().AddGiftFaceUI(_data.currentEventID,
UITypes.GiftSelectionPanel, _epm[RedirectID].PackType, true);
}
}
public void SaveData()
{
PlayFabMgr.Instance.UpdateUserDataValue("GeneralEventPackData",
Newtonsoft.Json.JsonConvert.SerializeObject(_data));
}
public bool UpdateData(FishingEvent e)
{
if (_epm[_tables.TbFishingEvent[e.ID].RedirectID].PackType != 5)
{
Debug.LogError($"Fishing event ID {e.ID} is not a rod-select pack event");
return false;
}
if (_data.currentEventID != e.ID)
{
//_spp[e.RedirectID].DropID
_data = new GeneralEventPackData(
eventID: e.ID,
redirectID: e.RedirectID,
purchaseCount: 0,
vip: GContext.container.Resolve<PlayerData>().PriceLv,
selections: new List<int>() { -1, -1, -1, -1 });
SaveData();
return true;
}
return false;
}
public void AddPurchase()
{
_data.purchaseCount++;
SaveData();
}
public void UpdateSelection(int slotIdx, int rewardIdx)
{
_data.selections[slotIdx] = rewardIdx;
SaveData();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cd9cd000a5513e459e35e42fb3c9d9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System;
public class TimedEventData : ITimedEventEntranceData
{
public int TicketCount { get; set; }
public DateTime ExpiryTime { get; set; }
public TimeSpan RemainingTime { get; set; }
public bool IsActive { get; set; }
}
public interface ITimedEventEntranceData
{
public int TicketCount { get; }
public DateTime ExpiryTime { get; }
public TimeSpan RemainingTime { get; }
public bool IsActive { get; }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c42662a136c6ab74f8783179cd37bd00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: