1
This commit is contained in:
@@ -27,6 +27,7 @@ using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
@@ -271,17 +272,21 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
|
||||
if (!fishTypeConfig.TryGetValue(FishTypeEnum.Boss鱼, out var bossList) || bossList.Count == 0)
|
||||
return;
|
||||
//foreach (var item in bossList)
|
||||
//{
|
||||
// if (item.fishNumber == 13027.ToString())
|
||||
// {
|
||||
// item.isCreate = 2;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
StartCoroutine(buchongfu(bossList, bossCount));
|
||||
|
||||
|
||||
foreach (var item in bossList)
|
||||
{
|
||||
//if (item.fishNumber == 11027.ToString())
|
||||
//{
|
||||
// item.isCreate = 2;
|
||||
//}
|
||||
//if (item.fishNumber == 11030.ToString())
|
||||
//{
|
||||
// item.isCreate = 2;
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1181,15 +1186,72 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
monster.DieFish();
|
||||
fishDatas_hashCodekey.Remove(fishId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 不依赖鱼,只在屏幕内随机一个位置生成金币特效,然后飞回指定点。
|
||||
/// </summary>
|
||||
private void SpawnRandomCoinFX(RedPacketRecord coinNum, Vector3 targetWorldPos)
|
||||
{
|
||||
// 1. 随机一个屏幕坐标
|
||||
Vector2 screenPos = new Vector2(
|
||||
UnityEngine.Random.Range(0f, Screen.width),
|
||||
UnityEngine.Random.Range(0f, Screen.height));
|
||||
|
||||
// 2. 屏幕坐标 → Canvas 坐标(跟你原来金币飞行逻辑保持一致)
|
||||
Vector2 canvasPos = CoordinateTransformation.ScreenPoint_ToCanvas(
|
||||
screenPos,
|
||||
UIManager.Instance.uiRoot.GetComponent<Canvas>());
|
||||
|
||||
// 3. 实例化金币特效(沿用你原来的 award 逻辑)
|
||||
var award = Instantiate(
|
||||
dieFXPrefabAward, // 或者用某个专门的“掉金币” prefab
|
||||
currGameType.subPanelParent.parent);
|
||||
|
||||
var rect = award.GetComponent<RectTransform>();
|
||||
rect.anchoredPosition = canvasPos;
|
||||
|
||||
// 4. 设置 CoinScript 的终点为 targetWorldPos
|
||||
var coinScript = award.GetComponent<CoinScript>();
|
||||
var endTra = new GameObject("CoinEndPoint_Random").transform;
|
||||
endTra.position = targetWorldPos;
|
||||
endTra.parent = coinScript.transform;
|
||||
|
||||
coinScript.endPoint = endTra;
|
||||
coinScript.isBoss = true;
|
||||
coinScript.SetCoinCount(coinNum.Amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量杀死多条鱼(带特效)。
|
||||
/// 批量杀死多条鱼(带特效 + 不足数量用纯金币补齐)。
|
||||
/// </summary>
|
||||
public void Id_DieListFish_FX(List<string> ids, List<RedPacketRecord> coinNum, Vector3 v3Point)
|
||||
/// <param name="guids">实际场上能找到的鱼 guid 列表(可能少于 count)</param>
|
||||
/// <param name="coinNum">红包拆分后的每份金额,长度应 >= count</param>
|
||||
/// <param name="v3Point">金币最终飞回的世界坐标(一般是炮台位置)</param>
|
||||
/// <param name="count">理论上要“死”的总数量(鱼 + 纯金币)</param>
|
||||
public void Id_DieListFish_FX(List<string> guids, List<RedPacketRecord> coinNum, Vector3 v3Point, int count)
|
||||
{
|
||||
for (int i = 0; i < ids.Count; i++)
|
||||
Id_DieFish_FX(ids[i], coinNum[i], v3Point);
|
||||
if (coinNum == null || coinNum.Count == 0) return;
|
||||
|
||||
// 1. 先处理“真的有鱼”的部分
|
||||
int realCount = Mathf.Min(guids.Count, coinNum.Count, count);
|
||||
for (int i = 0; i < realCount; i++)
|
||||
{
|
||||
// 用你原来的单条逻辑,不动
|
||||
Id_DieFish_FX(guids[i], coinNum[i], v3Point);
|
||||
}
|
||||
|
||||
// 2. 不足的部分,用“屏幕随机位置的金币特效”补齐
|
||||
int needExtra = count - realCount;
|
||||
if (needExtra <= 0) return;
|
||||
|
||||
// 防御:最多用 coinNum 里剩下的
|
||||
int maxExtra = Mathf.Min(needExtra, coinNum.Count - realCount);
|
||||
for (int i = 0; i < maxExtra; i++)
|
||||
{
|
||||
var red = coinNum[realCount + i];
|
||||
SpawnRandomCoinFX(red, v3Point);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收到服务器 WebSocket 杀鱼通知,处理金币加分、特效、音效。
|
||||
/// </summary>
|
||||
@@ -1279,7 +1341,6 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
monster.monsterData.fishTypeConfig.fishNumber, 1000);
|
||||
|
||||
monster.DieFish(killFish);
|
||||
fishDatas_hashCodekey.Remove(killFish.fishId);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
||||
Reference in New Issue
Block a user