Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7904986442 | ||
|
|
fd0312270b | ||
|
|
c3bb8d1a9e | ||
|
|
b75cfc1e4a |
No files matched your search
+1211
-10
File diff suppressed because it is too large.
Load diff
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
+1465
-14
File diff suppressed because it is too large.
Load diff
@@ -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:
|
||||
|
||||
@@ -100,24 +100,24 @@ MonoBehaviour:
|
||||
m_Keys: []
|
||||
m_Values:
|
||||
m_PrefilteringModeMainLightShadows: 3
|
||||
m_PrefilteringModeAdditionalLight: 4
|
||||
m_PrefilteringModeAdditionalLight: 3
|
||||
m_PrefilteringModeAdditionalLightShadows: 0
|
||||
m_PrefilterXRKeywords: 1
|
||||
m_PrefilteringModeForwardPlus: 1
|
||||
m_PrefilteringModeForwardPlus: 0
|
||||
m_PrefilteringModeDeferredRendering: 0
|
||||
m_PrefilteringModeScreenSpaceOcclusion: 0
|
||||
m_PrefilterDebugKeywords: 1
|
||||
m_PrefilterWriteRenderingLayers: 1
|
||||
m_PrefilterHDROutput: 1
|
||||
m_PrefilterAlphaOutput: 0
|
||||
m_PrefilterAlphaOutput: 1
|
||||
m_PrefilterSSAODepthNormals: 1
|
||||
m_PrefilterSSAOSourceDepthLow: 1
|
||||
m_PrefilterSSAOSourceDepthMedium: 0
|
||||
m_PrefilterSSAOSourceDepthMedium: 1
|
||||
m_PrefilterSSAOSourceDepthHigh: 1
|
||||
m_PrefilterSSAOInterleaved: 0
|
||||
m_PrefilterSSAOInterleaved: 1
|
||||
m_PrefilterSSAOBlueNoise: 1
|
||||
m_PrefilterSSAOSampleCountLow: 1
|
||||
m_PrefilterSSAOSampleCountMedium: 0
|
||||
m_PrefilterSSAOSampleCountMedium: 1
|
||||
m_PrefilterSSAOSampleCountHigh: 1
|
||||
m_PrefilterDBufferMRT1: 1
|
||||
m_PrefilterDBufferMRT2: 1
|
||||
@@ -127,15 +127,15 @@ MonoBehaviour:
|
||||
m_PrefilterSoftShadowsQualityHigh: 1
|
||||
m_PrefilterSoftShadows: 0
|
||||
m_PrefilterScreenCoord: 1
|
||||
m_PrefilterScreenSpaceIrradiance: 0
|
||||
m_PrefilterScreenSpaceIrradiance: 1
|
||||
m_PrefilterNativeRenderPass: 1
|
||||
m_PrefilterUseLegacyLightmaps: 0
|
||||
m_PrefilterBicubicLightmapSampling: 0
|
||||
m_PrefilterReflectionProbeRotation: 0
|
||||
m_PrefilterBicubicLightmapSampling: 1
|
||||
m_PrefilterReflectionProbeRotation: 1
|
||||
m_PrefilterReflectionProbeBlending: 0
|
||||
m_PrefilterReflectionProbeBoxProjection: 0
|
||||
m_PrefilterReflectionProbeAtlas: 0
|
||||
m_PrefilterPointSamplingUpsampling: 0
|
||||
m_PrefilterReflectionProbeAtlas: 1
|
||||
m_PrefilterPointSamplingUpsampling: 1
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
m_Textures:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a00a586eeeb99241b2b77f6cdd35837
|
||||
@@ -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;
|
||||
|
||||
@@ -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.2.1 | 與 v1.1.0 只差回合數,見下方「v1.2.0 錄製協定」。v1.2.1 只改介面文字,`protocolVersion` 仍是 1.2.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 視覺模型」。它直接讀取敵人的骨架位置(完美感知器),只加上三個真實外掛本來就有的限制,**不做插值或預測**:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
// 遊戲中顯示目前回合進度 (自動配置 : 第 n / 85 回合,不顯示條件 ; 自由模式 : 已記錄幾回合 ; 測試模式不顯示)
|
||||
// 遊戲中顯示目前回合進度 (自動配置 : 第 n / 總回合數,不顯示條件 ; 自由模式 : 已記錄幾回合 ; 測試模式不顯示)
|
||||
// 掛在 PlayerRig,Text 放在 HUD 上
|
||||
public class RoundProgressHUD : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+25
-5
@@ -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.2.1 | 與 v1.1.0 只差回合數,見下方「v1.2.0 錄製協定」。v1.2.1 只改介面文字,`protocolVersion` 仍是 1.2.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 視覺模型」。它直接讀取敵人的骨架位置(完美感知器),只加上三個真實外掛本來就有的限制,**不做插值或預測**:
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
1. 更改右下角網址到gitea
|
||||
2. 本地保存上次的設置情況 contributorID, sensitivity之類的 每次手動輸入有點煩
|
||||
3.
|
||||
4. 遊戲內顯示目前回合數
|
||||
5. startui顯示累計回合數下面新增一鍵清除本地本地資料
|
||||
6. sensitivity設定1.4時config紀錄1.399999976158142 看能不能改善
|
||||
+9
-6
@@ -8,7 +8,7 @@
|
||||
|
||||
本專案在 Unity 裡做了一個簡化的射擊靶場,讓貢獻者在「無輔助」與「模擬 AI 輔助」兩種情況下遊玩,記錄滑鼠的原始軌跡,作為分辨兩者的模型訓練資料。研究成果預計用於學術論文與開源的防護機制。
|
||||
|
||||
## 目前進度(v1.1.0)
|
||||
## 目前進度(v1.2.1)
|
||||
|
||||
| 項目 | 狀態 |
|
||||
|---|---|
|
||||
@@ -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)
|
||||
@@ -196,7 +199,7 @@ Docs/
|
||||
### 資料位置
|
||||
|
||||
```
|
||||
%USERPROFILE%/AppData/LocalLow/Sthkm3/MouseTrailCollector/
|
||||
%USERPROFILE%/AppData/LocalLow/Sahik/MouseTrailCollector/
|
||||
├─ settings.json StartUI 最後一次存的設定
|
||||
└─ Sessions/<開始時間>/ 每次執行的原始資料,打包過的資料夾裡會有 packed.txt
|
||||
```
|
||||
@@ -226,5 +229,5 @@ Docs/
|
||||
|
||||
## 相關連結
|
||||
|
||||
- GitHub:<https://github.com/Sthkm3/MouseTrailCollector>
|
||||
- 個人網站:<https://sthkm3.org>
|
||||
- GitHub:<https://github.com/sahik-dev/MouseTrailCollector>
|
||||
- 個人網站:<https://sahik.dev>
|
||||
@@ -34,3 +34,37 @@ MonoBehaviour:
|
||||
- Key: SpriteAtlasEmptySpaceLimit
|
||||
Value: 50
|
||||
CurrentParamsIndex: 0
|
||||
--- !u!114 &2
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 53
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEditor.ProjectAuditorModule:Unity.ProjectAuditor.Editor:ProjectAuditorSettings
|
||||
Rules:
|
||||
rules: []
|
||||
DiagnosticParams:
|
||||
paramsStack:
|
||||
- PlatformGroup:
|
||||
m_String: Unknown
|
||||
m_SerializedParams:
|
||||
- Key: StreamingClipThresholdBytes
|
||||
Value: 218294
|
||||
- Key: LongDecompressedClipThresholdBytes
|
||||
Value: 204800
|
||||
- Key: LongCompressedMobileClipThresholdBytes
|
||||
Value: 204800
|
||||
- Key: LoadInBackGroundClipSizeThresholdBytes
|
||||
Value: 204800
|
||||
- Key: StreamingAssetsFolderSizeLimit
|
||||
Value: 50
|
||||
- Key: TextureStreamingMipmapsSizeLimit
|
||||
Value: 4000
|
||||
- Key: SpriteAtlasEmptySpaceLimit
|
||||
Value: 50
|
||||
CurrentParamsIndex: 0
|
||||
@@ -12,7 +12,7 @@ PlayerSettings:
|
||||
targetDevice: 2
|
||||
useOnDemandResources: 0
|
||||
accelerometerFrequency: 60
|
||||
companyName: Sthkm3
|
||||
companyName: Sahik
|
||||
productName: MouseTrailCollector
|
||||
defaultCursor: {fileID: 0}
|
||||
cursorHotspot: {x: 0, y: 0}
|
||||
@@ -148,7 +148,7 @@ PlayerSettings:
|
||||
loadStoreDebugModeEnabled: 0
|
||||
visionOSBundleVersion: 1.0
|
||||
tvOSBundleVersion: 1.0
|
||||
bundleVersion: 1.1.0
|
||||
bundleVersion: 1.2.1
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
||||
@@ -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,13 +4,13 @@
|
||||
|
||||

