优化一大波
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -78,8 +81,12 @@ namespace GameFramework
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_subscribedScoreEvent)
|
||||
{
|
||||
ScoreManager.onScoreChanged -= UpdateSoulCount;
|
||||
_subscribedScoreEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -96,7 +103,11 @@ namespace GameFramework
|
||||
if (soulCountText != null)
|
||||
{
|
||||
soulCountText.text = count.ToString();
|
||||
if (count != _lastSoulCount)
|
||||
{
|
||||
Debug.Log($"[GameHUD] UpdateSoulCount: {count}");
|
||||
_lastSoulCount = count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace GameFramework
|
||||
|
||||
public static GameState GameState
|
||||
{
|
||||
get => Instance.gameState;
|
||||
set => Instance.gameState = value;
|
||||
get => Instance != null ? Instance.gameState : GameState.Playing;
|
||||
set { if (Instance != null) Instance.gameState = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private GameState gameState = GameState.Playing;
|
||||
@@ -68,6 +68,9 @@ namespace GameFramework
|
||||
/// </summary>
|
||||
private IEnumerator DeathTransition()
|
||||
{
|
||||
// 确保从暂停状态恢复(玩家可能在暂停时死亡)
|
||||
Time.timeScale = 1f;
|
||||
|
||||
// 等待一帧,让 HUD 先更新血量显示
|
||||
yield return null;
|
||||
|
||||
|
||||
@@ -95,5 +95,15 @@ namespace GameFramework
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (startButton != null) startButton.onClick.RemoveAllListeners();
|
||||
if (storyReplayButton != null) storyReplayButton.onClick.RemoveAllListeners();
|
||||
if (creditsButton != null) creditsButton.onClick.RemoveAllListeners();
|
||||
if (quitButton != null) quitButton.onClick.RemoveAllListeners();
|
||||
if (settingsBackButton != null) settingsBackButton.onClick.RemoveAllListeners();
|
||||
if (creditsCloseButton != null) creditsCloseButton.onClick.RemoveAllListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,23 @@ namespace GameFramework
|
||||
private Color color;
|
||||
private bool isLoading = false;
|
||||
|
||||
public void LoadGameplayScene() => Load(gameplayScene);
|
||||
public void LoadGameplayScene()
|
||||
{
|
||||
// 重置 GameManager 状态
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
GameManager.GameState = GameState.Playing;
|
||||
GameManager.onGameOver = null;
|
||||
GameManager.onGameWin = null;
|
||||
}
|
||||
// 重置 ScoreManager
|
||||
if (ScoreManager.Instance != null)
|
||||
ScoreManager.Instance.ResetScore();
|
||||
// 清理静态事件残留订阅
|
||||
IndianOceanAssets.Engine2_5D.HealthSystem.onPlayerDamaged = null;
|
||||
|
||||
Load(gameplayScene);
|
||||
}
|
||||
public void LoadMainMenuScene() => Load(mainMenuScene);
|
||||
public void LoadScoringScene() => Load(scoringScene);
|
||||
public void Load(string sceneName)
|
||||
|
||||
@@ -125,7 +125,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
lifetime: 10
|
||||
damageOnContact: 1
|
||||
damageOnContact: 3
|
||||
fadeOutDuration: 2
|
||||
soulDropPrefab: {fileID: 1000000000000001, guid: 5d3fc7696ceb3a24d9234355fee1c344, type: 3}
|
||||
--- !u!135 &8338025974414621740
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
|
||||
[Header("伤害")]
|
||||
[Tooltip("怪物碰触灵灯时受到的伤害")]
|
||||
[SerializeField] private int damageOnContact = 1;
|
||||
[SerializeField] private int damageOnContact = 3;
|
||||
|
||||
[Header("渐隐")]
|
||||
[Tooltip("碰触后灵灯渐隐消失的时间(秒)")]
|
||||
|
||||
Reference in New Issue
Block a user