Files
ft/Client/Assets/Scripts/DataCenter/FishingEvent_PVPData.cs
2026-06-29 21:18:33 +08:00

280 lines
10 KiB
C#

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 curSolomain;
public int PVPToken { private set; get; }//pvp商店代币
public void SetRankTierChange(EventSolomain beforeSolomain, EventSolomain eventSolomain)
{
rankTierChangeState = beforeSolomain.RankTier > eventSolomain.RankTier ? 1 : 2;
this.curSolomain = beforeSolomain;
}
public async void ShowRankTierChange()
{
if (rankTierChangeState > 0 && curSolomain != null)
{
GameObject go = await UIManager.Instance.ShowUI(UITypes.EventFishingDuelRankChangePopupPanel);
EventFishingDuelRankChangePopupPanel changePopupPanel = go.GetComponent<EventFishingDuelRankChangePopupPanel>();
changePopupPanel.SetRank(rankTierChangeState == 1, curSolomain);
rankTierChangeState = 0;
curSolomain = 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.inflation = GContext.container.Resolve<PlayerData>().InflationRate;
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
}
}