1.2.0
This commit is contained in:
1 parent
c3bb8d1a9e
commit
fd0312270b
26 files changed
+3310
-87
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user