优化一大波

This commit is contained in:
2026-07-05 15:49:57 +08:00
parent 8485743cb7
commit 31cbb580b6
6 changed files with 47 additions and 7 deletions
+13 -2
View File
@@ -41,6 +41,8 @@ namespace GameFramework
private EchoSystem _echoSystem;
private PlayerController _playerController;
private int _maxHealth = 5;
private bool _subscribedScoreEvent = false;
private int _lastSoulCount = -1;
void Start()
{
@@ -64,6 +66,7 @@ namespace GameFramework
if (ScoreManager.Instance != null)
{
ScoreManager.onScoreChanged += UpdateSoulCount;
_subscribedScoreEvent = true;
UpdateSoulCount(ScoreManager.Instance.CurrentScore);
}
@@ -79,7 +82,11 @@ namespace GameFramework
void OnDestroy()
{
ScoreManager.onScoreChanged -= UpdateSoulCount;
if (_subscribedScoreEvent)
{
ScoreManager.onScoreChanged -= UpdateSoulCount;
_subscribedScoreEvent = false;
}
}
void Update()
@@ -96,7 +103,11 @@ namespace GameFramework
if (soulCountText != null)
{
soulCountText.text = count.ToString();
Debug.Log($"[GameHUD] UpdateSoulCount: {count}");
if (count != _lastSoulCount)
{
Debug.Log($"[GameHUD] UpdateSoulCount: {count}");
_lastSoulCount = count;
}
}
else
{