3 Commits
Author SHA1 Message Date
Sahik fd0312270b 1.2.0 2026-12-03 02:00:00 +08:00
Sahik c3bb8d1a9e delete data 2026-12-01 21:14:19 +08:00
David b75cfc1e4a upload data 2026-12-01 04:00:38 +08:00
26 changed files with 3310 additions and 87 deletions

No files matched your search

File diff suppressed because it is too large. Load diff
-8
View File
@@ -736,14 +736,6 @@ PrefabInstance:
propertyPath: spawner
value:
objectReference: {fileID: 409618713}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: maxFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: minFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 2935208254808148485, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: spawner
value:
-8
View File
@@ -11059,14 +11059,6 @@ PrefabInstance:
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: maxFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: minFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 3127315678899527277, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: spawner
value:
File diff suppressed because it is too large. Load diff
-8
View File
@@ -3759,14 +3759,6 @@ PrefabInstance:
propertyPath: spawner
value:
objectReference: {fileID: 727757762}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: maxFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 1975131088334436892, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: minFov
value: 15
objectReference: {fileID: 0}
- target: {fileID: 2935208254808148485, guid: f9ebddc774e381740b975be07f15dad6, type: 3}
propertyPath: spawner
value:
+5
View File
@@ -28,6 +28,11 @@ public class GameSettings
public bool isTest = false; // 測試模式 : 不記錄資料
public bool autoPlan = false; // 自動配置 (正式錄製) : 由 SessionPlan 安排每回合有無輔助與強度,鎖定地圖 / 武器 / FOV
// v1.2.0 : 滑鼠 (選填,沒填是空字串 / 0) 與畫質
public string mouseModel = "";
public int mouseDpi = 0; // 100~50000,0 = 沒填
public bool lowQuality = false; // 低畫質 : 切到最低的畫質等級 (只影響畫面)
// 系統資訊
public int screenWidth;
public int screenHeight;
+49 -8
View File
@@ -4,7 +4,7 @@ using System.IO;
using System.Text;
using UnityEngine;
// 自動配置 (v1.1.0 正式錄製協定) : 這次執行的回合順序、進度與亂數種子
// 自動配置 (v1.2.0 正式錄製協定) : 這次執行的回合順序、進度與亂數種子
// 勾了 StartUI 的「自動配置」才會套排程 ; 自由模式與測試模式也由這裡組出條件,讓輔助腳本只走同一條路徑
// 跨場景共用 (回主畫面再回來,進度接著走) ; 回合存檔成功才前進,所以中途離開會重做同一個條件
// 當機後重開 : 新的種子、進度歸零,不接續 (舊回合由 SessionStorage 的 recovered/ 處理)
@@ -18,21 +18,21 @@ public static class SessionPlan
public int assistDelayMs; // 模擬辨識延遲 (自動配置兩類回合都一樣)
public int assistDelayJitterMs;
public float assistFovDeg; // 作用範圍 : 有輔助 15, 無輔助 0 (frames 的 assist_fov)
public int planIndex; // 排程中的第幾項 (熱身 0~4, 正式 5~84) ; 自由 / 測試模式 -1
public int blockIndex; // 區塊 0~7 ; 熱身、自由 / 測試模式 -1
public int planIndex; // 排程中的第幾項 (熱身 0~2, 正式 3~52) ; 自由 / 測試模式 -1
public int blockIndex; // 區塊 0~4 ; 熱身、自由 / 測試模式 -1
public int orderInBlock; // 區塊內 0~9 ; 熱身、自由 / 測試模式 -1
public bool isWarmup; // 熱身回合照常存檔,分析時排除
public int roundSeed; // 這一回合的亂數種子 (後座力、機器人動作、生成點、延遲抖動)
}
// ===== 協定常數 : 改任何一個都要升版號,已錄的人全部重錄 =====
public const string ProtocolVersion = "1.1.0";
public const int WarmupRounds = 5; // 熱身 : 無輔助
public const int Blocks = 8; // 試錄超過 20 分鐘就改 7,出包前決定
public const string ProtocolVersion = "1.2.0";
public const int WarmupRounds = 3; // 熱身 : 無輔助 (v1.1.0 為 5)
public const int Blocks = 5; // v1.1.0 為 8
public const int NoAssistPerBlock = 5; // 每區塊無輔助回合數
public static readonly int[] Strengths = { 20, 40, 60, 80, 100 }; // 每區塊各一回合
public const int RoundsPerBlock = NoAssistPerBlock + 5; // 5 = Strengths 的個數
public const int Total = WarmupRounds + Blocks * RoundsPerBlock; // 85
public const int Total = WarmupRounds + Blocks * RoundsPerBlock; // 53
public const float AssistFovDeg = 15f;
public const int DelayMs = 15;
public const int JitterMs = 5;
@@ -40,6 +40,7 @@ public static class SessionPlan
public const string Weapon = "Uzi";
public const int Fov = 90;
public const int TargetFps = 60;
public const float FpsWarnThreshold = 55f; // 熱身平均 FPS 低於這個值就提示 (不擋錄製)
// 這次執行的排程種子 (6 個人各自不同) ; 種子加 Generate() 就能重算整份順序
public static int PlanSeed { get; private set; }
@@ -58,6 +59,12 @@ public static class SessionPlan
private static int progress;
private static System.Random freeSeedRandom;
// 熱身的幀數與遊玩秒數 (扣掉暫停) : 熱身做完後算平均 FPS
private static long warmupFrames;
private static double warmupSeconds;
private static bool fpsChecked;
private static int defaultQualityLevel = -1;
// 每次進入 Play 都重設 (編輯器關掉 Domain Reload 時,static 不會自動清空)
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Init()
@@ -67,6 +74,9 @@ public static class SessionPlan
progress = 0;
Started = false;
freeSeedRandom = new System.Random();
warmupFrames = 0;
warmupSeconds = 0;
fpsChecked = false;
}
public static bool IsAuto(GameSettings s) => s != null && s.autoPlan && !s.isTest;
@@ -121,6 +131,24 @@ public static class SessionPlan
if (planIndex >= 0 && planIndex == progress) progress++;
}
// ===== 熱身 FPS 檢查 =====
// 熱身回合存檔時呼叫 (幀數只算有寫進 frames 的幀,秒數扣掉暫停)
public static void AddWarmupRound(int frames, double playSeconds)
{
if (playSeconds <= 0) return;
warmupFrames += frames;
warmupSeconds += playSeconds;
}
// 熱身的平均 FPS ; 熱身還沒做完為 -1
public static float WarmupFps => progress >= WarmupRounds && warmupSeconds > 0 ? (float)(warmupFrames / warmupSeconds) : -1f;
// 熱身剛做完、第一個正式回合生成之前,而且還沒檢查過 (回主選單再進來不會再檢查一次)
public static bool NeedsFpsCheck(GameSettings s) => IsAuto(s) && progress == WarmupRounds && !fpsChecked;
public static void MarkFpsChecked() => fpsChecked = true;
// 畫面上的進度文字 : 不顯示有無輔助或強度
public static string GetProgressText(GameSettings s)
{
@@ -133,7 +161,7 @@ public static class SessionPlan
return $"已記錄 {SessionStorage.NoAssistRounds + SessionStorage.AssistRounds} 回合";
}
// 由種子產生整份順序 : 熱身 5 回合無輔助 ; 之後每區塊 10 回合 (無輔助 5、各強度 1),區塊內隨機排序
// 由種子產生整份順序 : 熱身 3 回合無輔助 ; 之後每區塊 10 回合 (無輔助 5、各強度 1),區塊內隨機排序
// 同一個種子一定得到同一份順序
public static List<RoundCondition> Generate(int seed)
{
@@ -206,6 +234,19 @@ public static class SessionPlan
};
}
// 進遊戲前套用畫質與幀率 : 切換畫質等級會改掉 vSync 設定,所以幀率一定要在畫質之後設
// 低畫質 = 最低的畫質等級 (索引 0) ; 只影響畫面,遊戲邏輯與遮擋判定 (碰撞體射線) 不受影響
public static void ApplyDisplaySettings(GameSettings s)
{
// 一般畫質 = 名稱為 PC 的等級 ; 找不到才用第一次呼叫時的等級 (編輯器裡上次 Play 切過的等級會留著,所以優先用名稱)
if (defaultQualityLevel < 0) defaultQualityLevel = QualitySettings.GetQualityLevel();
int normal = Array.IndexOf(QualitySettings.names, "PC");
if (normal < 0) normal = defaultQualityLevel;
int level = s != null && s.lowQuality ? 0 : normal;
if (QualitySettings.GetQualityLevel() != level) QualitySettings.SetQualityLevel(level, true);
ApplyFrameRate(s);
}
// 自動配置時固定幀率,讓每個人的幀間隔一致 (實際幀率仍由 frames 的 dt 記錄) ; 其他模式維持不限制
public static void ApplyFrameRate(GameSettings s)
{
+79 -8
View File
@@ -7,7 +7,8 @@ using UnityEngine;
using Debug = UnityEngine.Debug;
// Build 前把 git commit 短碼寫到 Assets/BuildInfo/Resources/build_id.txt (不進 git),執行時由 BuildInfo.Id 讀出、記進 config 的 buildId
// 工作區不乾淨 (有未提交的改動) 會在後面加 "-dirty" 並警告 : 正式出包前請先全部 commit,出包後對該 commit 打 tag
// 工作區不乾淨 (有未提交的改動) 會在後面加 "-dirty" ; git 執行不了時改讀 .git 檔案並加 "-nogit" ; 都讀不到是 "unknown"
// 正式出包前請先全部 commit,出包後對該 commit 打 tag
public class BuildIdWriter : IPreprocessBuildWithReport
{
const string Folder = "Assets/BuildInfo/Resources";
@@ -16,9 +17,32 @@ public class BuildIdWriter : IPreprocessBuildWithReport
public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{
string id = BuildId();
Directory.CreateDirectory(Folder);
File.WriteAllText(FilePath, id);
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
Debug.Log($"BuildIdWriter : buildId = {id}");
}
// 正式出包應該是乾淨的 7 碼 ; 出現 -dirty、-nogit、unknown 都代表這個 exe 不該發出去
static string BuildId()
{
string hash = Git("rev-parse --short HEAD");
string id = string.IsNullOrEmpty(hash) ? "unknown" : hash;
// git 執行不了 (v1.1.0 出過包) : 改直接讀 .git 裡的檔案,但無法判斷工作區乾不乾淨
if (string.IsNullOrEmpty(hash))
{
string fromFiles = ReadHeadFromFiles();
if (string.IsNullOrEmpty(fromFiles))
{
Debug.LogWarning("BuildIdWriter : git 與 .git 檔案都讀不到,buildId 會是 unknown。這個 exe 不該發出去。");
return "unknown";
}
Debug.LogWarning("BuildIdWriter : git 執行失敗,改從 .git 檔案讀 commit,無法確認工作區是否乾淨,buildId 加上 -nogit。這個 exe 不該發出去,請在 git 能正常執行的環境重新出包。");
return fromFiles + "-nogit";
}
bool dirty = false;
foreach (string line in Git("status --porcelain").Split('\n'))
@@ -31,14 +55,61 @@ public class BuildIdWriter : IPreprocessBuildWithReport
if (dirty)
{
id += "-dirty";
Debug.LogWarning("BuildIdWriter : 工作區有未提交的改動,buildId 加上 -dirty。正式出包請先 commit 再 Build。");
return hash + "-dirty";
}
return hash;
}
Directory.CreateDirectory(Folder);
File.WriteAllText(FilePath, id);
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
Debug.Log($"BuildIdWriter : buildId = {id}");
// 讀 .git/HEAD : 「ref: refs/heads/<分支>」就再讀該分支的檔案 (沒有就找 packed-refs) ; 直接是雜湊 (detached HEAD) 就用它
// 回傳前 7 碼,讀不到回傳空字串
static string ReadHeadFromFiles()
{
try
{
string gitDir = Path.Combine(Path.GetDirectoryName(Application.dataPath), ".git");
string head = File.ReadAllText(Path.Combine(gitDir, "HEAD")).Trim();
string hash = head;
if (head.StartsWith("ref:"))
{
string refName = head.Substring(4).Trim();
string refPath = Path.Combine(gitDir, refName.Replace('/', Path.DirectorySeparatorChar));
hash = File.Exists(refPath) ? File.ReadAllText(refPath).Trim() : FindPackedRef(gitDir, refName);
}
return IsHash(hash) ? hash.Substring(0, 7) : "";
}
catch (System.Exception e)
{
Debug.LogWarning($"BuildIdWriter : 讀取 .git 檔案失敗 ({e.Message})");
return "";
}
}
// packed-refs 每行是「<雜湊> <ref 名稱>」,# 開頭是註解,^ 開頭是 tag 指向的 commit
static string FindPackedRef(string gitDir, string refName)
{
string path = Path.Combine(gitDir, "packed-refs");
if (!File.Exists(path)) return "";
foreach (string raw in File.ReadAllLines(path))
{
string line = raw.Trim();
if (line.Length == 0 || line[0] == '#' || line[0] == '^') continue;
int space = line.IndexOf(' ');
if (space > 0 && line.Substring(space + 1).Trim() == refName) return line.Substring(0, space);
}
return "";
}
static bool IsHash(string s)
{
if (string.IsNullOrEmpty(s) || s.Length < 40) return false;
for (int i = 0; i < 40; i++)
{
if (!System.Uri.IsHexDigit(s[i])) return false;
}
return true;
}
static string Git(string arguments)
@@ -62,7 +133,7 @@ public class BuildIdWriter : IPreprocessBuildWithReport
}
catch (System.Exception e)
{
Debug.LogWarning($"BuildIdWriter : 執行 git 失敗 ({e.Message}),buildId 會是 unknown");
Debug.LogWarning($"BuildIdWriter : 執行 git 失敗 ({e.Message}),改讀 .git 檔案");
return "";
}
}
+25
View File
@@ -80,6 +80,23 @@ public class BotSpawner : MonoBehaviour
{
if (botPrefab == null) return;
// 熱身剛做完 : 平均 FPS 太低就先提示,按「繼續」才生成第一個正式回合 (只檢查一次)
if (SessionPlan.NeedsFpsCheck(settings))
{
SessionPlan.MarkFpsChecked();
float fps = SessionPlan.WarmupFps;
Debug.Log($"BotSpawner : 熱身平均 FPS = {fps:F1}");
if (fps >= 0f && fps < SessionPlan.FpsWarnThreshold)
{
FpsWarning warning = FpsWarning.FindInScene();
if (warning != null && warning.Show(fps, () => StartCoroutine(SpawnWhenUnpaused())))
{
return;
}
Debug.LogWarning("BotSpawner : 場景裡沒有可用的 FpsWarning (或 PauseMenu),不提示直接繼續");
}
}
// 自動配置做完全部回合就不再生成 (RoundProgressHUD 會提示關閉遊戲)
if (!SessionPlan.TryGetCurrent(settings, out SessionPlan.RoundCondition c)) return;
CurrentCondition = c;
@@ -119,6 +136,14 @@ public class BotSpawner : MonoBehaviour
Spawn();
}
// 提示關掉後,等到「這一幀不是暫停」才生成 : 不然新回合的第一幀會被記成回合內的暫停
IEnumerator SpawnWhenUnpaused()
{
yield return null;
yield return new WaitUntil(() => !PauseMenu.IsPaused);
Spawn();
}
// 在範圍內隨機選點 : 要離玩家夠遠,而且不能卡在障礙物或牆裡 ; 試很多次都不行就用最後一次的結果
Vector3 PickSpawnPoint()
{
+90
View File
@@ -0,0 +1,90 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;
// 熱身做完、平均 FPS 太低時的提示 (v1.2.0) : 只提醒,不擋錄製
// 由 BotSpawner 在第一個正式回合生成之前呼叫,這時沒有回合在進行,所以不會吃到回合時間,也不會記成回合內的暫停
// 掛在場景裡一直啟用的物件上 (例如 HUD 的 Canvas),提示視窗本身平常隱藏
public class FpsWarning : MonoBehaviour
{
[Header("UI 參照")]
[Tooltip("提示視窗 (Panel),平常隱藏")]
public GameObject panel;
[Tooltip("提示文字 Text (TMP)")]
public TextMeshProUGUI messageText;
[Tooltip("繼續 Button")]
public Button continueButton;
[Tooltip("回主選單 Button")]
public Button menuButton;
[Header("場景")]
public string startSceneName = "StartUI";
private Action onContinue;
private bool wired;
void Start()
{
if (panel != null && onContinue == null) panel.SetActive(false);
WireButtons();
}
// 掛的物件沒啟用時 Start() 不會跑,所以 Show() 也會呼叫一次
void WireButtons()
{
if (wired) return;
wired = true;
if (continueButton != null) continueButton.onClick.AddListener(OnContinueClicked);
if (menuButton != null) menuButton.onClick.AddListener(OnMenuClicked);
}
// 給 BotSpawner 找場景裡的提示 (提示視窗可能是隱藏的,所以也找未啟用的物件)
public static FpsWarning FindInScene()
{
return FindAnyObjectByType<FpsWarning>(FindObjectsInactive.Include);
}
// 顯示提示並暫停 (不顯示暫停視窗) ; 按「繼續」後呼叫 continueAction
// 顯示不出來 (沒接 Panel 或場景沒有 PauseMenu) 時回傳 false,呼叫端直接繼續
public bool Show(float fps, Action continueAction)
{
if (panel == null) return false;
if (!PauseMenu.PauseForPrompt()) return false;
WireButtons();
onContinue = continueAction;
if (messageText != null)
{
messageText.text = $"目前平均 FPS 是 {fps:F0},目標是 {SessionPlan.TargetFps}。\n" +
"建議關掉其他程式,或回主選單勾選「低畫質」。\n" +
"也可以直接繼續。";
}
panel.SetActive(true);
return true;
}
void OnContinueClicked()
{
if (panel != null) panel.SetActive(false);
PauseMenu.ResumeFromPrompt();
Action action = onContinue;
onContinue = null;
action?.Invoke();
}
// 回主選單 : 排程進度照舊 (再進來從第一個正式回合開始,熱身不用重做)
void OnMenuClicked()
{
onContinue = null;
Time.timeScale = 1f;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
SceneManager.LoadScene(startSceneName);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9a00a586eeeb99241b2b77f6cdd35837
+53 -5
View File
@@ -8,6 +8,10 @@ using UnityEngine.InputSystem.UI;
// 遊戲中按 Esc 暫停 : 時間停止、放開滑鼠,選「繼續」或「回到主畫面」
// 切出遊戲視窗 (Alt+Tab 等) 時也會自動暫停
// 暫停期間記錄器不記錄,回合照樣有效
// v1.2.0 : 暫停狀態在每一幀開頭鎖存,同一幀裡所有腳本 (視角、輔助、感知器、武器、記錄器) 看到的都一樣
// 幀中途發生的暫停 / 繼續 (Esc、按鈕、切出視窗) 從下一幀才生效
// 執行順序 -100 : 在 RawMouseInput (-10000) 之後、AimAssist (-10) / PlayerLook (0) / RoundRecorder (100) 之前
[DefaultExecutionOrder(-100)]
public class PauseMenu : MonoBehaviour
{
[Header("UI 參照")]
@@ -23,12 +27,28 @@ public class PauseMenu : MonoBehaviour
[Header("場景")]
public string startSceneName = "StartUI";
// 給其他腳本判斷 (視角、記錄器)
// 給其他腳本判斷 (視角、輔助、感知器、武器、記錄器) : 「這一幀是否暫停」,整幀內不會變
public static bool IsPaused { get; private set; }
// 開始暫停的時間 (跟記錄器同一條時間軸) : 切出視窗時遊戲會停住,記錄器要靠這個知道真正的暫停時間
public static double PauseStartTime { get; private set; }
// 即時的暫停狀態 : 下一幀開頭才複製到 IsPaused
private static bool paused;
// 提示視窗 (例如熱身 FPS 提示) 開著 : 也算暫停,但不顯示暫停視窗,Esc 不作用
private static bool inPrompt;
private static PauseMenu instance;
void Awake()
{
instance = this;
paused = false;
inPrompt = false;
IsPaused = false;
}
void Start()
{
EnsureButtonsClickable();
@@ -40,9 +60,13 @@ public class PauseMenu : MonoBehaviour
void Update()
{
// 先鎖存這一幀的狀態,之後的 Esc 從下一幀才生效
IsPaused = paused;
if (inPrompt) return;
if (Keyboard.current != null && Keyboard.current.escapeKey.wasPressedThisFrame)
{
if (IsPaused) Resume();
if (paused) Resume();
else Pause();
}
}
@@ -50,16 +74,38 @@ public class PauseMenu : MonoBehaviour
// 遊戲視窗失去焦點 (Alt+Tab、點到別的視窗) : 自動暫停,回來時要按「繼續」
void OnApplicationFocus(bool hasFocus)
{
if (!hasFocus && !IsPaused) Pause();
if (!hasFocus && !paused) Pause();
}
void OnDestroy()
{
// 離開場景時一定要恢復,不然下一個場景會停住
if (instance == this) instance = null;
paused = false;
inPrompt = false;
IsPaused = false;
Time.timeScale = 1f;
}
// ===== 提示視窗用 (FpsWarning) =====
// 暫停但不顯示暫停視窗 ; 場景裡沒有 PauseMenu 時回傳 false
public static bool PauseForPrompt()
{
if (instance == null) return false;
inPrompt = true;
if (!paused) instance.Pause();
if (instance.pausePanel != null) instance.pausePanel.SetActive(false);
return true;
}
public static void ResumeFromPrompt()
{
if (instance == null) return;
inPrompt = false;
instance.Resume();
}
// 按鈕要能點,需要 : 場景裡有 EventSystem、Canvas 上有 Graphic Raycaster
// 地圖場景不一定有 (例如沙漠是從 Demo 場景改的),缺的話這裡自動補上
void EnsureButtonsClickable()
@@ -80,7 +126,7 @@ public class PauseMenu : MonoBehaviour
void Pause()
{
IsPaused = true;
paused = true;
PauseStartTime = Time.realtimeSinceStartupAsDouble;
Time.timeScale = 0f;
Cursor.lockState = CursorLockMode.None;
@@ -90,7 +136,7 @@ public class PauseMenu : MonoBehaviour
void Resume()
{
IsPaused = false;
paused = false;
Time.timeScale = 1f;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
@@ -99,6 +145,8 @@ public class PauseMenu : MonoBehaviour
void BackToMenu()
{
paused = false;
inPrompt = false;
IsPaused = false;
Time.timeScale = 1f;
Cursor.lockState = CursorLockMode.None;
+25 -5
View File
@@ -119,7 +119,7 @@ MouseTrail_<ID>_<yyyyMMdd_HHmmss>.zip
| `hit` | 命中一次(霰彈的每顆彈丸各記一次) |
| `kill` | 敵人倒下,回合結束 |
| `reload_start` | 開始換彈 |
| `pause` / `resume` | 暫停 / 繼續。按 Esc 或切出遊戲視窗(Alt+Tab 等)都會暫停。暫停期間 mouse 和 frames 不會有資料,`pause` 的時間是真正開始暫停的時間 |
| `pause` / `resume` | 暫停 / 繼續。按 Esc 或切出遊戲視窗(Alt+Tab 等)都會暫停。暫停期間 mouse 和 frames 不會有資料,`pause` 的時間是真正開始暫停的時間。v1.2.0 起暫停狀態在每一幀開頭決定,幀中途發生的暫停 / 繼續從下一幀才生效,所以每一幀的 mouse 加總都等於 frames 的 `mouse_dx`、`mouse_dy`(v1.1.0 在恢復的那一幀可能有 mouse 回報、但 frames 的位移是 0)。按 Esc 的那一幀仍會記錄,所以 `pause` 的時間不會早於最後一筆 frames 的 `t` |
| `prone_start` / `prone_end` | 開始趴下 / 結束趴下(站起或蹲起)。按 Z 切換。回合開始時已經趴著的話,會在 `round_start` 之後立刻補一筆 `prone_start`;回合結束時還趴著的話不會有 `prone_end` |
不記錄鍵盤按鍵(`prone_start` / `prone_end` 是姿勢改變的事件,不是按鍵事件)。玩家的移動用 `frames_N.csv` 的位置、速度和 `state` 表示,這是物理引擎實際算出的結果(包含加速度、滑鏟、空中轉向),比按鍵本身更能描述「畫面相對於玩家怎麼動」。
@@ -151,22 +151,33 @@ v1.1.0 新增:
|---|---|
| `autoPlan` | 是否為自動配置(正式錄製)。false = 自由模式,條件由玩家自己選 |
| `protocolVersion` | 錄製協定版本 |
| `buildId` | 出包時的 git commit 短碼,用來分辨同版號的不同 build。`-dirty` 表示出包時有未提交的改動,`editor` 表示在編輯器裡錄的 |
| `buildId` | 出包時的 git commit 短碼,用來分辨同版號的不同 build。`-dirty` 表示出包時有未提交的改動,`editor` 表示在編輯器裡錄的。v1.2.0 起出包時若 git 執行不了,會改讀 `.git` 檔案並加上 `-nogit`(無法確認工作區是否乾淨),都讀不到才是 `unknown`;正式發布的 build 應該是乾淨的 7 碼 |
| `sessionId` | 這次執行的代號(跟 zip 檔名的時間相同) |
| `planSeed` | 這次執行的排程種子 |
| `planIndex` | 排程中的第幾項:熱身 0–4,正式 5–84。自由模式為 -1 |
| `blockIndex`、`orderInBlock` | 區塊 0–7、區塊內第幾回合 0–9。熱身與自由模式為 -1 |
| `planIndex` | 排程中的第幾項:v1.1.0 熱身 0–4、正式 5–84;v1.2.0 熱身 0–2、正式 3–52。自由模式為 -1 |
| `blockIndex`、`orderInBlock` | 區塊(v1.1.0 為 0–7,v1.2.0 為 0–4)、區塊內第幾回合 0–9。熱身與自由模式為 -1 |
| `isWarmup` | 熱身回合,分析時請排除 |
| `assistFovDeg` | 作用範圍半徑(度),無輔助時為 0 |
| `roundSeed` | 這一回合的亂數種子:後座力、生成點、機器人動作、延遲抖動都由它開始。機器人動作與抖動的取用次數隨幀而變,所以只能近似重現 |
| `targetFps`、`vSyncCount` | 實際生效的幀率設定,`targetFps` 為 -1 表示不限制 |
v1.2.0 新增:
| 欄位 | 說明 |
|---|---|
| `mouseModel` | 滑鼠型號,玩家選填(最多 40 字),沒填為空字串 |
| `mouseDpi` | 滑鼠 DPI,玩家選填,範圍 100–50000,沒填或超出範圍為 0。回報率沒有欄位,請從 `mouse_N.csv` 的時間間隔計算 |
| `lowQuality` | StartUI 是否勾選「低畫質」(切到最低的畫質等級,只影響畫面,遊戲邏輯與遮擋判定不變) |
| `qualityLevel` | 這一回合實際的畫質等級名稱(`PC` 為預設、`Low` 為低畫質) |
| `warmupFps` | 熱身回合的平均 FPS(熱身的總幀數 ÷ 扣掉暫停的總遊玩秒數)。熱身還沒結束與自由模式為 -1。低於 55 時,遊戲會在第一個正式回合前提示玩家,但不擋錄製,分析時請自行標記 |
## 版本與資料階段
| 階段 | 版本 | 說明 |
|---|---|---|
| 第一階段(data_1) | `appVersion` 皆為 1.0.1 | 兩位玩家,**每人** 150 回合(無輔助 100、有輔助 50),125Hz 滑鼠,60Hz 螢幕,辨識延遲 15ms ± 5ms。先錄完有輔助(強度 20 → 100),再錄無輔助 |
| 第二階段起 | v1.1.0 | 自動配置,見下方「v1.1.0 錄製協定」 |
| 第二階段(data_2) | v1.1.0 | 自動配置,見下方「v1.1.0 錄製協定」 |
| 第三階段(data_3) | v1.2.0 | 與 v1.1.0 只差回合數,見下方「v1.2.0 錄製協定」 |
第一階段兩位玩家的差異:
@@ -187,6 +198,15 @@ v1.1.0 新增:
- 有輔助的回合準心是綠色、無輔助是白色,所以**玩家知道當下有沒有輔助**,但不知道強度。玩家可能因此調整瞄準方式,有無輔助的差異會同時包含輔助本身與玩家的反應。
- 回合存檔成功才進到下一項;中途回主畫面會重做同一項。關閉遊戲後再開是新的 session 與新的種子,不會接續。
### v1.2.0 錄製協定
與 v1.1.0 **只差回合數**,其他條件、輔助公式、區塊組成與洗牌方式、記錄格式都相同,可以和 v1.1.0 的資料直接合併:
- 熱身 3 回合(`planIndex` 0–2),接著 5 個區塊(`blockIndex` 0–4,`planIndex` 3–52),共 53 回合,約 6–12 分鐘。
- 新增的 config 欄位(`mouseModel`、`mouseDpi`、`lowQuality`、`qualityLevel`、`warmupFps`)見上方「v1.2.0 新增」。
- 暫停 / 繼續從下一幀才生效(見 `events_N.csv` 的 `pause` / `resume`);暫停期間不能開槍。
- 熱身平均 FPS 低於 55 時,第一個正式回合之前會跳提示(建議關掉其他程式或回主選單勾選低畫質,也可以直接繼續)。提示出現時沒有回合在進行,不會記成回合內的暫停。
## 模擬視覺模型
有輔助的回合中,輔助使用的敵人位置來自「模擬 AI 視覺模型」。它直接讀取敵人的骨架位置(完美感知器),只加上三個真實外掛本來就有的限制,**不做插值或預測**:
+11 -2
View File
@@ -33,8 +33,8 @@ public class RoundConfig : GameSettings
public string buildId; // 出包時的 git commit 短碼,分辨同版號的不同 build
public string sessionId; // 這次執行的代號 (= 資料夾 / zip 的時間戳)
public int planSeed; // 排程種子
public int planIndex; // 排程中的第幾項 (熱身 0~4,正式 5~84)
public int blockIndex; // 區塊 0~7,熱身 -1
public int planIndex; // 排程中的第幾項 (v1.2.0 : 熱身 0~2,正式 3~52)
public int blockIndex; // 區塊 (v1.2.0 : 0~4),熱身 -1
public int orderInBlock; // 區塊內 0~9,熱身 -1
public bool isWarmup; // 熱身回合 (分析時排除)
public float assistFovDeg; // 作用範圍 (度),無輔助為 0
@@ -42,6 +42,10 @@ public class RoundConfig : GameSettings
public int targetFps; // Application.targetFrameRate,-1 = 不限制
public int vSyncCount;
// v1.2.0
public float warmupFps; // 熱身量到的平均 FPS ; 熱身還沒結束、自由模式為 -1
public string qualityLevel; // 這一回合的畫質等級名稱
public static RoundConfig Create(int index, SessionPlan.RoundCondition condition)
{
RoundConfig c = new RoundConfig();
@@ -72,6 +76,11 @@ public class RoundConfig : GameSettings
c.recoilSeed = condition.roundSeed;
c.targetFps = Application.targetFrameRate;
c.vSyncCount = QualitySettings.vSyncCount;
c.warmupFps = SessionPlan.IsAuto(c) ? SessionPlan.WarmupFps : -1f;
int quality = QualitySettings.GetQualityLevel();
string[] names = QualitySettings.names;
c.qualityLevel = quality >= 0 && quality < names.Length ? names[quality] : quality.ToString();
return c;
}
}
+7 -2
View File
@@ -31,6 +31,7 @@ public class RoundRecorder : MonoBehaviour
public CsvWriter frames;
public CsvWriter events;
public double pauseStart;
public double lastFrameTime; // 最後寫進 frames 的那一幀的 t
public bool finishing; // 機器人倒下了,等這一幀結束再存 (同一幀最後一發的命中也要記到)
}
@@ -122,6 +123,7 @@ public class RoundRecorder : MonoBehaviour
File.WriteAllText(Path.Combine(SessionStorage.Folder, $"config_{c.roundIndex}.json"), JsonUtility.ToJson(c, true));
SessionStorage.MarkRoundSaved(c.assistMode);
if (c.isWarmup) SessionPlan.AddWarmupRound(c.frames, c.duration - c.pausedSeconds); // 熱身平均 FPS 用
SessionPlan.MarkSaved(c.planIndex); // 存檔成功才前進到下一項
Debug.Log($"第 {c.roundIndex} 回合已存檔 ({c.duration:F1} 秒,{c.mouseEvents} 筆滑鼠事件,{c.frames} 幀)");
round = null;
@@ -156,7 +158,9 @@ public class RoundRecorder : MonoBehaviour
if (paused)
{
// 用真正開始暫停的時間 : 切出視窗時遊戲會停住,等切回來才跑到這裡
round.pauseStart = PauseMenu.PauseStartTime;
// v1.2.0 : 按 Esc 的那一幀照常記錄 (暫停從下一幀才生效),所以暫停的開始不能早於最後一幀,
// 不然 pause 事件會排在已記錄的幀前面 ; 切出視窗發生在幀與幀之間,不受影響
round.pauseStart = Math.Max(PauseMenu.PauseStartTime, round.lastFrameTime);
WriteEvent("pause", null, -1f, round.pauseStart);
}
else
@@ -192,7 +196,8 @@ public class RoundRecorder : MonoBehaviour
void WriteFrame(HitscanWeapon weapon)
{
CsvWriter w = round.frames;
w.Add(Now).Add(Time.unscaledDeltaTime);
round.lastFrameTime = Now;
w.Add(round.lastFrameTime).Add(Time.unscaledDeltaTime);
// 視角
Vector2 recoil = playerLook != null ? playerLook.RecoilOffset : Vector2.zero;
+1 -1
View File
@@ -1,7 +1,7 @@
using UnityEngine;
using TMPro;
// 遊戲中顯示目前回合進度 (自動配置 : 第 n / 85 回合,不顯示條件 ; 自由模式 : 已記錄幾回合 ; 測試模式不顯示)
// 遊戲中顯示目前回合進度 (自動配置 : 第 n / 總回合數,不顯示條件 ; 自由模式 : 已記錄幾回合 ; 測試模式不顯示)
// 掛在 PlayerRig,Text 放在 HUD 上
public class RoundProgressHUD : MonoBehaviour
{
+2 -1
View File
@@ -72,7 +72,8 @@ public class HitscanWeapon : MonoBehaviour
UpdateModelKick();
// 選單開著 (滑鼠沒鎖定) 時不能開槍
if (Cursor.lockState != CursorLockMode.Locked) return;
// 這一幀標為暫停時也不行 : 按「繼續」的那一幀滑鼠已經鎖定,但這一幀不記錄,開槍會有 shot 卻沒有對應的幀
if (Cursor.lockState != CursorLockMode.Locked || PauseMenu.IsPaused) return;
if (Keyboard.current != null && Keyboard.current.rKey.wasPressedThisFrame)
{
@@ -0,0 +1,51 @@
using UnityEngine;
using TMPro;
// 滑鼠型號與 DPI (v1.2.0,選填) : 不知道可以留白,不填也能開始
// 存進 GameSettings 的 mouseModel / mouseDpi,每回合的 config 都會帶著 ; 回報率由資料端從 mouse_N.csv 算
public class MouseInfo : MonoBehaviour
{
[Header("UI 參照")]
[Tooltip("滑鼠型號 InputField")]
public TMP_InputField modelInput;
[Tooltip("DPI InputField")]
public TMP_InputField dpiInput;
public const int MaxModelLength = 40;
public const int MinDpi = 100;
public const int MaxDpi = 50000;
void Awake()
{
if (modelInput != null) modelInput.characterLimit = MaxModelLength;
if (dpiInput != null)
{
dpiInput.contentType = TMP_InputField.ContentType.IntegerNumber;
dpiInput.characterLimit = 5;
}
}
// 沒填為空字串
public string GetModel()
{
if (modelInput == null) return "";
string text = modelInput.text.Trim();
return text.Length > MaxModelLength ? text.Substring(0, MaxModelLength) : text;
}
// 沒填、不是數字、超出 100~50000 都當沒填 (0)
public int GetDpi()
{
if (dpiInput == null) return 0;
if (!int.TryParse(dpiInput.text.Trim(), out int dpi)) return 0;
return dpi >= MinDpi && dpi <= MaxDpi ? dpi : 0;
}
// 回填上次的值
public void Restore(string model, int dpi)
{
if (modelInput != null) modelInput.text = model ?? "";
if (dpiInput != null) dpiInput.text = dpi > 0 ? dpi.ToString() : "";
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fc3f787234bcacf4e91a4a93a6318931
@@ -27,6 +27,13 @@ public class SettingsSaver : MonoBehaviour
public Slider sensitivitySlider;
public Slider fovSlider;
[Header("滑鼠與畫質 (v1.2.0)")]
[Tooltip("滑鼠型號與 DPI 輸入欄 (選填)")]
public MouseInfo mouseInfo;
[Tooltip("低畫質 Toggle : 勾了就切到最低的畫質等級 (只影響畫面)")]
public Toggle lowQualityToggle;
[Header("輔助設定")]
public TMP_Dropdown assistDropdown;
public Slider assistStrengthSlider;
@@ -103,7 +110,7 @@ public class SettingsSaver : MonoBehaviour
RestoreLastSettings();
}
// 回填上次的 ID、靈敏度、FOV (不用每次重打)
// 回填上次的 ID、靈敏度、FOV、滑鼠型號與 DPI、低畫質 (不用每次重打)
// 自動配置不從檔案回填 : 舊版的設定檔沒有這一項,會變成沒勾 ; 以場景的預設為準,這次執行用過就維持勾選
void RestoreLastSettings()
{
@@ -117,6 +124,8 @@ public class SettingsSaver : MonoBehaviour
}
if (sensitivitySlider != null) sensitivitySlider.value = (float)last.sensitivity;
if (fovSlider != null) fovSlider.value = last.fov;
if (mouseInfo != null) mouseInfo.Restore(last.mouseModel, last.mouseDpi);
if (lowQualityToggle != null) lowQualityToggle.isOn = last.lowQuality;
}
// 要勾同意書,而且 Raw Input 正常運作 (沒有它就拿不到每一筆的真實時間,資料不能用) ; 測試不受影響
@@ -184,7 +193,7 @@ public class SettingsSaver : MonoBehaviour
}
settings.Save();
SessionPlan.ApplyFrameRate(settings);
SessionPlan.ApplyDisplaySettings(settings); // 畫質 → 幀率 (順序不能反)
Debug.Log($"設定已存到 : {GameSettings.FilePath}");
SceneManager.LoadScene(settings.map);
@@ -200,6 +209,13 @@ public class SettingsSaver : MonoBehaviour
if (sensitivitySlider != null) s.sensitivity = Math.Round(sensitivitySlider.value * 10.0) / 10.0;
if (fovSlider != null) s.fov = Mathf.RoundToInt(fovSlider.value);
if (mouseInfo != null)
{
s.mouseModel = mouseInfo.GetModel();
s.mouseDpi = mouseInfo.GetDpi();
}
if (lowQualityToggle != null) s.lowQuality = lowQualityToggle.isOn;
if (assistDropdown != null) s.assistMode = assistDropdown.value;
if (disableHorizontalToggle != null) s.disableHorizontalAssist = disableHorizontalToggle.isOn;
if (disableVerticalToggle != null) s.disableVerticalAssist = disableVerticalToggle.isOn;
+25 -5
View File
@@ -116,7 +116,7 @@ MouseTrail_<ID>_<yyyyMMdd_HHmmss>.zip
| `hit` | 命中一次(霰彈的每顆彈丸各記一次) |
| `kill` | 敵人倒下,回合結束 |
| `reload_start` | 開始換彈 |
| `pause` / `resume` | 暫停 / 繼續。按 Esc 或切出遊戲視窗(Alt+Tab 等)都會暫停。暫停期間 mouse 和 frames 不會有資料,`pause` 的時間是真正開始暫停的時間 |
| `pause` / `resume` | 暫停 / 繼續。按 Esc 或切出遊戲視窗(Alt+Tab 等)都會暫停。暫停期間 mouse 和 frames 不會有資料,`pause` 的時間是真正開始暫停的時間。v1.2.0 起暫停狀態在每一幀開頭決定,幀中途發生的暫停 / 繼續從下一幀才生效,所以每一幀的 mouse 加總都等於 frames 的 `mouse_dx`、`mouse_dy`(v1.1.0 在恢復的那一幀可能有 mouse 回報、但 frames 的位移是 0)。按 Esc 的那一幀仍會記錄,所以 `pause` 的時間不會早於最後一筆 frames 的 `t` |
| `prone_start` / `prone_end` | 開始趴下 / 結束趴下(站起或蹲起)。按 Z 切換。回合開始時已經趴著的話,會在 `round_start` 之後立刻補一筆 `prone_start`;回合結束時還趴著的話不會有 `prone_end` |
不記錄鍵盤按鍵(`prone_start` / `prone_end` 是姿勢改變的事件,不是按鍵事件)。玩家的移動用 `frames_N.csv` 的位置、速度和 `state` 表示,這是物理引擎實際算出的結果(包含加速度、滑鏟、空中轉向),比按鍵本身更能描述「畫面相對於玩家怎麼動」。
@@ -148,22 +148,33 @@ v1.1.0 新增:
|---|---|
| `autoPlan` | 是否為自動配置(正式錄製)。false = 自由模式,條件由玩家自己選 |
| `protocolVersion` | 錄製協定版本 |
| `buildId` | 出包時的 git commit 短碼,用來分辨同版號的不同 build。`-dirty` 表示出包時有未提交的改動,`editor` 表示在編輯器裡錄的 |
| `buildId` | 出包時的 git commit 短碼,用來分辨同版號的不同 build。`-dirty` 表示出包時有未提交的改動,`editor` 表示在編輯器裡錄的。v1.2.0 起出包時若 git 執行不了,會改讀 `.git` 檔案並加上 `-nogit`(無法確認工作區是否乾淨),都讀不到才是 `unknown`;正式發布的 build 應該是乾淨的 7 碼 |
| `sessionId` | 這次執行的代號(跟 zip 檔名的時間相同) |
| `planSeed` | 這次執行的排程種子 |
| `planIndex` | 排程中的第幾項:熱身 0–4,正式 5–84。自由模式為 -1 |
| `blockIndex`、`orderInBlock` | 區塊 0–7、區塊內第幾回合 0–9。熱身與自由模式為 -1 |
| `planIndex` | 排程中的第幾項:v1.1.0 熱身 0–4、正式 5–84;v1.2.0 熱身 0–2、正式 3–52。自由模式為 -1 |
| `blockIndex`、`orderInBlock` | 區塊(v1.1.0 為 0–7,v1.2.0 為 0–4)、區塊內第幾回合 0–9。熱身與自由模式為 -1 |
| `isWarmup` | 熱身回合,分析時請排除 |
| `assistFovDeg` | 作用範圍半徑(度),無輔助時為 0 |
| `roundSeed` | 這一回合的亂數種子:後座力、生成點、機器人動作、延遲抖動都由它開始。機器人動作與抖動的取用次數隨幀而變,所以只能近似重現 |
| `targetFps`、`vSyncCount` | 實際生效的幀率設定,`targetFps` 為 -1 表示不限制 |
v1.2.0 新增:
| 欄位 | 說明 |
|---|---|
| `mouseModel` | 滑鼠型號,玩家選填(最多 40 字),沒填為空字串 |
| `mouseDpi` | 滑鼠 DPI,玩家選填,範圍 100–50000,沒填或超出範圍為 0。回報率沒有欄位,請從 `mouse_N.csv` 的時間間隔計算 |
| `lowQuality` | StartUI 是否勾選「低畫質」(切到最低的畫質等級,只影響畫面,遊戲邏輯與遮擋判定不變) |
| `qualityLevel` | 這一回合實際的畫質等級名稱(`PC` 為預設、`Low` 為低畫質) |
| `warmupFps` | 熱身回合的平均 FPS(熱身的總幀數 ÷ 扣掉暫停的總遊玩秒數)。熱身還沒結束與自由模式為 -1。低於 55 時,遊戲會在第一個正式回合前提示玩家,但不擋錄製,分析時請自行標記 |
## 版本與資料階段
| 階段 | 版本 | 說明 |
|---|---|---|
| 第一階段(data_1) | `appVersion` 皆為 1.0.1 | 兩位玩家,**每人** 150 回合(無輔助 100、有輔助 50),125Hz 滑鼠,60Hz 螢幕,辨識延遲 15ms ± 5ms。先錄完有輔助(強度 20 → 100),再錄無輔助 |
| 第二階段起 | v1.1.0 | 自動配置,見下方「v1.1.0 錄製協定」 |
| 第二階段(data_2) | v1.1.0 | 自動配置,見下方「v1.1.0 錄製協定」 |
| 第三階段(data_3) | v1.2.0 | 與 v1.1.0 只差回合數,見下方「v1.2.0 錄製協定」 |
第一階段兩位玩家的差異:
@@ -184,6 +195,15 @@ v1.1.0 新增:
- 有輔助的回合準心是綠色、無輔助是白色,所以**玩家知道當下有沒有輔助**,但不知道強度。玩家可能因此調整瞄準方式,有無輔助的差異會同時包含輔助本身與玩家的反應。
- 回合存檔成功才進到下一項;中途回主畫面會重做同一項。關閉遊戲後再開是新的 session 與新的種子,不會接續。
### v1.2.0 錄製協定
與 v1.1.0 **只差回合數**,其他條件、輔助公式、區塊組成與洗牌方式、記錄格式都相同,可以和 v1.1.0 的資料直接合併:
- 熱身 3 回合(`planIndex` 0–2),接著 5 個區塊(`blockIndex` 0–4,`planIndex` 3–52),共 53 回合,約 6–12 分鐘。
- 新增的 config 欄位(`mouseModel`、`mouseDpi`、`lowQuality`、`qualityLevel`、`warmupFps`)見上方「v1.2.0 新增」。
- 暫停 / 繼續從下一幀才生效(見 `events_N.csv` 的 `pause` / `resume`);暫停期間不能開槍。
- 熱身平均 FPS 低於 55 時,第一個正式回合之前會跳提示(建議關掉其他程式或回主選單勾選低畫質,也可以直接繼續)。提示出現時沒有回合在進行,不會記成回合內的暫停。
## 模擬視覺模型
有輔助的回合中,輔助使用的敵人位置來自「模擬 AI 視覺模型」。它直接讀取敵人的骨架位置(完美感知器),只加上三個真實外掛本來就有的限制,**不做插值或預測**:
+6 -3
View File
@@ -8,7 +8,7 @@
本專案在 Unity 裡做了一個簡化的射擊靶場,讓貢獻者在「無輔助」與「模擬 AI 輔助」兩種情況下遊玩,記錄滑鼠的原始軌跡,作為分辨兩者的模型訓練資料。研究成果預計用於學術論文與開源的防護機制。
## 目前進度(v1.1.0)
## 目前進度(v1.2.0)
| 項目 | 狀態 |
|---|---|
@@ -62,7 +62,9 @@
## 設定說明
- **自動配置**:正式錄製用。勾選後由程式安排 85 回合的順序(有無輔助與強度在區塊內隨機),並固定地下室、Uzi、FOV 90 與 60 FPS,只需要填 ID 和靈敏度。有輔助的回合準心會變成綠色。協定見[資料集說明](Docs/Dataset.md#v110-錄製協定)。不勾選就是自由模式,可以自己選下面的所有設定。
- **自動配置**:正式錄製用。勾選後由程式安排 53 回合的順序(熱身 3 回合,之後 5 個區塊,有無輔助與強度在區塊內隨機),並固定地下室、Uzi、FOV 90 與 60 FPS,只需要填 ID 和靈敏度。有輔助的回合準心會變成綠色。熱身的平均 FPS 低於 55 時,第一個正式回合前會提示(不擋錄製)。協定見[資料集說明](Docs/Dataset.md#v120-錄製協定),與 v1.1.0 只差回合數。不勾選就是自由模式,可以自己選下面的所有設定。
- **滑鼠型號與 DPI**:選填,不知道可以留白。回報率由資料端從原始回報計算,不用填。
- **低畫質**:切到最低的畫質等級,只影響畫面(遊戲邏輯與遮擋判定不變),FPS 達不到 60 時使用。
- **靈敏度**:與 Apex Legends 相同的換算(滑鼠每移動 1 單位 = 0.022° × 靈敏度),可以直接填你平常在 Apex 用的數值。
- **FOV**:與 Apex 的定義相同,以 4:3 畫面為基準的水平 FOV,支援任意解析度與比例。
- **輔助方式**:
@@ -176,7 +178,8 @@ Assets/
├─ ApexMovementRules.cs 把 MotionCore 的移動調成 Apex 手感 (只有 W 自動奔跑、落地接滑鏟)
├─ EnemyIndicator.cs 敵人方位箭頭
├─ EnemyHealthBar.cs 敵人血條
├─ PauseMenu.cs 暫停選單 (Esc、切出視窗)
├─ PauseMenu.cs 暫停選單 (Esc、切出視窗) ; 暫停狀態每幀開頭鎖存,同一幀所有腳本看到的一樣
├─ FpsWarning.cs 熱身平均 FPS 太低時的提示 (不擋錄製)
├─ Weapon/ 武器數值、開火與命中判定、HUD、彈道線
├─ Bot/ 機器人 AI、血量、命中框、生成器
├─ Assist/ 模擬視覺模型 (EnemyPerceptor)、平滑跟槍 (AimAssist)
+1 -1
View File
@@ -148,7 +148,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 1.1.0
bundleVersion: 1.2.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
+2 -3
View File
@@ -7,7 +7,7 @@ QualitySettings:
m_CurrentQuality: 1
m_QualitySettings:
- serializedVersion: 4
name: Mobile
name: Low
pixelLightCount: 2
shadows: 2
shadowResolution: 1
@@ -58,8 +58,7 @@ QualitySettings:
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms:
- Standalone
excludedTargetPlatforms: []
- serializedVersion: 4
name: PC
pixelLightCount: 2
+4 -4
View File
@@ -4,13 +4,13 @@
![StartUI 畫面](png/001.png)
> 目前版本 **v1.1.0**(Windows),正在收集資料中。武器、地圖、各項設定與專案結構的詳細說明請看 **[完整說明(Full_README.md)](Full_README.md)**。
> 目前版本 **v1.2.0**(Windows),正在收集資料中。武器、地圖、各項設定與專案結構的詳細說明請看 **[完整說明(Full_README.md)](Full_README.md)**。
## 給貢獻者
1. 下載並解壓縮後執行 `MouseTrailCollector.exe`。若跳出「Windows 已保護您的電腦」,按「**其他資訊 → 仍要執行**」(程式沒有數位簽章,原始碼都在這個 repo)。
2. 閱讀右側資訊並勾選同意書,填好 ID 與靈敏度,確認「**自動配置**」有勾選,按「**開始**」直接進入遊戲。
3. 每打倒一隻敵人會自動存一回合,畫面會顯示進度,全部共 85 回合(預估 13–19 分鐘)。有無輔助由程式隨機安排,**準心是綠色**代表這一回合有輔助。請一次打完,關閉遊戲後再開會重新開始。
2. 閱讀右側資訊並勾選同意書,填好 ID 與靈敏度(滑鼠型號與 DPI 選填,不知道可以留白),確認「**自動配置**」有勾選,按「**開始**」直接進入遊戲。電腦比較吃力的話可以勾「**低畫質**」。
3. 每打倒一隻敵人會自動存一回合,畫面會顯示進度,全部共 53 回合(預估 6–12 分鐘)。有無輔助由程式隨機安排,**準心是綠色**代表這一回合有輔助。請一次打完,關閉遊戲後再開會重新開始。
4. 畫面顯示完成後**直接關閉遊戲**,把桌面上的 `MouseTrail_<ID>_<日期時間>.zip` 傳到 Discord 就完成了。
| 按鍵 | 動作 |
@@ -20,7 +20,7 @@
| Space / Left Shift / Z | 跳躍 / 蹲下、滑鏟 / 趴下 |
| Esc | 暫停(切出遊戲視窗也會自動暫停) |
**隱私**:只在遊戲回合中記錄滑鼠移動、開槍命中、雙方的位置與 StartUI 上的設定,不記錄鍵盤按鍵與遊戲外的任何操作。資料只存在你的電腦,不會自動上傳;zip 可以先打開確認內容。想撤回資料請在 Discord 聯絡我們。
**隱私**:只在遊戲回合中記錄滑鼠移動、開槍命中、雙方的位置與 StartUI 上的設定(包含選填的滑鼠型號與 DPI),不記錄鍵盤按鍵與遊戲外的任何操作。資料只存在你的電腦,不會自動上傳;zip 可以先打開確認內容。想撤回資料請在 Discord 聯絡我們。
## 資料
+179
View File
@@ -0,0 +1,179 @@
# MouseTrailCollector v1.2.0 修改需求
狀態:待檢查,尚未實作。由資料端(MouseTrailDataset)對 phase 2 資料的分析結果推出。
標記:【必】影響資料有效性或收件,【建議】值得做,【選】有空再做。
檢查者:程式現況是 2026-12-03 讀 `main`(c3bb8d1,程式碼與凍結版 801dbad 相同)得到的,沒有在 Unity 執行過。請逐條對照程式碼確認後再動手。
## 1. 背景與已定事項
- v1.1.0 的錄製協定沒有問題。phase 2(3 人、4 份錄製)已分析完,交錯錄製確實解決了錄製順序的問題。
- 現在的弱點都在「換人」和「換滑鼠」,所以 phase 3 要找十幾個人來錄。**這是最後一輪,沒有重錄的機會**。
- 因此 v1.2.0 的原則是:**只做必要的小修,不碰會影響資料內容的東西**,讓 phase 3 的資料可以和 phase 2 直接合併。
- 已決定不做(請不要順手加):
- 不解鎖 FPS,維持 60(控制實驗變量)。
- 不把「修正量拆到滑鼠回報上」內建進遊戲。分析端實驗過,各種拆法的偵測率幾乎相同,一律離線合成。
- 不加新的外掛種類、不加 SendInput、不加新的實驗變數。
## 2. 資料缺什麼 → 系統要改什麼
| # | 資料的問題(證據) | 需要的修改 |
|---|---|---|
| D1 | 人數太少(3 人),跨玩家結果每個方向只有一個人。要找十幾人,每人不能錄太久。phase 2 的 80 個正式回合花了 7–16 分鐘 | R1 |
| D2 | people_1 的 `buildId` 是 `unknown`:那次出包時 Unity 執行不了 git。結果同一輪資料出自兩個不同的 exe,其中一個無法確認版本 | R2、第 7 節 |
| D3 | people_4 第 38 回合,暫停後恢復的那一幀:`mouse_38.csv` 有 15 筆回報屬於該幀,但 `frames_38.csv` 該幀的 `mouse_dx`、`mouse_dy` 是 0 | R3 |
| D4 | people_1 的實際 FPS 只有 37–45(目標 60),錄完才發現。FPS 不同會讓跨玩家結果變差(分析端有直接證據) | R4 |
| D5 | 滑鼠型號和 DPI 沒有記錄,事後很難補。換滑鼠回報率是目前最明顯的弱點之一 | R5 |
## 3. 錄製協定(v1.2.0)
和 v1.1.0 只差回合數:
- 熱身 **3** 回合(原本 5):無輔助,`isWarmup = true`。
- 正式 **5** 區塊(原本 8)× 10 回合 = 50 回合。區塊組成不變:無輔助 5、強度 20/40/60/80/100 各 1,區塊內隨機排序。
- 共 **53** 回合,預估 6–12 分鐘。
- 其他全部不變:地下室、Uzi、FOV 90、作用範圍 15°、辨識延遲 15 ± 5 ms、目標 60 FPS、有輔助時準心變綠、靈敏度自選。
## 4. 修改項目
### R1【必】回合數:`Assets/Stript/Common/SessionPlan.cs`
- `WarmupRounds` 5 → 3。
- `Blocks` 8 → 5。`Total` 會自動變成 53。
- `ProtocolVersion` 改成 `"1.2.0"`。
- 區塊的組成(`NoAssistPerBlock`、`Strengths`)和 `Generate()` 的邏輯**不要動**。
- 把寫死回合數的文字和註解一起改掉。我看到的有:
- `SessionPlan.cs` 與 `RoundConfig.cs` 的註解(熱身 0~4、正式 5~84、區塊 0~7)。
- `DatasetReadme.cs` 第 157 行(`planIndex` 的說明)、第 184 行(協定說明)。
- `README.md` 第 13 行(「全部共 85 回合(預估 13–19 分鐘)」)。
- `Full_README.md` 第 65 行(「安排 85 回合」)。
- `Docs/Dataset.md` 的 v1.1.0 錄製協定段落(請自行確認,我沒有讀這個檔)。
- 畫面上的進度文字用的是 `Total`,應該不用改,請確認。
### R2【必】`buildId` 的後備讀法:`Assets/Stript/Editor/BuildIdWriter.cs`
現在 `Git()` 失敗就直接寫 `unknown`。改成:
- git 執行失敗時,改讀檔案取得 commit:
- 讀 `.git/HEAD`。內容是 `ref: refs/heads/<分支>` 時,再讀 `.git/refs/heads/<分支>`;該檔不存在就到 `.git/packed-refs` 找同一個 ref。
- 內容直接是 40 碼雜湊時(detached HEAD)就用它。
- 取前 7 碼。
- 用後備讀法時無法判斷工作區乾不乾淨,請在後面加 `-nogit`(例如 `a1b2c3d-nogit`),並在 Console 印出警告。
- 連檔案都讀不到才寫 `unknown`。
- 正式出包的 `buildId` 應該是乾淨的 7 碼。出現 `-dirty`、`-nogit`、`unknown` 都代表這個 exe 不該發出去(見第 7 節)。
### R3【必】暫停與恢復那一幀要一致
現況(請對照程式碼確認我的理解):
- `PlayerLook.Update()` 在暫停時把滑鼠位移當成 0(第 97 行),`LastMouseDelta` 也是 0。
- `PauseMenu.Update()` 處理 Esc,沒有指定執行順序。`Resume()` 也可能由按鈕觸發。
- `RoundRecorder.LateUpdate()`(順序 100)在幀尾才讀 `PauseMenu.IsPaused`,不是暫停就寫入這一幀的滑鼠回報和幀狀態。
所以同一幀裡,暫停狀態在 `PlayerLook` 讀過之後改變,就會不一致:
- **恢復的那一幀**:`PlayerLook` 看到「暫停中」沒套用滑鼠,之後才恢復;記錄器看到「沒暫停」就把這一幀的回報寫進 `mouse`,但 `frames` 的 `mouse_dx/dy` 是 0。這就是 D3。
- **暫停的那一幀**(反方向,資料端查不出來):`PlayerLook` 已經套用滑鼠轉了視角,之後才暫停;記錄器看到「暫停中」整幀不寫。視角動了但沒有任何紀錄。
- 切出視窗(`OnApplicationFocus`)也會觸發暫停,時機同樣不固定。
需求:**一幀之內,所有模組看到的暫停狀態必須相同**。做法由你決定,例如:
- 每幀開頭(比 `PlayerLook` 早)把暫停狀態鎖存成「這一幀是否暫停」,`PlayerLook`、`AimAssist`、`EnemyPerceptor`、`RoundRecorder` 都讀這個值;幀中途發生的暫停或恢復,從下一幀才生效。
- 或者讓記錄器以「`PlayerLook` 這一幀有沒有套用輸入」為準來決定寫不寫。
驗收條件:
- 任何一幀,`mouse_N.csv` 依 `frame` 加總都等於 `frames_N.csv` 的 `mouse_dx`、`mouse_dy`,包含暫停前後的幀。
- 有寫進 `frames` 的幀,視角的變化等於該幀的滑鼠位移加輔助位移(換算角度)加後座力變化;暫停前後不會出現「視角變了但沒有對應位移」的跳動。
- 暫停期間收到的滑鼠回報不套用、不記錄(和現在一樣)。
- `pausedSeconds`、`pause` / `resume` 事件維持原本的定義。
請實際測:回合中按 Esc 暫停再恢復、按鈕恢復、Alt+Tab 切出再切回,各做幾次,邊移動滑鼠邊做。
### R4【必】熱身時檢查 FPS
- 熱身回合期間量平均 FPS:熱身回合的總幀數 ÷ 總遊玩秒數(扣掉暫停)。
- 熱身最後一回合存檔後、第一個正式回合的機器人生成**之前**判斷:
- 平均 FPS ≥ 55:不顯示任何東西,直接繼續。
- 平均 FPS < 55:顯示提示,內容大意是「目前平均 FPS 是 X,目標是 60。建議關掉其他程式,或回主選單開啟低畫質。也可以直接繼續。」提供「繼續」和「回主選單」兩個按鈕。
- **不要擋住不給錄**。有些人的電腦就是跑不動,照樣收,分析時會標記。
- 提示出現時不能有回合在進行(不要吃到正式回合的時間,也不要被記成回合內的暫停)。
- 回主選單後再進來,排程進度照舊接續(現在就是這樣),熱身不用重做。
- config 新增兩個欄位(放 `RoundConfig`):
- `warmupFps`(float):熱身量到的平均 FPS。熱身還沒結束時為 -1。自由模式為 -1。
- `qualityLevel`(string):這一回合的畫質等級名稱,`QualitySettings.names[QualitySettings.GetQualityLevel()]`。
- 【建議】StartUI 加一個「低畫質」勾選(存進 `GameSettings`,例如 `lowQuality`),勾了就 `QualitySettings.SetQualityLevel` 到最低等級。套用後請確認 `vSyncCount` 仍是 0、`targetFrameRate` 仍是 60(`SessionPlan.ApplyFrameRate` 要在切換畫質**之後**呼叫,因為切換畫質等級會改掉 vSync 設定)。
- 低畫質只能影響畫面,**不能改變遊戲邏輯**:機器人行為、命中判定、感知器的遮擋判定(射線)都不能受影響。請確認遮擋判定用的是碰撞體而不是畫面。
### R5【必】滑鼠型號與 DPI(選填)
- `GameSettings` 新增兩個欄位。因為 `RoundConfig` 繼承 `GameSettings`,會自動寫進每回合的 config:
- `mouseModel`(string,預設空字串)
- `mouseDpi`(int,預設 0 代表沒填)
- **欄位名稱請照這兩個**,資料端的收件腳本是找這兩個名字。
- StartUI 加兩個輸入欄,標明「選填,不知道可以留白」。不填也能開始。
- 型號:限制長度(例如 40 字)。
- DPI:只收數字,合理範圍 100–50000,超出就當沒填。
- 比照 v1.1.0 對 ID 和靈敏度的做法,下次開啟時回填上次的值。
- 回報率不用填,資料端可以從 `mouse_N.csv` 算出來。
- `DatasetReadme.cs` 的欄位說明要加這兩欄和 R4 的兩欄。資訊頁(同意書前的說明)若有列出記錄內容,請補上「滑鼠型號與 DPI(選填)」。
### R6【必】版本與文件
- `ProjectSettings/ProjectSettings.asset` 的 `bundleVersion` 改成 `1.2.0`。
- `README.md`:回合數與預估時間(53 回合、約 6–12 分鐘)。
- `Full_README.md`、`Docs/Dataset.md`:補 v1.2.0 的協定與新欄位,寫明與 v1.1.0 的差別只有回合數。
- 出包的 commit 打 tag `1.2.0`。
### R7【選】清掉場景裡的殘留覆寫
Basement、Desert、Forest、Test 四個場景還留有已刪除欄位 `minFov`、`maxFov` 的覆寫。Unity 會忽略,不影響資料。有空再清。
## 5. 不要改的部分
改了就不能和 phase 2 合併,等於 phase 2 的資料作廢:
- `RawMouseInput` 的擷取與時間戳。
- `frames_N.csv`、`mouse_N.csv`、`events_N.csv` 的欄位與順序。
- 輔助公式、作用範圍 15°、強度 20/40/60/80/100、區塊內的組成與洗牌方式。
- 感知器:自動配置下每幀取樣、延遲 15 ± 5 ms、可見比例 75% 的遮擋規則。
- 有輔助時準心變綠(`CrosshairAssistColor`),強度仍不顯示。
- 地下室、Uzi、FOV 90、目標 60 FPS、`vSyncCount = 0`。
- 機器人行為、每回合種子的用法。
- config 既有欄位的名稱與意義(只能新增,不能改名或刪除)。
- 貢獻者 ID 維持選填。沒填的由資料端收件時自動編號。
## 6. 驗收(資料端會做)
實作完成後,請用**正式出包的 exe**(不是編輯器)自己完整錄一份,把 zip 交給資料端。資料端會跑:
```
python phase_3/scripts_3/ingest.py <zip> --dry-run
```
要通過的項目:
1. `appVersion` 與 `protocolVersion` 都是 `1.2.0`;`buildId` 是乾淨的 7 碼,等於 tag `1.2.0` 的 commit。
2. 共 53 回合:熱身 3(`planIndex` 0–2),正式 50(`planIndex` 3–52,`blockIndex` 0–4);與 `plan.csv` 逐項一致。
3. 5 個區塊各為無輔助 5 回合、強度 20/40/60/80/100 各 1 回合。
4. 無輔助回合的 `assist_dx`、`assist_dy`、`assist_engaged`、`assist_fov` 全為 0;有輔助回合的 `assist_fov` 全為 15。
5. **所有幀**的 `mouse` 加總等於 `frames` 的 `mouse_dx`、`mouse_dy`。試錄時請故意在回合中暫停、恢復、Alt+Tab 幾次(R3)。
6. 地圖、武器、FOV、延遲、`targetFps`、`autoPlan` 都是協定值;實際平均 FPS 約 60。
7. 滑鼠時間戳沒有批次現象(間隔 < 0.01 ms 的比例約 0)。
8. config 有 `mouseModel`、`mouseDpi`、`warmupFps`、`qualityLevel`;有填的值正確,沒填的是空字串與 0。
9. 與 v1.1.0 的資料比較:除了回合數與新欄位,其他欄位的定義與數值範圍相同。
另外請回報(資料驗不出來的):
- R4 的提示有沒有實際看過。可以暫時把門檻調高來觸發,測完改回 55。
- 低畫質開關前後,FPS 與 `vSyncCount`、`targetFps` 的值。
## 7. 發布流程
phase 2 出現過兩個不同的 exe,這次請照以下順序,**全員(包含我們自己)只用同一個檔**:
1. 所有改動 commit,工作區乾淨。
2. 在 **git 可以正常執行**的機器上出包。Console 會印出 `BuildIdWriter : buildId = xxxxxxx`,確認是乾淨的 7 碼。
3. 執行出包的 exe,隨便打一回合後關閉,打開 zip 裡的 `config_1.json`,確認 `buildId` 等於目前的 commit、`appVersion` 是 `1.2.0`。
4. 對該 commit 打 tag `1.2.0`,把這個 exe 壓縮後上傳到 release。
5. 自己從 release 下載、完整錄一份,交給資料端驗收(第 6 節)。
6. 驗收通過後才把 release 連結發給其他人。之後不要再重新出包;真的要改,就升版號並重新驗收。