|
||||
|
||||
> 目前版本 **v1.1.0**(Windows),正在收集資料中。武器、地圖、各項設定與專案結構的詳細說明請看 **[完整說明(Full_README.md)](Full_README.md)**。
|
||||
> 目前版本 **v1.2.1**(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 聯絡我們。
|
||||
|
||||
## 資料
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
- 修改記錄的欄位時,請同步更新 `Docs/Dataset.md` 與 `Record/DatasetReadme.cs`(打包進 zip 的那一份)。
|
||||
- 出包前先 commit 所有改動,`Editor/BuildIdWriter.cs` 會把 commit 短碼寫進 config 的 `buildId`(工作區不乾淨會加 `-dirty`);tag 要打在實際出包的那個 commit。
|
||||
- 正式錄製的協定常數都在 `Common/SessionPlan.cs`。
|
||||
- 資料位置:`%USERPROFILE%/AppData/LocalLow/Sthkm3/MouseTrailCollector/`。
|
||||
- 資料位置:`%USERPROFILE%/AppData/LocalLow/Sahik/MouseTrailCollector/`。
|
||||
- 角色移動使用 MotionCore,其中幾個檔案為了 Apex 手感做了修改,改動處都標有 `[Mouse Trail Collector 修改]`(`IdleState.cs`、`PlayerController.Stance.cs`、`PlayerSlideState.cs`、`Controls.inputactions`),更新 MotionCore 時請補回。
|
||||
|
||||
## 第三方素材
|
||||
@@ -51,4 +51,4 @@ MotionCore – Physics Character Controller、Low Poly Weapons VOL.1、Lite Rifl
|
||||
|
||||
## 連結
|
||||
|
||||
GitHub:<https://github.com/Sthkm3/MouseTrailCollector> ・ 個人網站:<https://sthkm3.org>
|
||||
GitHub:<https://github.com/sahik-dev/MouseTrailCollector> ・ 個人網站:<https://sahik.dev>
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 543 KiB |
@@ -1,131 +0,0 @@
|
||||
# MouseTrailCollector v1.1.0 修改需求
|
||||
|
||||
狀態:待二次檢查,尚未實作。由資料端(MouseTrailDataset)的檢查結果推出。
|
||||
標記:【必】影響資料有效性,【建議】值得做,【選】有空再做。
|
||||
檢查者:程式現況是 2026-11-25 讀 `main`(2638c59)得到的,沒有在 Unity 執行過,請逐條對照程式碼確認後再動手。
|
||||
|
||||
## 1. 背景與已定事項
|
||||
- 書審已過。委員主要意見:有輔助與無輔助的錄製順序和標籤完全重合、只有 2 位玩家、沒用未參與訓練的玩家測試。
|
||||
- 兩位組員用新版重錄第一階段,再加 4 位玩家錄第二階段,共 6 人,全部用**同一個 build**,資料直接用於終審報告。
|
||||
- 每人 20 分鐘內,有輔助與無輔助**交錯錄製**。
|
||||
- **不加新的外掛種類**(列未來展望),不加新的實驗變數。
|
||||
|
||||
## 2. 資料缺什麼 → 系統要改什麼
|
||||
|
||||
| # | 資料的問題(證據) | 需要的修改 |
|
||||
|---|---|---|
|
||||
| D1 | 兩人都先錄約 50 回合有輔助(強度 20→100),再錄 100 回合無輔助。只用無輔助資料分前後 50 回合,含時間特徵時回合 AUC 達 0.77(不含為 0.57–0.58) | R1、R2 |
|
||||
| D2 | 強度由低到高錄,強度與練習、疲勞無法分開 | R1 |
|
||||
| D3 | 兩人 config 的 `appVersion` 都是 1.0.1,但實錄 `assist_fov`:玩家 1 固定 15°;玩家 2 隨強度 20/40/60/80/100 為 10/15/20/25/30° | R3、R4 |
|
||||
| D4 | 武器、地圖、靈敏度都綁在玩家身上(Uzi+Basement+1.2;AK74+Forest+7.0) | R5 |
|
||||
| D5 | 平均幀率,玩家 1 約 60、玩家 2 約 63–65,螢幕都是 60 Hz;幀間隔是可被模型學到的非輔助差異 | R6 |
|
||||
| D6 | 每回合獨立,沒有區塊、順序、熱身欄位,無法以區塊切分或控制順序 | R3 |
|
||||
| D7 | 靈敏度 1.4 在 config 存成 1.399999976158142 | R9 |
|
||||
|
||||
## 3. 錄製協定(v1.1.0)
|
||||
- 熱身 5 回合:無輔助,照常存檔但標 `isWarmup = true`,分析時排除。
|
||||
- 正式 8 區塊 × 10 回合 = 80 回合。每區塊:無輔助 5、強度 20/40/60/80/100 各 1,區塊內隨機排序。
|
||||
- 預估:依第一階段回合時間(玩家 1 無輔助約 9 秒、玩家 2 約 14.5 秒;有輔助約 4–12 秒)加重生 1.5 秒,85 回合約 13–19 分鐘。試錄超時就改成 7 區塊,**在凍結 build 之前決定**。
|
||||
- 辨識延遲 15 ± 5 ms、作用範圍 15°,全員固定。
|
||||
- 玩家看不到當下的強度(仍可能感覺得到,報告列為限制)。
|
||||
|
||||
## 4. 修改項目
|
||||
|
||||
### R1【必】自動排程:新增 `Assets/Stript/Common/SessionPlan.cs`
|
||||
現在換強度必須回主選單,`AimAssist`、`EnemyPerceptor` 只在 `Start()` 讀一次設定。只靠口頭交代玩家交錯,容易漏錄或錄錯,而且回主選單的操作本身會與換條件綁在一起。
|
||||
- 以種子產生整份順序;種子與順序一併存檔。
|
||||
- 進度放在跨場景的靜態狀態;**回合存檔成功才前進**,中途離開、回主選單則重做同一條件。
|
||||
- 做完 85 回合後 `BotSpawner` 不再生成,顯示「完成,請關閉遊戲」。
|
||||
- 編輯器關閉 Domain Reload 時要重設靜態狀態,比照 `SessionStorage.Init()` 的做法。
|
||||
- 當機後重開:開新的 session 與新種子,不接續;舊回合沿用現有 `recovered/`。
|
||||
|
||||
### R2【必】每回合套用條件
|
||||
- `BotSpawner.Spawn()`:觸發 `BotSpawned` **之前**,取出這回合條件並套用到 `AimAssist`、`EnemyPerceptor`。
|
||||
- `AimAssist`:抽出 `Apply(條件)`,重設 `mode`、`strength`、`remainingError`、`lastSampleTime`、`FovRadius`。
|
||||
- `EnemyPerceptor`:套用延遲與抖動;清空 `pending`、`Output`。無輔助回合目前延遲設 0,新版建議兩類都用 15 ± 5 ms,讓 `out_*` 定義一致。
|
||||
- `PlayerLook`:清空 `pendingAssistDelta`,避免上一回合殘留。
|
||||
- 注意 `Start()` 順序:第一隻機器人在 `BotSpawner.Start()` 就生成,此時 `AimAssist.Start()`/`EnemyPerceptor.Start()` 可能還沒跑,之後又覆蓋掉條件。把「讀設定」改成不覆蓋排程條件。
|
||||
- 順手確認:`AimAssist` 與 `PlayerLook` 都在 `Update`,且沒有看到 `DefaultExecutionOrder`。修正量是當幀還是下一幀套用並不固定,請明確指定順序(報告第 3.6.2 節寫的是當幀套用)。
|
||||
- 確認暫停時(timeScale = 0)不會累積修正量。
|
||||
|
||||
### R3【必】config 新欄位:`RoundConfig`
|
||||
`Create()` 現在整份複製 `GameSettings.Load()`,回合條件必須改由排程覆寫 `assistMode`、`assistStrength`、`assistDelayMs`、`assistDelayJitterMs`。新增:
|
||||
|
||||
| 欄位 | 說明 |
|
||||
|---|---|
|
||||
| `protocolVersion` | 協定版本,`"1.1.0"` |
|
||||
| `buildId` | git commit 短碼,出包時寫入,**用來分辨同版號的不同 build**(D3) |
|
||||
| `sessionId`、`planSeed` | 這次執行的代號、排程種子 |
|
||||
| `planIndex` | 排程中的第幾項(熱身 0–4,正式 5–84) |
|
||||
| `blockIndex`、`orderInBlock` | 區塊 0–7、區塊內 0–9;熱身為 -1 |
|
||||
| `isWarmup` | 是否熱身 |
|
||||
| `assistFovDeg` | 固定 15 |
|
||||
| `targetFps`、`vSyncCount` | 實際生效的幀率設定 |
|
||||
|
||||
既有欄位名稱與意義不變,資料端腳本仍讀得到。`frames` 的 `assist_fov` 在無輔助回合維持 0。
|
||||
|
||||
### R4【必】作用範圍改成單一來源
|
||||
`AimAssist` 的 `minFov`/`maxFov` 可被 prefab 與場景覆寫:程式預設 3/15,`PlayerRig.prefab` 與四個場景目前覆寫成 15/15。這是 D3 同版號卻不同行為的可能原因,未證實。
|
||||
- 改為一個常數 15°,刪除兩個可編輯欄位與場景中的殘留覆寫。
|
||||
- tooltip「半徑隨強度變大」一併更新。
|
||||
|
||||
### R5【必】正式錄製鎖定任務
|
||||
- 正式模式鎖住輔助相關選項、地圖、武器;建議 Basement + Uzi(玩家 1 的設定),**此選擇待專題組確認**,集中放在一個常數。
|
||||
- FOV 建議固定 90。靈敏度自選,反映個人習慣。
|
||||
- 測試模式維持自由選擇,且不套用排程、不記錄。
|
||||
- 主要改 `SettingsSaver.cs`、`AssistOptionsLock.cs`。
|
||||
|
||||
### R6【建議】固定幀率並記錄
|
||||
PC 品質等級 `vSyncCount: 0`,自己的程式沒有設 `targetFrameRate`。實際 60 左右的來源不明,請先確認。建議固定一個全員都達得到的值(60),實際幀率仍由 `dt` 記錄。改動後用直方圖確認 Raw Input 時間戳不受影響。
|
||||
|
||||
### R7【建議】進度顯示
|
||||
- 遊戲中顯示「第 n / 85 回合」與「第 k 區塊」;不顯示強度或有無輔助。
|
||||
- 區塊之間可休息:等玩家按鍵才生成下一隻,不計入回合時間。
|
||||
- `RoundCounter` 現在顯示有/無輔助的回合數,正式模式改成總進度,避免透露條件。
|
||||
- 確認正式場景 `EnemyPerceptor.showDebug` 為 0。`PlayerRig.prefab` 是 0,但 Basement、Test 有覆寫,請檢查其值;它會在畫面上顯示偵測框。
|
||||
|
||||
### R8【建議】亂數可重現
|
||||
- 後座力種子在武器 `Awake` 以 `Environment.TickCount` 產生一次,同場景的回合共用,並非每回合一個。
|
||||
- 機器人動作、生成點、延遲抖動目前看來用未設種子的 `UnityEngine.Random`。報告 5.2.1 寫「記錄每一回合的隨機種子」,現況只有後座力符合一部分。
|
||||
- 建議每回合由 `planSeed + planIndex` 導出種子並記錄;做不到就回報,改報告文字。
|
||||
- 不要讓 6 人用同一個 `planSeed`。
|
||||
|
||||
### R9【建議】沿用 v1.0.2 需求清單(`Docs/MouseTrailCollector_v1.0.2_needs.txt`)
|
||||
- 靈敏度存檔精度(D7)。
|
||||
- 記住上次的 ID、靈敏度。
|
||||
- 遊戲內顯示回合數:已含在 R7。
|
||||
- 網址改 gitea、一鍵清除本地資料:【選】;清除前需確認,且不可刪未打包的回合。
|
||||
|
||||
### R10【必】版本與文件
|
||||
- `bundleVersion` 改 1.1.0;tag 要打在**實際出包的 commit**(現有 1.0.0 與 1.0.1 的 tag 時間相同,無法回推)。
|
||||
- 出包時工作區必須乾淨。目前有 8 個未提交的 `.meta` 刪除,先處理。
|
||||
- `DatasetReadme.cs`、`Docs/Dataset.md` 同步更新:新欄位與協定;並更正第一階段敘述(500 Hz 應為 125 Hz;武器地圖兩人不同;「v1.0.1 固定 15°」不適用於玩家 2;150 回合是每人)。
|
||||
|
||||
## 5. 不要改
|
||||
- `RawMouseInput` 的擷取與時間戳方式。
|
||||
- `mouse`、`frames`、`events` 既有欄位與順序。
|
||||
- 輔助公式(Eq. 2,k = 2 至 30)、遮擋比例、敵人血量與行為。
|
||||
- 隱私:不記鍵盤、不記遊戲外操作。
|
||||
|
||||
## 6. 驗收
|
||||
1. 排程:同種子結果相同;每區塊條件數正確(無輔助 5、各強度 1)。
|
||||
2. 中途回主選單、暫停、Alt+Tab、關閉重開,各試一次:順序不漏不重。
|
||||
3. 編輯器跑完熱身加 2 區塊,逐回合檢查:
|
||||
- config 的 `assistStrength` 與排程一致;`assist_fov` 有輔助為 15、無輔助為 0。
|
||||
- 無輔助回合的 `assist_dx`、`assist_dy` **全為 0**,特別看緊接在有輔助之後的第一幀。
|
||||
- 有輔助回合的 `assist_engaged` 有作用。
|
||||
4. `mouse` 依 `frame` 加總等於 `frames.mouse_dx`、`mouse_dy`。
|
||||
5. 正式出包版再試錄一次完整 85 回合,記下總時間(< 20 分鐘)。
|
||||
6. 兩位組員先錄,資料端檢查通過後,才發給另外 4 人。
|
||||
|
||||
## 7. 凍結規則
|
||||
出包後凍結 v1.1.0。任何會影響資料的改動都要升版號,**已錄的人全部重錄**,不混用版本。
|
||||
|
||||
## 8. 資料端會用到(供對照欄位是否足夠)
|
||||
以區塊切分的交叉驗證、留一位玩家、固定門檻套到未見玩家、強度趨勢納入 `planIndex`、純手負對照(不加輔助,只用 `mouse`)、重做順序干擾檢查。每人 40 個正式無輔助回合,6 人共 240。
|
||||
|
||||
## 9. 請二次檢查者回答
|
||||
1. 第 4 節 R2 的 `Start()` 順序問題是否真的存在?
|
||||
2. D3 的原因能否從 git 歷史或 build 證實?
|
||||
3. 排程與套用條件放在 `BotSpawner` 是否最小改動?有沒有遺漏只在 `Start()` 讀設定的地方(已知:`PlayerLook`、`WeaponLoadout`、`AimAssist`、`EnemyPerceptor`、`RoundRecorder`)?
|
||||
4. 一天內做不完時,R1–R5、R10 為必要,其餘可捨。
|
||||
Reference in new issue
Block a user