根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加项目使用指南 - 完善API接口说明 - 修正错误的配置示例 ``` 注意:由于您提供的code differences部分为空,以上是一个示例模板。当您有具体的代码变更时,请提供详细的变更内容以便生成更准确的commit message。
This commit is contained in:
1 parent
8d58c2223c
commit
11f1af357d
191 files changed
+2315
-1539
No files matched your search
@@ -0,0 +1,102 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗管理器:监听双方召唤师死亡,触发胜负判定并显示结果 UI。
|
||||
/// </summary>
|
||||
public class BattleManager : MonoBehaviour
|
||||
{
|
||||
[Header("召唤师引用")]
|
||||
public GameObject playerSummoner;
|
||||
public GameObject enemySummoner;
|
||||
|
||||
[Header("胜负 UI")]
|
||||
public GameObject victoryPanel;
|
||||
public GameObject defeatPanel;
|
||||
|
||||
private WorldHealthBar playerHealthBar;
|
||||
private WorldHealthBar enemyHealthBar;
|
||||
private bool battleEnded = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 获取双方召唤师的血条组件
|
||||
if (playerSummoner != null)
|
||||
{
|
||||
playerHealthBar = playerSummoner.GetComponent<WorldHealthBar>();
|
||||
}
|
||||
|
||||
if (enemySummoner != null)
|
||||
{
|
||||
enemyHealthBar = enemySummoner.GetComponent<WorldHealthBar>();
|
||||
}
|
||||
|
||||
// 隐藏胜负 UI
|
||||
if (victoryPanel != null) victoryPanel.SetActive(false);
|
||||
if (defeatPanel != null) defeatPanel.SetActive(false);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (battleEnded) return;
|
||||
|
||||
// 检测己方召唤师死亡
|
||||
if (playerHealthBar != null && playerHealthBar.IsDead)
|
||||
{
|
||||
OnBattleEnd(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 检测敌方召唤师死亡
|
||||
if (enemyHealthBar != null && enemyHealthBar.IsDead)
|
||||
{
|
||||
OnBattleEnd(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBattleEnd(bool victory)
|
||||
{
|
||||
battleEnded = true;
|
||||
|
||||
// 暂停游戏
|
||||
Time.timeScale = 0f;
|
||||
|
||||
// 显示对应 UI
|
||||
if (victory)
|
||||
{
|
||||
Debug.Log("胜利!");
|
||||
if (victoryPanel != null)
|
||||
{
|
||||
victoryPanel.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("失败!");
|
||||
if (defeatPanel != null)
|
||||
{
|
||||
defeatPanel.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 重新开始按钮回调
|
||||
public void OnRestartButtonClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(
|
||||
UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
|
||||
}
|
||||
|
||||
// 退出按钮回调
|
||||
public void OnQuitButtonClicked()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user