加入用户最近100场战绩记录并实现展示
This commit is contained in:
@@ -111,6 +111,11 @@ public class NoteSpawner : MonoBehaviour
|
||||
// Guard to avoid double-trigger / deadlock
|
||||
private bool immediateSettlementTriggered = false;
|
||||
|
||||
public bool IsImmediateSettlementTriggered
|
||||
{
|
||||
get { return immediateSettlementTriggered; }
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Load saved visual speed multiplier before any spawning logic uses it
|
||||
|
||||
@@ -149,6 +149,7 @@ public class settlementController : MonoBehaviour
|
||||
private Transform cachedIntroMvpTransform;
|
||||
private Vector3 cachedIntroMvpBaseLocalPos;
|
||||
private bool hasCachedIntroMvpBaseLocalPos;
|
||||
private bool settlementHistoryRecorded;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -183,6 +184,9 @@ public class settlementController : MonoBehaviour
|
||||
try { gameMusicMixer.SetFloat(lowpassParamName, 22000f); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
RegisterCurrentLineupDeployCount();
|
||||
settlementHistoryRecorded = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -243,6 +247,62 @@ public class settlementController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterCurrentLineupDeployCount()
|
||||
{
|
||||
HashSet<int> uniqueHeroIds = new HashSet<int>();
|
||||
AllyHero_SO[] allHeroes = null;
|
||||
|
||||
if (teamUIController.Instance != null && teamUIController.Instance.allySlotIds != null)
|
||||
{
|
||||
for (int i = 0; i < teamUIController.Instance.allySlotIds.Count; i++)
|
||||
{
|
||||
int heroId = teamUIController.Instance.allySlotIds[i];
|
||||
if (heroId > 0)
|
||||
{
|
||||
uniqueHeroIds.Add(heroId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uniqueHeroIds.Count == 0)
|
||||
{
|
||||
for (int slotIndex = 1; slotIndex <= 5; slotIndex++)
|
||||
{
|
||||
int heroId = PlayerPrefs.GetInt("selected_heroSlot0" + slotIndex + "_heroID", 0);
|
||||
if (heroId > 0)
|
||||
{
|
||||
uniqueHeroIds.Add(heroId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uniqueHeroIds.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
allHeroes = Resources.LoadAll<AllyHero_SO>(string.Empty);
|
||||
if (allHeroes == null || allHeroes.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int heroId in uniqueHeroIds)
|
||||
{
|
||||
for (int i = 0; i < allHeroes.Length; i++)
|
||||
{
|
||||
AllyHero_SO hero = allHeroes[i];
|
||||
if (hero == null || hero.ally_heroID != heroId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
hero.IncrementBattleDeployCount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startSettlement_uiUpdate()
|
||||
{
|
||||
if (settlementUiInitialized)
|
||||
@@ -251,6 +311,7 @@ public class settlementController : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
settlementUiInitialized = true;
|
||||
settlementHistoryRecorded = false;
|
||||
|
||||
// Documentation text normalized.
|
||||
InitializeSettlementCanvas();
|
||||
@@ -317,19 +378,23 @@ public class settlementController : MonoBehaviour
|
||||
|
||||
if (!GameConfig.autoPlayEnabled)
|
||||
{
|
||||
DailyTaskEventHub.ReportPlaySong();
|
||||
DailyTaskEventHub.ReportPlaySong(thisSong_so != null ? thisSong_so.songID : 0);
|
||||
DailyTaskEventHub.ReportTotalScore(targetTotalScore);
|
||||
DailyTaskEventHub.ReportSingleRunScore(targetTotalScore);
|
||||
|
||||
if (InGamePerformanceManager.Instance != null && InGamePerformanceManager.Instance.HighestComboThisRun > 0)
|
||||
{
|
||||
DailyTaskEventHub.ReportSingleRunCombo(InGamePerformanceManager.Instance.HighestComboThisRun);
|
||||
}
|
||||
|
||||
if (targetMissCount <= 0 && noteCountRaw > 0)
|
||||
{
|
||||
DailyTaskEventHub.ReportFullCombo();
|
||||
}
|
||||
|
||||
if (sessionDurationForTasks > 0f)
|
||||
{
|
||||
DailyTaskEventHub.ReportGameDuration(sessionDurationForTasks);
|
||||
}
|
||||
}
|
||||
|
||||
TryRecordRecentPlayHistory(noteCountRaw);
|
||||
|
||||
perfectHitCount_Text.text = targetPerfectCount.ToString();
|
||||
greatHitCount_Text.text = targetGreatCount.ToString();
|
||||
goodHitCount_Text.text = targetGoodCount.ToString();
|
||||
@@ -460,6 +525,127 @@ public class settlementController : MonoBehaviour
|
||||
StartSettlementIntro();
|
||||
}
|
||||
|
||||
private void TryRecordRecentPlayHistory(int noteCountRaw)
|
||||
{
|
||||
if (settlementHistoryRecorded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
settlementHistoryRecorded = true;
|
||||
|
||||
var record = new RecentPlayRecord
|
||||
{
|
||||
playedAt = System.DateTime.Now.ToString("MM-dd, HH:mm"),
|
||||
songID = thisSong_so != null ? thisSong_so.songID : 0,
|
||||
songName = thisSong_so != null && !string.IsNullOrWhiteSpace(thisSong_so.songName)
|
||||
? thisSong_so.songName
|
||||
: (bmm != null ? bmm.parsedTitle : "Unknown"),
|
||||
difficultyDisplay = BuildDifficultyDisplay(),
|
||||
accuracy = targetAccuracyPercent,
|
||||
srks = CalculateSongRankingScore(noteCountRaw),
|
||||
totalScore = targetTotalScore,
|
||||
scoreReadable = true,
|
||||
wasEarlySettlement = IsEarlySettlement(noteCountRaw),
|
||||
wasAllPerfect = IsAllPerfectRun(noteCountRaw)
|
||||
};
|
||||
|
||||
RecentPlayHistoryStore.Push(record);
|
||||
}
|
||||
|
||||
private string BuildDifficultyDisplay()
|
||||
{
|
||||
int difficulty = bmm != null ? bmm.assignedDifficulty : -1;
|
||||
string suffix = GetDifficultyShortName(difficulty);
|
||||
float level = 0f;
|
||||
|
||||
if (thisSong_so != null && thisSong_so.chartFiles != null)
|
||||
{
|
||||
for (int i = 0; i < thisSong_so.chartFiles.Count; i++)
|
||||
{
|
||||
ChartFileEntry entry = thisSong_so.chartFiles[i];
|
||||
if (entry == null || entry.difficulty != difficulty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
level = entry.difficultyLEVEL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string levelText = Mathf.Approximately(level, Mathf.Round(level))
|
||||
? Mathf.RoundToInt(level).ToString()
|
||||
: level.ToString("0.#");
|
||||
|
||||
if (string.IsNullOrEmpty(levelText) || levelText == "0")
|
||||
{
|
||||
return suffix;
|
||||
}
|
||||
|
||||
return levelText + "_" + suffix;
|
||||
}
|
||||
|
||||
private static string GetDifficultyShortName(int difficulty)
|
||||
{
|
||||
switch (difficulty)
|
||||
{
|
||||
case 0: return "EZ";
|
||||
case 1: return "HD";
|
||||
case 2: return "IN";
|
||||
case 3: return "IM";
|
||||
default: return "UN";
|
||||
}
|
||||
}
|
||||
|
||||
private float CalculateSongRankingScore(int noteCountRaw)
|
||||
{
|
||||
int totalNotes = Mathf.Max(1, noteCountRaw);
|
||||
float accuracyScore = Mathf.Clamp01(targetAccuracyPercent / 100f);
|
||||
float scoreScore = Mathf.Clamp01((float)targetTotalScore / Mathf.Max(1, _1000000));
|
||||
int highestCombo = InGamePerformanceManager.Instance != null ? InGamePerformanceManager.Instance.HighestComboThisRun : 0;
|
||||
float comboScore = Mathf.Clamp01((float)highestCombo / totalNotes);
|
||||
float judgementScore = Mathf.Clamp01(
|
||||
(targetPerfectCount + targetGreatCount * 0.7f + targetGoodCount * 0.35f) / totalNotes);
|
||||
float missPenalty = Mathf.Clamp01((float)targetMissCount / totalNotes);
|
||||
|
||||
float srks =
|
||||
accuracyScore * 42f +
|
||||
scoreScore * 28f +
|
||||
comboScore * 18f +
|
||||
judgementScore * 12f;
|
||||
|
||||
srks -= missPenalty * 18f;
|
||||
|
||||
if (targetMissCount <= 0 && totalNotes > 0)
|
||||
{
|
||||
srks += 4f;
|
||||
}
|
||||
|
||||
return Mathf.Clamp(srks, 0f, 100f);
|
||||
}
|
||||
|
||||
private bool IsEarlySettlement(int noteCountRaw)
|
||||
{
|
||||
NoteSpawner spawner = FindAnyObjectByType<NoteSpawner>();
|
||||
if (spawner != null && spawner.IsImmediateSettlementTriggered)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int parsedNoteAmount = bmm != null ? bmm.parsedNoteAmount : 0;
|
||||
return parsedNoteAmount > 0 && noteCountRaw < parsedNoteAmount;
|
||||
}
|
||||
|
||||
private bool IsAllPerfectRun(int noteCountRaw)
|
||||
{
|
||||
return noteCountRaw > 0 &&
|
||||
targetPerfectCount >= noteCountRaw &&
|
||||
targetGreatCount == 0 &&
|
||||
targetGoodCount == 0 &&
|
||||
targetMissCount == 0;
|
||||
}
|
||||
|
||||
private void StartSettlementIntro()
|
||||
{
|
||||
skipIntroRequested = false;
|
||||
|
||||
Reference in New Issue
Block a user