结算重做部分 谱面分装好 编队UI之bug修复
This commit is contained in:
@@ -25,6 +25,7 @@ public class AllyCombatant : MonoBehaviour, ICombatant
|
||||
public float scoreEfficiency = 1f;
|
||||
|
||||
private bool isDead = false; // new: dead flag
|
||||
public BeatmapManager bmm;
|
||||
|
||||
// add attack stat to be available at runtime
|
||||
[Tooltip("基础攻击力(运行时使用),会从 AllyHero_SO.levelStats[0].attack 填充(如果存在)")]
|
||||
@@ -35,6 +36,9 @@ public class AllyCombatant : MonoBehaviour, ICombatant
|
||||
[Tooltip("Base score value for a perfect hit on this track")]
|
||||
public int baseTrackScore = 1000;
|
||||
|
||||
// Editable multipliers for each judge quality (exposed for designers)
|
||||
[Tooltip("Score multiplier for Perfect (default 1.0)")]
|
||||
public float perfectRatio = 1f;
|
||||
[Tooltip("Score multiplier for Great (e.g. 0.75)")]
|
||||
public float greatRatio = 0.75f;
|
||||
[Tooltip("Score multiplier for Good (e.g. 0.5)")]
|
||||
@@ -298,34 +302,41 @@ public class AllyCombatant : MonoBehaviour, ICombatant
|
||||
}
|
||||
|
||||
// Scoring API
|
||||
public void AddScoreForJudge(string judge)
|
||||
// Modified to return the amount added so callers can track per-track contributions
|
||||
public int AddScoreForJudge(string judge)
|
||||
{
|
||||
int add = 0;
|
||||
float multiplier = 0f;
|
||||
switch (judge)
|
||||
{
|
||||
case "Perfect":
|
||||
add = baseTrackScore;
|
||||
multiplier = perfectRatio;
|
||||
break;
|
||||
case "Great":
|
||||
add = Mathf.FloorToInt(baseTrackScore * greatRatio);
|
||||
multiplier = greatRatio;
|
||||
break;
|
||||
case "Good":
|
||||
add = Mathf.FloorToInt(baseTrackScore * goodRatio);
|
||||
multiplier = goodRatio;
|
||||
break;
|
||||
case "Miss":
|
||||
add = Mathf.FloorToInt(baseTrackScore * missRatio);
|
||||
multiplier = missRatio;
|
||||
break;
|
||||
default:
|
||||
add = 0;
|
||||
multiplier = 0f;
|
||||
break;
|
||||
}
|
||||
// apply scoreEfficiency or other modifiers here
|
||||
add = Mathf.FloorToInt(add * scoreEfficiency);
|
||||
|
||||
// Use perNoteScore from BeatmapManager as the base score for each note hit
|
||||
int baseScore = bmm != null ? bmm.perNoteScore : baseTrackScore;
|
||||
add = Mathf.FloorToInt(baseScore * multiplier);
|
||||
|
||||
int before = currentScore;
|
||||
currentScore = Mathf.Clamp(currentScore + add, 0, maxTrackScore);
|
||||
int actuallyAdded = currentScore - before;
|
||||
UpdateScoreUI();
|
||||
// update global total
|
||||
ScoreManager.Instance?.RecalculateTotal();
|
||||
return actuallyAdded;
|
||||
}
|
||||
|
||||
// Add an arbitrary score delta directly (used by skills to modify single judge or grant/penalize score)
|
||||
|
||||
@@ -8,10 +8,73 @@ public class ScoreManager : MonoBehaviour
|
||||
|
||||
public int totalScore = 0;
|
||||
|
||||
// per-track pm score sums (red, green, yellow, purple, blue)
|
||||
public int red_pmScore_sum = 0;
|
||||
public int green_pmScore_sum = 0;
|
||||
public int yellow_pmScore_sum = 0;
|
||||
public int purple_pmScore_sum = 0;
|
||||
public int blue_pmScore_sum = 0;
|
||||
|
||||
// aggregate of the five track pm sums
|
||||
public int allSum_pmScore = 0;
|
||||
|
||||
private int[] pmScoreSums = new int[5];
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null) Instance = this;
|
||||
else Destroy(gameObject);
|
||||
|
||||
for (int i = 0; i < pmScoreSums.Length; i++) pmScoreSums[i] = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a per-note pm score delta to the specified track (0..4) and update named fields + aggregate.
|
||||
/// </summary>
|
||||
public void AddPmScoreForTrack(int trackIndex, int delta)
|
||||
{
|
||||
if (trackIndex < 0 || trackIndex >= pmScoreSums.Length) return;
|
||||
if (delta == 0) return;
|
||||
pmScoreSums[trackIndex] += delta;
|
||||
// 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;
|
||||
|
||||
// update named fields for easy access
|
||||
red_pmScore_sum = pmScoreSums[0];
|
||||
green_pmScore_sum = pmScoreSums[1];
|
||||
yellow_pmScore_sum = pmScoreSums[2];
|
||||
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);
|
||||
|
||||
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}");
|
||||
|
||||
// Update UI in teamUIController if available (per-track pm sums + aggregate)
|
||||
var ui = teamUIController.Instance;
|
||||
if (ui != null)
|
||||
{
|
||||
// Legacy Text fields on teamUIController
|
||||
try
|
||||
{
|
||||
if (ui.red_pmScore_sum != null) ui.red_pmScore_sum.text = red_pmScore_sum.ToString();
|
||||
if (ui.green_pmScore_sum != null) ui.green_pmScore_sum.text = green_pmScore_sum.ToString();
|
||||
if (ui.yellow_pmScore_sum != null) ui.yellow_pmScore_sum.text = yellow_pmScore_sum.ToString();
|
||||
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();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[ScoreManager] Failed to write pm sums to teamUIController fields: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
// Optionally update any UI for pm sums here if teamUIController exposes fields (not implemented by default)
|
||||
}
|
||||
|
||||
public void RecalculateTotal()
|
||||
|
||||
Reference in New Issue
Block a user