This commit is contained in:
2026-08-01 15:58:39 +08:00
parent effe4e9692
commit 0195686408
2 changed files with 15 additions and 16 deletions
@@ -2126,11 +2126,11 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
}
/// <summary>
/// 防止金币不足退出房间弹窗重复弹出。
/// 一旦弹出后保持 true,直到金币恢复到能发射最小炮倍才重置,
/// 确保同一时段内屏幕上最多只显示一个弹窗。
/// 金币不足退出房间弹窗的引用。
/// 弹窗存在期间不为 null(被 Destroy 后 Unity fake null,== null 为 true),
/// 用于确保屏幕上同一时间最多只显示一个弹窗,散射/自动开火也不会重复弹出。
/// </summary>
private bool _isGoldInsufficientPanelShown = false;
private TiShi _goldInsufficientPanel = null;
/// <summary>
/// 获取当前房间最小炮倍(paoBeiList 中的最小值)
@@ -2146,7 +2146,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
/// 金币不足则不切换攻击状态、不发送开炮请求,避免无效请求与服务端拒绝。
/// ⭐ 当金币不足以发射最小炮倍时,弹窗询问是否退出房间:
/// 确认 → 走退出房间逻辑;X号 → 关闭面板。本地判断,不发送开炮请求。
/// 弹窗期间通过 _isGoldInsufficientPanelShown 保证全局只显示一个。
/// 通过 _goldInsufficientPanel 引用检测保证全局只显示一个弹窗,
/// 弹窗未关闭前绝不重复弹出(散射/自动开火每帧检测也只弹一次)。
/// </summary>
private bool HasEnoughGoldToFire(bool isSanShe)
{
@@ -2155,27 +2156,23 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
long need = currSitData.consumeGoldNum * count;
if (currSitData.goldNum >= need)
{
// 金币够当前炮倍:重置弹窗标志
_isGoldInsufficientPanelShown = false;
// 金币够当前炮倍:可正常开火
return true;
}
// 金币不足当前炮倍:进一步判断是否连最小炮倍都发射不起
long minConsume = GetMinConsumeGold();
// 金币恢复到能发射最小炮倍 → 重置弹窗标志,允许下次不足时再次弹窗
if (minConsume <= 0 || currSitData.goldNum >= minConsume)
{
_isGoldInsufficientPanelShown = false;
// 金币够最小炮倍:玩家可降炮倍继续游戏,不弹窗
return false;
}
// ⭐ 金币不足以发射最小炮倍 → 弹窗询问是否退出房间
// _isGoldInsufficientPanelShown 保证只弹一个,不重复
if (!_isGoldInsufficientPanelShown)
// 关键:只有当前没有弹窗时才弹,避免散射/自动开火反复弹窗
if (_goldInsufficientPanel == null)
{
_isGoldInsufficientPanelShown = true;
UIManager.Instance.ShowTiShi(
_goldInsufficientPanel = UIManager.Instance.ShowTiShi(
"金币不足,是否退出房间?",
() => RequestLeaveRoom(),
true);