This commit is contained in:
2026-09-05 15:02:49 +08:00
parent fdaf4e2fa3
commit 54e8af08fd
4 changed files with 125 additions and 3 deletions
@@ -1934,9 +1934,21 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
}
/// <summary>战神激光命中延迟(秒):不开实体子弹,开火后延迟此时间直接发 KillFish 给后端(模拟弹道飞行)</summary>
[Tooltip("战神激光命中延迟(秒):不开实体子弹,开火后延迟此时间直接发 KillFish 给后端")]
[Tooltip("战神激光命中延迟(秒):不开实体子弹,开火后延迟此时间直接发 KillFish 给后端(模拟弹道飞行)")]
public float laserHitDelay = 0.2f;
[Header("三合一抛物线(正常炮台散射+锁定,上下两颗子弹的弧线)")]
[Tooltip("近距离阈值:目标距离小于此值时弧线鼓出封顶(防止目标太近子弹乱飘)")]
public float sanSheNearDistance = 10f;
[Tooltip("远距离阈值:目标距离大于此值时弧线鼓出保底(很远时仍有弧线感)")]
public float sanSheFarDistance = 35f;
[Tooltip("弧线最高点横向鼓出最大值(目标距离≤近距离阈值时,世界单位)")]
public float sanSheMaxBulge = 6f;
[Tooltip("弧线最高点横向鼓出最小值(目标距离≥远距离阈值时,世界单位)")]
public float sanSheMinBulge = 4f;
[Tooltip("三合一侧弹飞行速度(世界单位/秒,0=用子弹默认速度):子弹默认速度太快全程仅零点几秒,弧线看不清,降速拉长飞行时间")]
public float sanSheSideBulletSpeed = 50f;
private void FireBullet(SitPosData sit, float angle, bool isSanShe, bool isDouble, bool isLock, List<string> bullitIDs,
List<string> fireTargetMonsterIDs = null, List<long> bulletGolds = null)
{
@@ -1972,18 +1984,60 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
// 必须保证三发子弹都创建,否则金币消耗和后端对不上
if (isSanShe && isLock)
{
// 三发出膛角度:左 -20,中 0,右 +20(锁定子弹会追踪转向主锁目标)
// 三发出膛角度:右 -20,中 0,左 +20(锁定子弹会追踪转向主锁目标)
float[] defaultAngles = { angle - 20, angle, angle + 20 };
// ⭐ 三合一抛物线:主锁目标有效时,上下两颗子弹走弧线包抄
// 鼓出幅度随目标距离变化:近→大,远→小(最高点离中线越近),
// 用近距离/远距离两个阈值钳制:很近时封顶不乱飘,很远时保底仍有弧线感
bool hasLockTarget = sit.monCotl_Lock != null && sit.monCotl_Lock_Position != null
&& sit.monCotl_Lock_Position.gameObject.activeInHierarchy;
Vector2 toTarget = Vector2.zero;
float targetDist = 0f;
if (hasLockTarget)
{
toTarget = (Vector2)sit.monCotl_Lock_Position.position - startPos;
targetDist = toTarget.magnitude;
hasLockTarget = targetDist > 0.01f;
}
// ⭐ 诊断日志(定位三合一抛物线不生效用,问题解决后删除)
if (sit.user == GameManager.Instance.user.id)
{
float tDiag = Mathf.InverseLerp(sanSheFarDistance, sanSheNearDistance, targetDist);
float bulgeDiag = Mathf.Lerp(sanSheMinBulge, sanSheMaxBulge, tDiag);
Debug.Log($"[三合一诊断] 进入三合一分支: 主锁目标={(sit.monCotl_Lock != null ? sit.monCotl_Lock.name : "无")} " +
$"锁定点={(sit.monCotl_Lock_Position != null ? "有" : "无")} hasLockTarget={hasLockTarget} " +
$"目标距离={targetDist:F2} 鼓出={bulgeDiag:F2} 侧弹速度={sanSheSideBulletSpeed} " +
$"阈值(近{sanSheNearDistance}/远{sanSheFarDistance}) 幅度(小{sanSheMinBulge}/大{sanSheMaxBulge})");
}
for (int i = 0; i < 3; i++)
{
// lockTarget 传 null:CreateBullet 内部兜底会 Lock(sit.monCotl_Lock, sit.monCotl_Lock_Position),
// 三发全部锁定同一条主锁目标;主锁目标为空时按普通子弹发射(不锁定)
CreateBullet(sit, startPos, defaultAngles[i], isDouble, true, SafeBid(i), null, null, GetBulletGold(i));
var bullet = CreateBullet(sit, startPos, defaultAngles[i], isDouble, true, SafeBid(i), null, null, GetBulletGold(i));
// ⭐ 上下两颗(i=0/2)挂抛物线,中间(i=1)直线:
// 鼓出方向垂直于炮口→目标连线,两颗各往自己外侧鼓,形成弧线包抄汇聚
// 侧弹同时降速(子弹默认100太快,零点几秒飞完,弧线看不清)
if (bullet != null && hasLockTarget && i != 1)
{
// 近距离阈值内→最大鼓出,远距离阈值外→最小鼓出,中间线性过渡
float t = Mathf.InverseLerp(sanSheFarDistance, sanSheNearDistance, targetDist);
float bulge = Mathf.Lerp(sanSheMinBulge, sanSheMaxBulge, t);
Vector2 axisRight = new Vector2(toTarget.y, -toTarget.x).normalized;
bullet.SetParabola(i == 0 ? axisRight : -axisRight, bulge, targetDist, sanSheSideBulletSpeed);
}
}
}
else if (isSanShe)
{
// ⭐ 诊断日志(定位三合一抛物线不生效用,问题解决后删除)
if (sit.user == GameManager.Instance.user.id)
Debug.LogWarning($"[三合一诊断] 走了【散射不锁定】直飞分支: 锁定开关={isLock} → 三发直飞无终点无弧线。" +
$"三合一抛物线需要: 散射+锁定都开 且 锁定到一条鱼");
CreateBullet(sit, startPos, angle - 20, isDouble, isLock, SafeBid(0), null, null, GetBulletGold(0));
CreateBullet(sit, startPos, angle, isDouble, isLock, SafeBid(1), null, null, GetBulletGold(1));
CreateBullet(sit, startPos, angle + 20, isDouble, isLock, SafeBid(2), null, null, GetBulletGold(2));