2025-06-03 02:42:28 -04:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
2026-07-18 16:51:18 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 单次演奏的运行时判定记录。
|
|
|
|
|
|
/// 本类随 GameScene 重建,只负责本局结算;长期最佳成绩由 SongSaveModule 写入 ES3,
|
|
|
|
|
|
/// 因此不要把此对象直接当作存档模型使用。
|
|
|
|
|
|
/// </summary>
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public class PlayingRecorder
|
|
|
|
|
|
{
|
|
|
|
|
|
public int perfectCount;
|
|
|
|
|
|
public int goodCount;
|
|
|
|
|
|
public int badCount;
|
|
|
|
|
|
public int missCount;
|
|
|
|
|
|
public int totalCount;
|
|
|
|
|
|
|
|
|
|
|
|
public float accuracy;
|
|
|
|
|
|
|
|
|
|
|
|
public int currentCombo;
|
|
|
|
|
|
public int maxCombo;
|
|
|
|
|
|
|
2026-07-18 16:51:18 -04:00
|
|
|
|
/// <summary>本局判定偏差图数据,仅供当前 Summary 使用,不写入存档。</summary>
|
2025-08-11 14:04:06 -04:00
|
|
|
|
public List<float> resultData = new List<float>();
|
|
|
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public bool isFullCombo;
|
|
|
|
|
|
public bool isAllPerfect;
|
|
|
|
|
|
|
2026-07-18 16:51:18 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在进入一局新演奏时重置全部瞬时状态。
|
|
|
|
|
|
/// 初始化为 100% / FC / AP 是为了让首个非 Perfect 判定能正确打破对应状态;
|
|
|
|
|
|
/// 无有效判定的空局不会被 SongSaveModule 写入成绩。
|
|
|
|
|
|
/// </summary>
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public void Initialize()
|
|
|
|
|
|
{
|
2026-07-18 16:51:18 -04:00
|
|
|
|
if (resultData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
resultData = new List<float>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
resultData.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
|
perfectCount = 0;
|
|
|
|
|
|
goodCount = 0;
|
|
|
|
|
|
badCount = 0;
|
|
|
|
|
|
missCount = 0;
|
|
|
|
|
|
totalCount = 0;
|
|
|
|
|
|
accuracy = 100f;
|
|
|
|
|
|
currentCombo = 0;
|
|
|
|
|
|
maxCombo = 0;
|
|
|
|
|
|
isFullCombo = true;
|
|
|
|
|
|
isAllPerfect = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateAccuracy()
|
|
|
|
|
|
{
|
|
|
|
|
|
float baseValue = perfectCount + goodCount * 0.7f + badCount * 0.3f;
|
|
|
|
|
|
if (totalCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
accuracy = baseValue / totalCount * 100f;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
accuracy = 100f; // 如果没有任何击打,准确率为100%
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddCombo()
|
|
|
|
|
|
{
|
|
|
|
|
|
currentCombo++;
|
|
|
|
|
|
maxCombo = Mathf.Max(maxCombo, currentCombo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ResetCombo()
|
|
|
|
|
|
{
|
|
|
|
|
|
currentCombo = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddPerfect()
|
|
|
|
|
|
{
|
|
|
|
|
|
perfectCount++;
|
|
|
|
|
|
totalCount++;
|
|
|
|
|
|
AddCombo();
|
|
|
|
|
|
UpdateAccuracy();
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateAccuracy(accuracy);
|
|
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateCombo(currentCombo);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddGood()
|
|
|
|
|
|
{
|
|
|
|
|
|
goodCount++;
|
|
|
|
|
|
totalCount++;
|
|
|
|
|
|
AddCombo();
|
|
|
|
|
|
UpdateAccuracy();
|
|
|
|
|
|
isAllPerfect = false;
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateAccuracy(accuracy);
|
|
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateCombo(currentCombo);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddBad()
|
|
|
|
|
|
{
|
|
|
|
|
|
badCount++;
|
|
|
|
|
|
totalCount++;
|
|
|
|
|
|
ResetCombo();
|
|
|
|
|
|
UpdateAccuracy();
|
|
|
|
|
|
isFullCombo = false;
|
|
|
|
|
|
isAllPerfect = false;
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateAccuracy(accuracy);
|
|
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateCombo(currentCombo);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddMiss()
|
|
|
|
|
|
{
|
|
|
|
|
|
missCount++;
|
|
|
|
|
|
totalCount++;
|
|
|
|
|
|
ResetCombo();
|
|
|
|
|
|
UpdateAccuracy();
|
|
|
|
|
|
isFullCombo = false;
|
|
|
|
|
|
isAllPerfect = false;
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateAccuracy(accuracy);
|
|
|
|
|
|
GameManager.Instance.gameUICanvas.UpdateCombo(currentCombo);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-07-18 16:51:18 -04:00
|
|
|
|
}
|