307 lines
11 KiB
C#
307 lines
11 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
public class DropAfterDrop
|
|
{
|
|
public string Mode;
|
|
public string Bone;
|
|
public string Fx;
|
|
public DropAfterDrop(string mode, string bone, string fx)
|
|
{
|
|
Mode = mode;
|
|
Bone = bone;
|
|
Fx = fx;
|
|
}
|
|
}
|
|
public class PlayNewItemFxEvent
|
|
{
|
|
public string fxName;
|
|
public string audioName;
|
|
public bool IsDarkness;
|
|
public float PerformanceDelay;
|
|
//==0=>start ==1=>stopFX ==2=>stopAudio or all
|
|
public int type;
|
|
}
|
|
public class CollectingData
|
|
{
|
|
ETDropAfterDrop etDropAfterDrop;
|
|
ETChangeMaterial eTChangeMaterial;
|
|
ETNewItem etNewItem;
|
|
ETKeepsake eTKeepsake;
|
|
ETDropByFish eTDropByFish;
|
|
|
|
private MapFishList mapFishList = null;
|
|
int addCollecting = 0;
|
|
int extraCashDrop = 0;
|
|
public FishingData fishingData;
|
|
//获取额外掉落id
|
|
int GetExtraDropID()
|
|
{
|
|
if (!fishingData.IsEventGameFish())
|
|
{
|
|
if (etDropAfterDrop != null)
|
|
{
|
|
//根据鱼的品质获取掉落id
|
|
int Quality = fishingData.fishItem.Quality - 1;
|
|
if (Quality >= etDropAfterDrop.ExtraDropList.Count)
|
|
{
|
|
Quality = etDropAfterDrop.ExtraDropList.Count - 1;
|
|
}
|
|
extraCashDrop = etDropAfterDrop.ExtraCashDropList[Quality];
|
|
return etDropAfterDrop.ExtraDropList[Quality];
|
|
}
|
|
else if (eTChangeMaterial != null)
|
|
{
|
|
extraCashDrop = eTChangeMaterial.ExtraCashDropList;
|
|
return eTChangeMaterial.ExtraDropList;
|
|
}
|
|
else if (mapFishList != null)
|
|
{
|
|
//根据鱼的编号获取掉落id
|
|
int index = mapFishList.FishIDList.IndexOf(fishingData.fishItem.RedirectID);
|
|
if (index != -1)
|
|
{
|
|
return mapFishList.DropIDList[index];
|
|
}
|
|
}
|
|
else if (eTKeepsake != null)
|
|
{
|
|
if (fishingData.NewIndex >= eTKeepsake.FishExtraDropList.Count)
|
|
{
|
|
Debug.LogError($"Keepsake FishExtraDropList == {eTKeepsake.FishExtraDropList.Count} Not Index {fishingData.NewIndex}");
|
|
return eTKeepsake.FishExtraDropList[0];
|
|
}
|
|
return eTKeepsake.FishExtraDropList[fishingData.NewIndex];
|
|
}
|
|
else if (etNewItem != null)
|
|
{
|
|
if (fishingData.NewIndex >= etNewItem.ExtraDropList.Count)
|
|
{
|
|
Debug.LogError($"NewItem ExtraDropList == {etNewItem.ExtraDropList.Count} Not Index {fishingData.NewIndex}");
|
|
|
|
return etNewItem.ExtraDropList[0];
|
|
}
|
|
return etNewItem.ExtraDropList[fishingData.NewIndex];
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
/// <summary>
|
|
/// 最后钓上来的鱼是否有装饰
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DropAfterDrop OnChangeFishData()
|
|
{
|
|
var collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
|
if (collectingTargetInit == null)
|
|
{
|
|
return null;
|
|
}
|
|
DropAfterDrop afterDrop = null;
|
|
if (etDropAfterDrop != null)
|
|
{
|
|
afterDrop = new DropAfterDrop(etDropAfterDrop.Mode, etDropAfterDrop.Bone, etDropAfterDrop.Fx);
|
|
}
|
|
else if (eTDropByFish != null)
|
|
{
|
|
afterDrop = new DropAfterDrop(eTDropByFish.Mode, eTDropByFish.Bone, eTDropByFish.Fx);
|
|
}
|
|
//有相关装饰活动,并且有代币掉落
|
|
return addCollecting > 0 ? afterDrop : null;
|
|
}
|
|
public ETChangeMaterial MaterialChange()
|
|
{
|
|
return addCollecting > 0 ? eTChangeMaterial : null;
|
|
}
|
|
|
|
public float StatsChange(int index)
|
|
{
|
|
if (addCollecting == 0)
|
|
{
|
|
return 1;
|
|
}
|
|
if (eTChangeMaterial != null)
|
|
{
|
|
int Quality = fishingData.curFishData.Quality - 1;
|
|
if (Quality >= eTChangeMaterial.StatsChange.Count)
|
|
{
|
|
Quality = eTChangeMaterial.StatsChange.Count - 1;
|
|
}
|
|
|
|
List<float> statsChange = eTChangeMaterial.StatsChange[Quality];
|
|
if (index < statsChange.Count)
|
|
{
|
|
return statsChange[index];
|
|
}
|
|
}
|
|
if (etDropAfterDrop != null && index < etDropAfterDrop.StatsChange.Count)
|
|
{
|
|
return etDropAfterDrop.StatsChange[index];
|
|
}
|
|
return 1;
|
|
}
|
|
public ETNewItem ETNewItemFx()
|
|
{
|
|
return etNewItem;
|
|
}
|
|
/// <summary>
|
|
/// 掉落活动代币数量
|
|
/// </summary>
|
|
public void ExtraDrop()
|
|
{
|
|
addCollecting = 0;
|
|
extraCashDrop = 0;
|
|
//鱼的品质或者编号
|
|
int dropID = GetExtraDropID();
|
|
if (dropID != 0)
|
|
{
|
|
List<ItemData> itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropIdAndType(dropID);
|
|
if (itemData is { Count: > 0 })
|
|
{
|
|
addCollecting = itemData[0].count;
|
|
}
|
|
}
|
|
}
|
|
public void Reset()
|
|
{
|
|
eTDropByFish = null;
|
|
etDropAfterDrop = null;
|
|
etNewItem = null;
|
|
eTKeepsake = null;
|
|
eTChangeMaterial = null;
|
|
|
|
mapFishList = null;
|
|
addCollecting = 0;
|
|
}
|
|
public void GetFishByWeight()
|
|
{
|
|
var collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
|
if (collectingTargetInit != null)
|
|
{
|
|
FishBuffTimeData fishBuffTimeData = GContext.container.Resolve<BuffDataCenter>().GetBuffData<CollectionTargetWeight>();
|
|
float BasicProb = collectingTargetInit.BasicProb;
|
|
CollectionTargetWeight collectionTargetWeight = null;
|
|
if (fishBuffTimeData != null)
|
|
{
|
|
FishBuff fishBuff = GContext.container.Resolve<Tables>().TbFishBuff.GetOrDefault(fishBuffTimeData.buffID);
|
|
collectionTargetWeight = fishBuff.BuffParam as CollectionTargetWeight;
|
|
BasicProb = collectionTargetWeight.NewTargetFishProb;
|
|
}
|
|
if (Random.Range(0, 1f) <= BasicProb + 0.0001f)
|
|
{
|
|
EventTargetExtraDrop eventTargetExtraDrop = GContext.container.Resolve<FishingEventData>().GetEventTargetExtraDrop();
|
|
if (eventTargetExtraDrop != null)
|
|
{
|
|
if (eventTargetExtraDrop is ETDropByFish)
|
|
{
|
|
var eTDropByFishCur = (ETDropByFish)eventTargetExtraDrop;
|
|
List<MapFishList> _mapFishList = eTDropByFishCur.ExtraDropList;
|
|
for (int i = 0; i < _mapFishList.Count; i++)
|
|
{
|
|
if (_mapFishList[i].MapID == fishingData.MapId)
|
|
{
|
|
eTDropByFish = eTDropByFishCur;
|
|
mapFishList = _mapFishList[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else if (eventTargetExtraDrop is ETDropAfterDrop)
|
|
{
|
|
etDropAfterDrop = (ETDropAfterDrop)eventTargetExtraDrop;
|
|
}
|
|
else if (eventTargetExtraDrop is ETChangeMaterial)
|
|
{
|
|
eTChangeMaterial = (ETChangeMaterial)eventTargetExtraDrop;
|
|
}
|
|
else if (eventTargetExtraDrop is ETNewItem)
|
|
{
|
|
fishingData.NewIndex = 0;
|
|
etNewItem = (ETNewItem)eventTargetExtraDrop;
|
|
fishingData.NewItemID = etNewItem.NewItemID[fishingData.NewIndex];
|
|
fishingData.fishItem = GContext.container.Resolve<Tables>().GetItemData(fishingData.NewItemID);
|
|
return;
|
|
}
|
|
else if (eventTargetExtraDrop is ETKeepsake)
|
|
{
|
|
eTKeepsake = (ETKeepsake)eventTargetExtraDrop;
|
|
var newItemIDList = new List<int>(eTKeepsake.FishIDList);
|
|
var newItemWeight = new List<float>(eTKeepsake.FishWeightList);
|
|
//===================信物相关===================
|
|
int curHour = ZZTimeHelper.UtcNow().UtcNowOffset().Hour;
|
|
if (curHour >= 16)
|
|
{
|
|
curHour = 16;
|
|
}
|
|
else if (curHour >= 8)
|
|
{
|
|
curHour = 8;
|
|
}
|
|
else
|
|
{
|
|
curHour = 0;
|
|
}
|
|
int fishCount = GContext.container.Resolve<PlayerShopData>().GetShopPackBuyCount("CTFishID0" + curHour);
|
|
|
|
//每日信物权重
|
|
var keepsakeWeight = eTKeepsake.KeepsakeWeight;
|
|
if (fishCount < keepsakeWeight.Count)
|
|
{
|
|
newItemWeight[0] = keepsakeWeight[fishCount];
|
|
}
|
|
//buff重置鱼和信物权重
|
|
if (collectionTargetWeight != null)
|
|
{
|
|
newItemWeight = new List<float>(collectionTargetWeight.NewWeightList);
|
|
}
|
|
//===================信物相关===================
|
|
NewItemIDListFun(newItemIDList, newItemWeight);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void NewItemIDListFun(List<int> newItemIDList, List<float> newItemWeight)
|
|
{
|
|
fishingData.NewIndex = 0;
|
|
fishingData.NewItemID = newItemIDList[0];
|
|
float allWeight = newItemWeight.Sum();
|
|
//特殊物品概率特殊调整 Todo
|
|
float randomWeight = Random.Range(0.001f, allWeight);
|
|
float sum = 0;
|
|
for (int i = 0; i < newItemIDList.Count; i++)
|
|
{
|
|
sum += newItemWeight[i];
|
|
if (randomWeight < sum)
|
|
{
|
|
fishingData.NewIndex = i;
|
|
fishingData.NewItemID = newItemIDList[fishingData.NewIndex];
|
|
fishingData.fishItem = GContext.container.Resolve<Tables>().GetItemData(fishingData.NewItemID);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 额外掉落代币数量
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public int GetAddCollecting()
|
|
{
|
|
return addCollecting;
|
|
}
|
|
|
|
public float ExtraCashDrop()
|
|
{
|
|
if (addCollecting > 0 && extraCashDrop > 0)
|
|
{
|
|
DropPackageList dropPackageList = GContext.container.Resolve<Tables>().TbDrop[extraCashDrop].DropList;
|
|
return dropPackageList.DropCountList[0];
|
|
}
|
|
return 0;
|
|
}
|
|
}
|