This commit is contained in:
2026-08-09 17:57:46 +08:00
parent 316a83a6ac
commit 983192ba29
323 changed files with 32641 additions and 14505 deletions
@@ -286,8 +286,8 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
// 鱼创建由服务端 OnFishSpawn 事件驱动,客户端 Update 不再出鱼
// (保留 isFrozen 字段供 FreezeAllFish/UnfreezeAllFish 使用)
// ⭐ 调试用:按 M 键手动出鱼(出 Inspector 配置的 debugSpawnFishNumber)
// 使用新版输入系统(Input System):Keyboard.current.wasPressedThisFrame
// ⭐ 调试用:按 M 键发送 HTTP 请求到服务端 AdminApi 出鱼
// roomId 从 gameData.currRoomData 读取,fishNumber 从 Inspector 配置读取
if (UnityEngine.InputSystem.Keyboard.current != null &&
UnityEngine.InputSystem.Keyboard.current.mKey.wasPressedThisFrame)
{
@@ -296,7 +296,13 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
Debug.LogWarning("[CreateFishManager] 未配置 debugSpawnFishNumber,请在 Inspector 设置鱼编号");
return;
}
ManualSpawn(debugSpawnFishNumber);
string roomId = GameManager.Instance.gameData?.currRoomData?.roomId;
if (string.IsNullOrEmpty(roomId))
{
Debug.LogWarning("[CreateFishManager] 当前未在房间中(roomId 为空),无法出鱼");
return;
}
APIManager.TempSpawnFish(roomId, debugSpawnFishNumber);
}
}
@@ -1241,14 +1247,19 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
yz_FishConfig_Line = null;
yz_FishConfig_Line_Dic1 = null;
if (fishRoot == null) return;
// ⭐ 收集要销毁的对象列表,避免遍历时字典被修改或对象已销毁导致 MissingReferenceException
var fishToDestroy = new List<GameObject>();
foreach (var item in fishDatas_hashCodekey)
{
if (item.Value.gameObject != null)
if (item.Value != null && item.Value.gameObject != null)
{
Destroy(item.Value.gameObject);
fishToDestroy.Add(item.Value.gameObject);
}
}
foreach (var go in fishToDestroy)
{
if (go != null) Destroy(go);
}
fishDatas_hashCodekey.Clear();
fishDatas_hashCodekey_Boss.Clear();
fishDatas_hashCodekey_Small.Clear();
@@ -1692,7 +1703,7 @@ public class CreateFishManager : MonoSingleton<CreateFishManager>
EffectPool.Instance.Get(
monster.effect_Die != null ? monster.effect_Die : dieFXPrefab,
monster.transform.position, Quaternion.identity, transform.parent);
int goldToAdd = killFish.gold; // 立即复制需要的数据
long goldToAdd = killFish.gold; // 立即复制需要的数据
string fishId = killFish.fishId; // 如果需要的话
Action<int> onScoreAdd = (audioID) =>
{