1.1.0 未驗證
This commit is contained in:
1 parent
2638c5929d
commit
4a72bd132a
31 files changed
+790
-123
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
// 模擬 AI 視覺外掛的輔助瞄準 : 只用 EnemyPerceptor.Output (外掛真正拿到的結果)
|
||||
// 模式依 StartUI 設定 : 0 = 無輔助,1 = 平滑跟槍
|
||||
// 模式與強度由 BotSpawner 每回合用 Apply() 套上 (自動配置的排程,或 StartUI 的設定) ; 0 = 無輔助,1 = 平滑跟槍
|
||||
// 執行順序排在 PlayerLook 之前,修正量在同一幀套用
|
||||
[DefaultExecutionOrder(-10)]
|
||||
public class AimAssist : MonoBehaviour
|
||||
{
|
||||
[Header("參照")]
|
||||
@@ -10,19 +12,12 @@ public class AimAssist : MonoBehaviour
|
||||
[Tooltip("CameraRoot 上的 PlayerLook")]
|
||||
public PlayerLook playerLook;
|
||||
|
||||
[Header("輔助範圍 (準心周圍一圈,半徑隨強度變大)")]
|
||||
[Tooltip("強度 1% 時的半徑 (度)")]
|
||||
public float minFov = 3f;
|
||||
|
||||
[Tooltip("強度 100% 時的半徑 (度)")]
|
||||
public float maxFov = 15f;
|
||||
|
||||
[Header("平滑跟槍")]
|
||||
[Tooltip("強度 1% / 100% 時的修正速度 (每秒修正剩餘誤差的比例係數,越大越快)")]
|
||||
public Vector2 trackSpeed = new Vector2(2f, 30f);
|
||||
|
||||
// 給記錄器用 : 這一幀輔助做了什麼
|
||||
public float FovRadius { get; private set; }
|
||||
public float FovRadius { get; private set; } // 作用範圍半徑 (度) : 有輔助固定 15,無輔助 0 (SessionPlan.AssistFovDeg)
|
||||
public bool Engaged { get; private set; }
|
||||
|
||||
private int mode;
|
||||
@@ -35,19 +30,28 @@ public class AimAssist : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 輔助模式與強度不在這裡讀 : 由 Apply() 每回合套上,才不會被第一回合的生成順序蓋掉
|
||||
GameSettings s = GameSettings.Load();
|
||||
mode = s.assistMode;
|
||||
strength = s.assistStrength / 100f;
|
||||
noHorizontal = s.disableHorizontalAssist;
|
||||
noVertical = s.disableVerticalAssist;
|
||||
degreesPerCount = 0.022f * Mathf.Max(0.01f, s.sensitivity); // 跟 PlayerLook 相同的換算
|
||||
degreesPerCount = 0.022f * Mathf.Max(0.01f, (float)s.sensitivity); // 跟 PlayerLook 相同的換算
|
||||
}
|
||||
|
||||
FovRadius = mode == 1 ? Mathf.Lerp(minFov, maxFov, strength) : 0f; // 無輔助時記 0
|
||||
// 套用這一回合的條件,並清掉上一回合的殘留 (BotSpawner 在生成機器人、觸發 BotSpawned 之前呼叫)
|
||||
public void Apply(SessionPlan.RoundCondition c)
|
||||
{
|
||||
mode = c.assistMode;
|
||||
strength = c.assistStrength / 100f;
|
||||
FovRadius = mode == 1 ? c.assistFovDeg : 0f; // 無輔助時記 0
|
||||
remainingError = Vector2.zero;
|
||||
lastSampleTime = -1f;
|
||||
Engaged = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Engaged = false;
|
||||
if (PauseMenu.IsPaused) return; // 暫停時不算、不累積
|
||||
if (mode != 1 || perceptor == null || playerLook == null) return;
|
||||
|
||||
EnemyPerceptor.Detection d = perceptor.Output;
|
||||
|
||||
Reference in new issue
Block a user