修复一堆bug 加入粒子系统代替原击打特效 焕新长音符逻辑 修复多重计分 更新判定管理和音符生成器 搞了一个免费包
This commit is contained in:
@@ -20,26 +20,58 @@ public class ScoreManager : MonoBehaviour
|
||||
|
||||
private int[] pmScoreSums = new int[5];
|
||||
|
||||
// per-track idol score sums (red, green, yellow, purple, blue)
|
||||
public int red_idolScore_sum = 0;
|
||||
public int green_idolScore_sum = 0;
|
||||
public int yellow_idolScore_sum = 0;
|
||||
public int purple_idolScore_sum = 0;
|
||||
public int blue_idolScore_sum = 0;
|
||||
|
||||
// aggregate of the five track idol sums
|
||||
public int allSum_idolScore = 0;
|
||||
|
||||
private int[] idolScoreSums = new int[5];
|
||||
|
||||
[Header("Judgement Statistics")]
|
||||
public int countPerfect = 0;
|
||||
public int countGreat = 0;
|
||||
public int countGood = 0;
|
||||
public int countMiss = 0;
|
||||
|
||||
public void ResetStatistics()
|
||||
{
|
||||
countPerfect = countGreat = countGood = countMiss = 0;
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null) Instance = this;
|
||||
else Destroy(gameObject);
|
||||
|
||||
for (int i = 0; i < pmScoreSums.Length; i++) pmScoreSums[i] = 0;
|
||||
for (int i = 0; i < idolScoreSums.Length; i++) idolScoreSums[i] = 0;
|
||||
|
||||
ResetStatistics();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a per-note pm score delta to the specified track (0..4) and update named fields + aggregate.
|
||||
/// Also calculates idol score as pmDelta * scoreEfficiency.
|
||||
/// </summary>
|
||||
public void AddPmScoreForTrack(int trackIndex, int delta)
|
||||
public void AddPmScoreForTrack(int trackIndex, int pmDelta, float scoreEfficiency)
|
||||
{
|
||||
if (trackIndex < 0 || trackIndex >= pmScoreSums.Length) return;
|
||||
if (delta == 0) return;
|
||||
pmScoreSums[trackIndex] += delta;
|
||||
if (pmDelta == 0) return;
|
||||
pmScoreSums[trackIndex] += pmDelta;
|
||||
// clamp at int.MaxValue-1 to avoid overflow
|
||||
if (pmScoreSums[trackIndex] < 0) pmScoreSums[trackIndex] = 0;
|
||||
if (pmScoreSums[trackIndex] > int.MaxValue - 1) pmScoreSums[trackIndex] = int.MaxValue - 1;
|
||||
|
||||
// calculate idol score: pmDelta * scoreEfficiency
|
||||
int idolDelta = Mathf.FloorToInt(pmDelta * scoreEfficiency);
|
||||
idolScoreSums[trackIndex] += idolDelta;
|
||||
if (idolScoreSums[trackIndex] < 0) idolScoreSums[trackIndex] = 0;
|
||||
if (idolScoreSums[trackIndex] > int.MaxValue - 1) idolScoreSums[trackIndex] = int.MaxValue - 1;
|
||||
|
||||
// update named fields for easy access
|
||||
red_pmScore_sum = pmScoreSums[0];
|
||||
green_pmScore_sum = pmScoreSums[1];
|
||||
@@ -47,12 +79,21 @@ public class ScoreManager : MonoBehaviour
|
||||
purple_pmScore_sum = pmScoreSums[3];
|
||||
blue_pmScore_sum = pmScoreSums[4];
|
||||
|
||||
// recompute aggregate
|
||||
long agg = 0;
|
||||
for (int i = 0; i < pmScoreSums.Length; i++) agg += pmScoreSums[i];
|
||||
allSum_pmScore = (int)Mathf.Min((float)agg, (float)int.MaxValue - 1f);
|
||||
red_idolScore_sum = idolScoreSums[0];
|
||||
green_idolScore_sum = idolScoreSums[1];
|
||||
yellow_idolScore_sum = idolScoreSums[2];
|
||||
purple_idolScore_sum = idolScoreSums[3];
|
||||
blue_idolScore_sum = idolScoreSums[4];
|
||||
|
||||
Debug.Log($"[ScoreManager] Added {delta} to track {trackIndex} pm sum. New per-track sums: R{red_pmScore_sum} G{green_pmScore_sum} Y{yellow_pmScore_sum} P{purple_pmScore_sum} B{blue_pmScore_sum} -> allSum={allSum_pmScore}");
|
||||
// recompute aggregates
|
||||
long aggPm = 0;
|
||||
long aggIdol = 0;
|
||||
for (int i = 0; i < pmScoreSums.Length; i++) aggPm += pmScoreSums[i];
|
||||
for (int i = 0; i < idolScoreSums.Length; i++) aggIdol += idolScoreSums[i];
|
||||
allSum_pmScore = (int)Mathf.Min((float)aggPm, (float)int.MaxValue - 1f);
|
||||
allSum_idolScore = (int)Mathf.Min((float)aggIdol, (float)int.MaxValue - 1f);
|
||||
|
||||
Debug.Log($"[ScoreManager] Added {pmDelta} to track {trackIndex} pm sum, idol delta {idolDelta}. New pm sums: R{red_pmScore_sum} G{green_pmScore_sum} Y{yellow_pmScore_sum} P{purple_pmScore_sum} B{blue_pmScore_sum} -> allSumPm={allSum_pmScore}. Idol sums: R{red_idolScore_sum} G{green_idolScore_sum} Y{yellow_idolScore_sum} P{purple_idolScore_sum} B{blue_idolScore_sum} -> allSumIdol={allSum_idolScore}");
|
||||
|
||||
// Update UI in teamUIController if available (per-track pm sums + aggregate)
|
||||
var ui = teamUIController.Instance;
|
||||
@@ -67,10 +108,17 @@ public class ScoreManager : MonoBehaviour
|
||||
if (ui.purple_pmScore_sum != null) ui.purple_pmScore_sum.text = purple_pmScore_sum.ToString();
|
||||
if (ui.blue_pmScore_sum != null) ui.blue_pmScore_sum.text = blue_pmScore_sum.ToString();
|
||||
if (ui.allSum_pmScore != null) ui.allSum_pmScore.text = allSum_pmScore.ToString();
|
||||
|
||||
if (ui.red_idolScore_sum != null) ui.red_idolScore_sum.text = red_idolScore_sum.ToString();
|
||||
if (ui.green_idolScore_sum != null) ui.green_idolScore_sum.text = green_idolScore_sum.ToString();
|
||||
if (ui.yellow_idolScore_sum != null) ui.yellow_idolScore_sum.text = yellow_idolScore_sum.ToString();
|
||||
if (ui.purple_idolScore_sum != null) ui.purple_idolScore_sum.text = purple_idolScore_sum.ToString();
|
||||
if (ui.blue_idolScore_sum != null) ui.blue_idolScore_sum.text = blue_idolScore_sum.ToString();
|
||||
if (ui.allSum_idolScore != null) ui.allSum_idolScore.text = allSum_idolScore.ToString();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[ScoreManager] Failed to write pm sums to teamUIController fields: {ex}");
|
||||
Debug.LogWarning($"[ScoreManager] Failed to write sums to teamUIController fields: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,4 +235,4 @@ public class ScoreManager : MonoBehaviour
|
||||
Debug.LogWarning("[ScoreManager] teamUIController.Instance is null; cannot update UI.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user