1
This commit is contained in:
@@ -983,6 +983,9 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
|
||||
if (!isChangingTurret)
|
||||
{
|
||||
// ⭐ 本地金币校验:没钱不切换 Attack 状态,也不广播,避免无效请求
|
||||
if (!HasEnoughGoldToFire(toggle_Three.isOn))
|
||||
return;
|
||||
// 按下即进入 Attack:短按→射击,长按超过阈值后切回 Idle 弹扇形
|
||||
currSitData.ChangeState(TurretState.Attack);
|
||||
SyncTurretState(TurretState.Attack);
|
||||
@@ -1353,6 +1356,11 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
clickTime += Time.deltaTime;
|
||||
if (clickTime < attackTime) return;
|
||||
|
||||
// ⭐ 本地金币校验:没钱直接返回,不发送开炮请求
|
||||
// clickTime 保持满,金币恢复后立即开火
|
||||
if (!HasEnoughGoldToFire(toggle_Three.isOn))
|
||||
return;
|
||||
|
||||
// ⭐ 子弹上限校验(先于扣费和状态切换)
|
||||
if (IsBulletLimitReached(currSitData.user))
|
||||
{
|
||||
@@ -1510,6 +1518,11 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
autoFireTimer += Time.deltaTime;
|
||||
if (autoFireTimer < attackTime) return;
|
||||
|
||||
// ⭐ 本地金币校验:没钱直接返回,不切换攻击状态、不发送开炮请求
|
||||
// autoFireTimer 保持满,金币恢复后立即开火
|
||||
if (!HasEnoughGoldToFire(toggle_Three.isOn))
|
||||
return;
|
||||
|
||||
// ⭐ 子弹上限校验(先于状态切换和扣费)
|
||||
if (IsBulletLimitReached(currSitData.user))
|
||||
{
|
||||
@@ -2112,6 +2125,55 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 防止金币不足退出房间弹窗重复弹出(金币恢复后自动重置)
|
||||
/// </summary>
|
||||
private bool _isGoldInsufficientPanelShown = false;
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前房间最小炮倍(paoBeiList 中的最小值)
|
||||
/// </summary>
|
||||
private long GetMinConsumeGold()
|
||||
{
|
||||
if (paoBeiList == null || paoBeiList.Count == 0) return 0;
|
||||
return paoBeiList.Min();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开炮前本地金币校验:三射按 3 发,否则按 1 发计算所需金币。
|
||||
/// 金币不足则不切换攻击状态、不发送开炮请求,避免无效请求与服务端拒绝。
|
||||
/// ⭐ 当金币不足以发射最小炮倍时,弹窗询问是否退出房间:
|
||||
/// 确认 → 走退出房间逻辑;X号 → 关闭面板。本地判断,不发送开炮请求。
|
||||
/// </summary>
|
||||
private bool HasEnoughGoldToFire(bool isSanShe)
|
||||
{
|
||||
if (currSitData == null) return false;
|
||||
int count = isSanShe ? 3 : 1;
|
||||
long need = currSitData.consumeGoldNum * count;
|
||||
if (currSitData.goldNum >= need)
|
||||
{
|
||||
// 金币足够:重置弹窗标志,允许下次不足时再次弹窗
|
||||
_isGoldInsufficientPanelShown = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 金币不足当前炮倍:进一步判断是否连最小炮倍都发射不起
|
||||
long minConsume = GetMinConsumeGold();
|
||||
if (minConsume > 0 && currSitData.goldNum < minConsume)
|
||||
{
|
||||
// ⭐ 金币不足以发射最小炮倍 → 弹窗询问是否退出房间(防重复)
|
||||
if (!_isGoldInsufficientPanelShown)
|
||||
{
|
||||
_isGoldInsufficientPanelShown = true;
|
||||
UIManager.Instance.ShowTiShi(
|
||||
"金币不足,是否退出房间?",
|
||||
() => RequestLeaveRoom(),
|
||||
true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private BullitMove CreateBullet(SitPosData sit, Vector2 pos, float angle, bool isDouble, bool isLock, string id,
|
||||
MonsterContral lockTarget = null, Transform lockHitPos = null, long fireConsumeGold = 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user