根据提供的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,54 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// 召唤师专属血条 UI:顶部 HUD 显示双方召唤师血量,区别于单位头顶血条。
|
||||
/// </summary>
|
||||
public class SummonerHealthBarUI : MonoBehaviour
|
||||
{
|
||||
[Header("UI 引用")]
|
||||
public Image playerHealthFill;
|
||||
public Image enemyHealthFill;
|
||||
public Text playerHealthText;
|
||||
public Text enemyHealthText;
|
||||
|
||||
[Header("召唤师引用")]
|
||||
public GameObject playerSummoner;
|
||||
public GameObject enemySummoner;
|
||||
|
||||
private WorldHealthBar playerHealthBar;
|
||||
private WorldHealthBar enemyHealthBar;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 获取双方召唤师的血条组件
|
||||
if (playerSummoner != null)
|
||||
{
|
||||
playerHealthBar = playerSummoner.GetComponent<WorldHealthBar>();
|
||||
}
|
||||
|
||||
if (enemySummoner != null)
|
||||
{
|
||||
enemyHealthBar = enemySummoner.GetComponent<WorldHealthBar>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateHealthBar(playerHealthBar, playerHealthFill, playerHealthText);
|
||||
UpdateHealthBar(enemyHealthBar, enemyHealthFill, enemyHealthText);
|
||||
}
|
||||
|
||||
private void UpdateHealthBar(WorldHealthBar healthBar, Image fillImage, Text healthText)
|
||||
{
|
||||
if (healthBar == null || fillImage == null) return;
|
||||
|
||||
float ratio = healthBar.currentHealth / healthBar.maxHealth;
|
||||
fillImage.fillAmount = ratio;
|
||||
|
||||
if (healthText != null)
|
||||
{
|
||||
healthText.text = $"{Mathf.CeilToInt(healthBar.currentHealth)}/{Mathf.CeilToInt(healthBar.maxHealth)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user