feat(gameplay): 实现召唤师对决模式核心功能 - 新增召唤师对决管理模式,支持点卡片直接召唤单位 - 添加召唤师点地移动控制,移动时不攻击、站定时自动攻击 - 实现召唤师模式开关,单位不再自动追击远处敌人 - 更新卡牌按钮逻辑,对决模式下按能量消耗直接召唤 - 修改单位基础行为,支持移动中不攻击的召唤师模式 - 更新核心玩法文档,从建筑生产模式转向召唤师对决模式 - 添加召唤师对决测试场景,整合新的战斗逻辑 ```
103 lines
2.4 KiB
C#
103 lines
2.4 KiB
C#
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
|
|
}
|
|
}
|