特效新内容。修复gameplay致命bug和分数保存bug
This commit is contained in:
@@ -304,6 +304,50 @@ public class SongData : ScriptableObject
|
||||
CalculateHighestPersonalRecord();
|
||||
}
|
||||
|
||||
public void ApplySettlementResult(int difficulty, int pmScore, int idolScore, int maxScoreSum)
|
||||
{
|
||||
if (difficulty < 0) return;
|
||||
|
||||
if (personalRecordMap == null) personalRecordMap = new Dictionary<int, int>();
|
||||
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
|
||||
if (chartScoreMap == null) chartScoreMap = new Dictionary<int, int>();
|
||||
|
||||
int total = pmScore + idolScore;
|
||||
int currentBestTotal = GetPersonalRecord(difficulty) + GetIdolRecord(difficulty);
|
||||
bool isNewTotalRecord = total > currentBestTotal;
|
||||
|
||||
if (isNewTotalRecord)
|
||||
{
|
||||
personalRecordMap[difficulty] = pmScore;
|
||||
idolRecordMap[difficulty] = idolScore;
|
||||
}
|
||||
|
||||
ChartFileEntry entry = chartFiles != null ? chartFiles.Find(e => e != null && e.difficulty == difficulty) : null;
|
||||
if (entry != null)
|
||||
{
|
||||
if (isNewTotalRecord)
|
||||
{
|
||||
entry.chartPersonalRecordForThisDifficulty = pmScore;
|
||||
entry.idolPersonalRecordForThisDifficulty = idolScore;
|
||||
entry.totalPersonalRecordForThisDifficulty = total;
|
||||
}
|
||||
|
||||
float newProgress = maxScoreSum > 0 ? Mathf.Clamp01((float)total / (float)maxScoreSum) : 0f;
|
||||
if (newProgress > entry.levelProgressForThisDifficulty)
|
||||
{
|
||||
entry.levelProgressForThisDifficulty = newProgress;
|
||||
}
|
||||
|
||||
entry.lastScoreForThisDifficulty = total;
|
||||
}
|
||||
|
||||
chartScoreMap[difficulty] = total;
|
||||
|
||||
UpdateOverallRecordsFromEntries();
|
||||
ApplySerializableRoundTrip();
|
||||
SavePersistent();
|
||||
}
|
||||
|
||||
public void GetAbsoluteHighestScore(out int highestScore, out int bestDifficulty, out string bestDifficultyName)
|
||||
{
|
||||
highestScore = 0;
|
||||
@@ -375,6 +419,62 @@ public class SongData : ScriptableObject
|
||||
CalculateHighestPersonalRecord();
|
||||
}
|
||||
|
||||
private void UpdateOverallRecordsFromEntries()
|
||||
{
|
||||
int highestTotal = 0;
|
||||
float highestProgress = 0f;
|
||||
|
||||
if (chartFiles != null && chartFiles.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < chartFiles.Count; i++)
|
||||
{
|
||||
ChartFileEntry entry = chartFiles[i];
|
||||
if (entry == null) continue;
|
||||
|
||||
int total = entry.totalPersonalRecordForThisDifficulty;
|
||||
if (total <= 0)
|
||||
{
|
||||
int p = GetPersonalRecord(entry.difficulty);
|
||||
int idol = GetIdolRecord(entry.difficulty);
|
||||
total = p + idol;
|
||||
}
|
||||
|
||||
if (total > highestTotal)
|
||||
{
|
||||
highestTotal = total;
|
||||
}
|
||||
|
||||
if (entry.levelProgressForThisDifficulty > highestProgress)
|
||||
{
|
||||
highestProgress = entry.levelProgressForThisDifficulty;
|
||||
}
|
||||
}
|
||||
|
||||
personalRecord = highestTotal;
|
||||
current_levelProgress = highestProgress;
|
||||
return;
|
||||
}
|
||||
|
||||
if (personalRecordMap != null && personalRecordMap.Count > 0)
|
||||
{
|
||||
foreach (var kvp in personalRecordMap)
|
||||
{
|
||||
int diff = kvp.Key;
|
||||
int total = kvp.Value + GetIdolRecord(diff);
|
||||
if (total > highestTotal) highestTotal = total;
|
||||
}
|
||||
personalRecord = highestTotal;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySerializableRoundTrip()
|
||||
{
|
||||
SongDataSerializable serializable = new SongDataSerializable(this);
|
||||
string json = JsonUtility.ToJson(serializable);
|
||||
SongDataSerializable roundTrip = JsonUtility.FromJson<SongDataSerializable>(json);
|
||||
if (roundTrip != null) roundTrip.ApplyTo(this);
|
||||
}
|
||||
|
||||
public void UpdateIdolRecord(int difficulty, int newIdolScore)
|
||||
{
|
||||
if (idolRecordMap == null) idolRecordMap = new Dictionary<int, int>();
|
||||
|
||||
@@ -833,7 +833,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
@@ -105,36 +105,26 @@ public class SongButton : MonoBehaviour
|
||||
songOverallDescriptionText.text = string.IsNullOrEmpty(sd.thisLevel_overallDescription) ? "" : sd.thisLevel_overallDescription;
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
int bestTotal = 0;
|
||||
int bestDiff = -1;
|
||||
string bestDiffName = "";
|
||||
sd.GetAbsoluteHighestScore(out bestTotal, out bestDiff, out bestDiffName);
|
||||
sd.GetAbsoluteHighestScore(out int bestTotal, out int bestDiff, out string bestDiffName);
|
||||
|
||||
if (bestTotal < 0) bestTotal = 0;
|
||||
|
||||
if (highestScoreText != null) highestScoreText.text = bestTotal.ToString();
|
||||
|
||||
// Documentation text normalized.
|
||||
if (highestScoreDifficultyText != null)
|
||||
{
|
||||
highestScoreDifficultyText.text = string.IsNullOrEmpty(bestDiffName) ? "" : "(" + bestDiffName + ")";
|
||||
}
|
||||
|
||||
// Assign scoreLevelImage based on thresholds relative to 2,000,000
|
||||
if (scoreLevelImage != null)
|
||||
{
|
||||
Sprite chosenSprite = null;
|
||||
Sprite chosenSprite;
|
||||
float baseScore = 2000000f;
|
||||
|
||||
// Documentation text normalized.
|
||||
if (bestTotal <= 0)
|
||||
{
|
||||
chosenSprite = ufSprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Evaluate from top to bottom thresholds
|
||||
if (bestTotal >= baseScore * easePercent && easeSprite != null)
|
||||
chosenSprite = easeSprite;
|
||||
else if (bestTotal >= baseScore * ssPercent && ssSprite != null)
|
||||
@@ -225,10 +215,7 @@ public class SongButton : MonoBehaviour
|
||||
}
|
||||
if (selectedSong != null)
|
||||
{
|
||||
int bestTotal = 0;
|
||||
int bestDiff = -1;
|
||||
string bestDiffName = "";
|
||||
selectedSong.GetAbsoluteHighestScore(out bestTotal, out bestDiff, out bestDiffName);
|
||||
selectedSong.GetAbsoluteHighestScore(out int bestTotal, out int bestDiff, out string bestDiffName);
|
||||
if (bestDiff >= 0)
|
||||
{
|
||||
selectedSong.thisLevel_selectedDifficultyID = bestDiff;
|
||||
|
||||
Reference in New Issue
Block a user