feat(gameplay): 添加建筑系统和改进摄像机控制 - 移除人类士兵数据资产文件,重构为建筑放置系统 - 在CharacterData中添加productionInterval和buildingCost字段用于建筑生产 - 实现CameraFollow脚本的完整重写,支持键盘WASD拖动、鼠标拖动、触摸拖动 - 添加摄像机缩放功能,支持上下键和触摸双指缩放 - 更新Projecttile.cs以同时处理单位和建筑目标的伤害检测 - 修改SummonCardButton从法力值召唤改为金币建筑放置模式 - 在UnitBase.cs中更新攻击逻辑以支持对建筑造成伤害 - 升级WorldHealthBar以显示建筑生产进度和更好的缩放补偿 - 修复MainCharacterDebugMovement移除键盘移动输入冲突 - 更新包管理器中的codely.bridge版本从1.0.80到1.0.81 ```
43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(WorldHealthBar))]
|
|
public class BuildingHealth : MonoBehaviour
|
|
{
|
|
[Header("建筑生命")]
|
|
[Min(1f)] public float maxHealth = 500f;
|
|
|
|
private WorldHealthBar healthBar;
|
|
|
|
public float ProductionProgress => healthBar != null
|
|
? Mathf.Clamp01(healthBar.currentEnergy / healthBar.maxEnergy)
|
|
: 0f;
|
|
|
|
private void Awake()
|
|
{
|
|
healthBar = GetComponent<WorldHealthBar>();
|
|
healthBar.maxHealth = maxHealth;
|
|
healthBar.currentHealth = maxHealth;
|
|
healthBar.maxEnergy = 1f;
|
|
healthBar.currentEnergy = 0f;
|
|
}
|
|
|
|
public void SetProductionProgress(float normalizedProgress)
|
|
{
|
|
if (healthBar != null)
|
|
{
|
|
healthBar.SetEnergy(Mathf.Clamp01(normalizedProgress) * healthBar.maxEnergy);
|
|
}
|
|
}
|
|
|
|
public bool ReceiveDamage(float damage, GameObject attacker = null)
|
|
{
|
|
if (damage <= 0f || healthBar == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
healthBar.TakeDamage(damage);
|
|
return true;
|
|
}
|
|
}
|