This commit is contained in:
2026-06-20 15:00:15 +08:00
parent 5bf4e31ab3
commit a800620fee
58 changed files with 2997 additions and 619 deletions
@@ -102,7 +102,6 @@ using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using static UnityEditor.Progress;
public class GameMainPanel_FishBase : GameMainPanel_Base
{
@@ -772,11 +771,17 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
screenPos, null, out Vector2 localPos);
Vector2 dir = localPos - sit.tra_CurrTurret.GetComponent<RectTransform>().anchoredPosition;
// ⭐ 鱼太近时 dir 接近零向量,Atan2 会不稳定导致原地转圈 → 跳过
const float minDistance = 5f;
if (dir.sqrMagnitude < minDistance * minDistance) return;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f;
if (sit.IsFlipped) angle = (angle + 180f) % 360f;
sit.SetRotation(angle);
SyncRotate(angle);
}
private void HandleAutoRotate()
@@ -899,6 +904,13 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
clickTime += Time.deltaTime;
if (clickTime < attackTime) return;
// ⭐ 子弹上限校验(先于扣费和状态切换)
if (IsBulletLimitReached(currSitData.user))
{
clickTime = 0; // 重置计时,下次再试
return;
}
clickTime = 0;
float angle = currSitData.currentAngle;
@@ -1021,6 +1033,13 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
autoFireTimer += Time.deltaTime;
if (autoFireTimer < attackTime) return;
// ⭐ 子弹上限校验(先于状态切换和扣费)
if (IsBulletLimitReached(currSitData.user))
{
autoFireTimer = 0f; // 重置计时,下次再试
return;
}
autoFireTimer = 0f;
float angle = currSitData.currentAngle;
@@ -1364,6 +1383,27 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
#endregion
#region BulletModule(子弹系统)
public int sitBulletMaxCount = 80;
/// <summary>
/// 检查指定用户是否已达50发子弹上限
/// </summary>
private bool IsBulletLimitReached(string userId)
{
if (bulletParent == null) return false;
int count = 0;
foreach (Transform child in bulletParent.transform)
{
if (child.TryGetComponent<BullitMove>(out var bm) && bm.userid == userId)
count++;
}
if (count >= sitBulletMaxCount)
{
UIManager.Instance.ShowBoardError("子弹已达上限");
return true;
}
return false;
}
private BullitMove CreateBullet(SitPosData sit, Vector2 pos, float angle, bool isDouble, bool isLock, string id,
MonsterContral lockTarget = null, Transform lockHitPos = null)
{
@@ -1376,6 +1416,19 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
GameObject prefab = isDouble ? sit.currentTurret.bulletPrefab_Two : sit.currentTurret.bulletPrefab;
// ⭐ 每座位最多50发子弹(先校验,不扣钱)
int activeBullets = 0;
foreach (Transform child in bulletParent.transform)
{
if (child.TryGetComponent<BullitMove>(out var bm) && bm.userid == sit.user)
activeBullets++;
}
if (activeBullets >= 50)
{
UIManager.Instance.ShowBoardError($"[子弹上限] 座位{sit.posID}已达50发上限");
return null;
}
if (!sit.ConsumeGold(isDouble ? 2 : 1))
return null;