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; //根据鱼的品质获取掉落id int Quality = fishingData.fishItem.Quality - 1; if (Quality >= eTChangeMaterial.ExtraDropList.Count) { Quality = eTChangeMaterial.ExtraDropList.Count - 1; } return eTChangeMaterial.ExtraDropList[Quality]; } 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; } /// /// 最后钓上来的鱼是否有装饰 /// /// public DropAfterDrop OnChangeFishData() { var collectingTargetInit = GContext.container.Resolve().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); } else if (eTChangeMaterial != null) { afterDrop = new DropAfterDrop(eTChangeMaterial.Mode, eTChangeMaterial.Bone, "None"); } //有相关装饰活动,并且有代币掉落 return addCollecting > 0 ? afterDrop : null; } public ETChangeMaterial MaterialChange() { return addCollecting > 0 ? eTChangeMaterial : null; } public float StatsChange(int index) { if (addCollecting == 0) { return 1; } List> statsChanges = null; if (eTChangeMaterial != null) { statsChanges = eTChangeMaterial.StatsChange; } else if (etDropAfterDrop != null) { statsChanges = etDropAfterDrop.StatsChange; } if (statsChanges != null) { int Quality = fishingData.curFishData.Quality - 1; if (Quality >= statsChanges.Count) { Quality = statsChanges.Count - 1; } List statsChange = statsChanges[Quality]; if (index < statsChange.Count) { return statsChange[index]; } } return 1; } public ETNewItem ETNewItemFx() { return etNewItem; } /// /// 掉落活动代币数量 /// public void ExtraDrop(bool EventtargetTrigger = false) { addCollecting = 0; extraCashDrop = 0; //鱼的品质或者编号 int dropID = GetExtraDropID(); if (dropID != 0) { Drop drop = GContext.container.Resolve().TbDrop.GetOrDefault(dropID); var dropList = drop.DropList; var itemData = new ItemData(); if (!EventtargetTrigger) { if (drop.Type == DropType.Probability) { if (Mathf.Ceil(dropList.DropProbList[0] * 100) >= Random.Range(0, 100) - 0.00001f) { EventtargetTrigger = true; } } else { EventtargetTrigger = true; } } if (EventtargetTrigger) { itemData.id = dropList.DropIDList[0]; itemData.count = dropList.DropCountList[0]; GContext.container.Resolve().ItemTransition(itemData); if (itemData.count > 0) { addCollecting = itemData.count; } } //List itemData = GContext.container.Resolve().GetItemDataByDropIdAndType(dropID); } } public void Reset() { eTDropByFish = null; etDropAfterDrop = null; etNewItem = null; eTKeepsake = null; eTChangeMaterial = null; mapFishList = null; addCollecting = 0; } public void GetFishByWeight(int EventtargetTriggerParam = -1) { FishingEventData fishingEventData = GContext.container.Resolve(); var collectingTargetInit = fishingEventData.collectingTargetInit; if (collectingTargetInit != null && fishingEventData.collectingTargetResoure) { FishBuffTimeData fishBuffTimeData = GContext.container.Resolve().GetBuffData(); float BasicProb = collectingTargetInit.BasicProb; CollectionTargetWeight collectionTargetWeight = null; if (fishBuffTimeData != null) { FishBuff fishBuff = GContext.container.Resolve().TbFishBuff.GetOrDefault(fishBuffTimeData.buffID); collectionTargetWeight = fishBuff.BuffParam as CollectionTargetWeight; BasicProb = collectionTargetWeight.NewTargetFishProb; } if (EventtargetTriggerParam >= 0 || Random.Range(0, 1f) <= BasicProb + 0.0001f) { EventTargetExtraDrop eventTargetExtraDrop = fishingEventData.GetEventTargetExtraDrop(); if (eventTargetExtraDrop != null) { if (eventTargetExtraDrop is ETDropByFish) { var eTDropByFishCur = (ETDropByFish)eventTargetExtraDrop; List _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().GetItemData(fishingData.NewItemID); return; } else if (eventTargetExtraDrop is ETKeepsake) { eTKeepsake = (ETKeepsake)eventTargetExtraDrop; var newItemIDList = new List(eTKeepsake.FishIDList); var newItemWeight = new List(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().GetShopPackBuyCount("CTFishID0" + curHour); //每日信物权重 var keepsakeWeight = eTKeepsake.KeepsakeWeight; if (fishCount < keepsakeWeight.Count) { newItemWeight[0] = keepsakeWeight[fishCount]; } //buff重置鱼和信物权重 if (collectionTargetWeight != null) { newItemWeight = new List(collectionTargetWeight.NewWeightList); } //===================信物相关=================== if (EventtargetTriggerParam < 0) { NewItemIDListFun(newItemIDList, newItemWeight); } else { fishingData.NewIndex = EventtargetTriggerParam; fishingData.NewItemID = newItemIDList[fishingData.NewIndex]; fishingData.fishItem = GContext.container.Resolve().GetItemData(fishingData.NewItemID); } } } } } } void NewItemIDListFun(List newItemIDList, List 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().GetItemData(fishingData.NewItemID); return; } } } /// /// 额外掉落代币数量 /// /// public int GetAddCollecting() { return addCollecting; } public float ExtraCashDrop() { if (addCollecting > 0 && extraCashDrop > 0) { DropPackageList dropPackageList = GContext.container.Resolve().TbDrop[extraCashDrop].DropList; return dropPackageList.DropCountList[0]; } return 0; } }