1
This commit is contained in:
@@ -735,73 +735,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 结束游戏退出房间
|
||||
/// <summary>退出房间:关闭生成系统。</summary>
|
||||
public void ExitRoom()
|
||||
{
|
||||
CloseSpawnSystem();
|
||||
}
|
||||
/// <summary>
|
||||
/// 关闭生成系统:清理列表,销毁场景内所有鱼对象。
|
||||
/// </summary>
|
||||
public async void CloseSpawnSystem()
|
||||
{
|
||||
|
||||
//await Task.Delay(2000);
|
||||
spawnList = null;
|
||||
spawnDic = null;
|
||||
yz_FishConfig_Line_Dic = null;
|
||||
yz_FishConfig_Line = null;
|
||||
yz_FishConfig_Line_Dic1 = null;
|
||||
if (fishRoot == null) return;
|
||||
foreach (var item in fishDatas_hashCodekey)
|
||||
{
|
||||
if (item.Value.gameObject != null)
|
||||
{
|
||||
Destroy(item.Value.gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
fishDatas_hashCodekey.Clear();
|
||||
fishDatas_hashCodekey_Boss.Clear();
|
||||
fishDatas_hashCodekey_Small.Clear();
|
||||
foreach (Transform item in fishRoot)
|
||||
{
|
||||
Destroy(item.gameObject);
|
||||
|
||||
}
|
||||
//for (int i = fishDatas_hashCodekey.childCount - 1; i >= 0; i--)
|
||||
// Destroy(fishRoot.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
/// <summary>释放 NativeArray(避免 Unity 内存泄漏警告)。</summary>
|
||||
private void DisposeNativeArrays()
|
||||
{
|
||||
if (timers.IsCreated) timers.Dispose();
|
||||
if (frequencies.IsCreated) frequencies.Dispose();
|
||||
if (shouldSpawn.IsCreated) shouldSpawn.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 收到服务器 SyncGameData 创鱼事件,反序列化并执行实例化。
|
||||
///// </summary>
|
||||
//public void CreateFish(SyncGameData syncGameData)
|
||||
//{
|
||||
// var rotateData = JsonConvert.DeserializeObject<FrameData_CreateFish>(
|
||||
// syncGameData.frameData.ToString());
|
||||
// SpawnFishMainThread(rotateData, syncGameData.time);
|
||||
//}
|
||||
#region 创建鱼
|
||||
/// <summary>
|
||||
/// AI优化过的
|
||||
/// </summary>
|
||||
@@ -812,8 +746,6 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
if (rotateData != null)
|
||||
SpawnFishMainThread(rotateData, syncGameData.time);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 主线程实例化鱼对象(单体鱼 / 鱼阵分发)。
|
||||
/// </summary>
|
||||
@@ -836,11 +768,11 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
SpawnFishArray(createFishData, cfg, time);
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// 单体鱼生成
|
||||
// ================================================================
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成一条普通/Boss/黄金鱼并初始化路径。
|
||||
/// </summary>
|
||||
@@ -872,35 +804,12 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Debug.LogError(createFishData.fishNumber);
|
||||
Debug.LogError(ex.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>将鱼实例注册到全局字典及对应分类字典。</summary>
|
||||
private void RegisterFishInstance(MonsterContral mc, int fishTypeId)
|
||||
{
|
||||
fishDatas_hashCodekey[mc.guid] = mc;
|
||||
|
||||
switch (fishTypeId)
|
||||
{
|
||||
case 1: // 普通鱼
|
||||
case 3: // 特殊鱼 / 黄金鱼
|
||||
fishDatas_hashCodekey_Small[mc.guid] = mc;
|
||||
break;
|
||||
case 2: // Boss
|
||||
case 4:
|
||||
case 5:
|
||||
fishDatas_hashCodekey_Boss[mc.guid] = mc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// 鱼阵生成(按 arrayNumber 前缀分发到对应阵型协程/方法)
|
||||
// ================================================================
|
||||
@@ -1082,6 +991,78 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>将鱼实例注册到全局字典及对应分类字典。</summary>
|
||||
private void RegisterFishInstance(MonsterContral mc, int fishTypeId)
|
||||
{
|
||||
fishDatas_hashCodekey[mc.guid] = mc;
|
||||
|
||||
switch (fishTypeId)
|
||||
{
|
||||
case 1: // 普通鱼
|
||||
case 3: // 特殊鱼 / 黄金鱼
|
||||
fishDatas_hashCodekey_Small[mc.guid] = mc;
|
||||
break;
|
||||
case 2: // Boss
|
||||
case 4:
|
||||
case 5:
|
||||
fishDatas_hashCodekey_Boss[mc.guid] = mc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 结束游戏退出房间
|
||||
/// <summary>退出房间:关闭生成系统。</summary>
|
||||
public void ExitRoom()
|
||||
{
|
||||
CloseSpawnSystem();
|
||||
}
|
||||
/// <summary>
|
||||
/// 关闭生成系统:清理列表,销毁场景内所有鱼对象。
|
||||
/// </summary>
|
||||
public async void CloseSpawnSystem()
|
||||
{
|
||||
|
||||
//await Task.Delay(2000);
|
||||
spawnList = null;
|
||||
spawnDic = null;
|
||||
yz_FishConfig_Line_Dic = null;
|
||||
yz_FishConfig_Line = null;
|
||||
yz_FishConfig_Line_Dic1 = null;
|
||||
if (fishRoot == null) return;
|
||||
foreach (var item in fishDatas_hashCodekey)
|
||||
{
|
||||
if (item.Value.gameObject != null)
|
||||
{
|
||||
Destroy(item.Value.gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
fishDatas_hashCodekey.Clear();
|
||||
fishDatas_hashCodekey_Boss.Clear();
|
||||
fishDatas_hashCodekey_Small.Clear();
|
||||
foreach (Transform item in fishRoot)
|
||||
{
|
||||
Destroy(item.gameObject);
|
||||
|
||||
}
|
||||
//for (int i = fishDatas_hashCodekey.childCount - 1; i >= 0; i--)
|
||||
// Destroy(fishRoot.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
/// <summary>释放 NativeArray(避免 Unity 内存泄漏警告)。</summary>
|
||||
private void DisposeNativeArrays()
|
||||
{
|
||||
if (timers.IsCreated) timers.Dispose();
|
||||
if (frequencies.IsCreated) frequencies.Dispose();
|
||||
if (shouldSpawn.IsCreated) shouldSpawn.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Tool
|
||||
// ================================================================
|
||||
// 随机工具方法
|
||||
// ================================================================
|
||||
@@ -1131,11 +1112,47 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
#region 杀鱼
|
||||
// ================================================================
|
||||
// 杀鱼接口
|
||||
// ================================================================
|
||||
|
||||
/// <summary>
|
||||
/// 批量杀死多条鱼(带特效 + 不足数量用纯金币补齐)。
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
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>
|
||||
/// 随机选取 count 条小鱼/黄金鱼,通知服务器同步死亡,并返回 guid 列表。
|
||||
/// </summary>
|
||||
@@ -1211,7 +1228,6 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
}
|
||||
fishDatas_hashCodekey.Remove(fishId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按 ID 杀死一条鱼(带特效 + 金币飞出动画)。
|
||||
/// </summary>
|
||||
@@ -1284,41 +1300,11 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
endTra.parent = coinScript.transform;
|
||||
|
||||
coinScript.endPoint = endTra;
|
||||
coinScript.isBoss = true;
|
||||
coinScript.isBoss = true;
|
||||
coinScript.SetCoinCount(coinNum.Amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量杀死多条鱼(带特效 + 不足数量用纯金币补齐)。
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
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 杀鱼通知,处理金币加分、特效、音效。
|
||||
@@ -1353,7 +1339,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
sit.goldNum += killFish.gold;
|
||||
sit.tMP_GoldNum.text = sit.goldNum.ToString();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1378,13 +1364,13 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
monster.transform.position,
|
||||
UIManager.Instance.uiRoot.GetComponent<Canvas>());
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
award.transform.position = monster.transform.position;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var coinScript = award.GetComponent<BJBase>();
|
||||
foreach (var item in currGameType.list_Sits)
|
||||
@@ -1423,6 +1409,22 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
|
||||
monster.monsterData.fishTypeConfig.fishNumber, 1000);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ================================================================
|
||||
// 工具:获取当前面板座位列表
|
||||
|
||||
Reference in New Issue
Block a user