```
feat(gameplay): 添加建筑系统和改进摄像机控制 - 移除人类士兵数据资产文件,重构为建筑放置系统 - 在CharacterData中添加productionInterval和buildingCost字段用于建筑生产 - 实现CameraFollow脚本的完整重写,支持键盘WASD拖动、鼠标拖动、触摸拖动 - 添加摄像机缩放功能,支持上下键和触摸双指缩放 - 更新Projecttile.cs以同时处理单位和建筑目标的伤害检测 - 修改SummonCardButton从法力值召唤改为金币建筑放置模式 - 在UnitBase.cs中更新攻击逻辑以支持对建筑造成伤害 - 升级WorldHealthBar以显示建筑生产进度和更好的缩放补偿 - 修复MainCharacterDebugMovement移除键盘移动输入冲突 - 更新包管理器中的codely.bridge版本从1.0.80到1.0.81 ```
This commit is contained in:
1 parent
fb56cd7ede
commit
769aea30f3
55 files changed
+9328
-90
No files matched your search
@@ -94,6 +94,7 @@ public class WorldHealthBar : MonoBehaviour
|
||||
{
|
||||
if (barRect == null) return;
|
||||
barRect.localPosition = GetBarRootPosition();
|
||||
ApplyScaleCompensation();
|
||||
|
||||
// 优先使用场景中名称完全为 Main Camera 的摄像机。
|
||||
Camera camera = FindMainCamera();
|
||||
@@ -167,13 +168,19 @@ public class WorldHealthBar : MonoBehaviour
|
||||
|
||||
// 清空技能能量并刷新能量条。
|
||||
public void ResetEnergy()
|
||||
{
|
||||
SetEnergy(0f);
|
||||
}
|
||||
|
||||
// 设置下方条的当前填充值;单位用于技能能量,建筑用于生产进度。
|
||||
public void SetEnergy(float value)
|
||||
{
|
||||
if (isDead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentEnergy = 0f;
|
||||
currentEnergy = Mathf.Clamp(value, 0f, maxEnergy);
|
||||
UpdateEnergyFill();
|
||||
}
|
||||
|
||||
@@ -327,7 +334,10 @@ public class WorldHealthBar : MonoBehaviour
|
||||
worldWidth = barWidth;
|
||||
// 水平方向固定对齐单位根节点,只使用模型顶部计算血条高度。
|
||||
Vector3 top = transform.InverseTransformPoint(new Vector3(transform.position.x, bounds.max.y, transform.position.z));
|
||||
localBarPosition = new Vector3(0f, top.y + heightOffset, 0f);
|
||||
float localHeightOffset = transform.lossyScale.y != 0f
|
||||
? heightOffset / transform.lossyScale.y
|
||||
: heightOffset;
|
||||
localBarPosition = new Vector3(0f, top.y + localHeightOffset, 0f);
|
||||
}
|
||||
// 创建世界空间 Canvas、边框和绿色血量填充。
|
||||
private void CreateBar()
|
||||
@@ -343,6 +353,7 @@ public class WorldHealthBar : MonoBehaviour
|
||||
barRect.sizeDelta = new Vector2(PixelWidth, TotalPixelHeight);
|
||||
barRect.localScale = Vector3.one * (worldWidth / PixelWidth);
|
||||
barRect.localPosition = GetBarRootPosition();
|
||||
ApplyScaleCompensation();
|
||||
|
||||
RectTransform healthRow = CreateRow(barObject.transform, "HealthBar", PixelWidth, PixelHeight, 0);
|
||||
Image background = CreateImage("Border", healthRow, RoundedSprite(), borderColor);
|
||||
@@ -383,12 +394,25 @@ public class WorldHealthBar : MonoBehaviour
|
||||
energyFillImage = energyInner;
|
||||
}
|
||||
|
||||
private void ApplyScaleCompensation()
|
||||
{
|
||||
Vector3 parentScale = transform.lossyScale;
|
||||
float targetScale = worldWidth / PixelWidth;
|
||||
barRect.localScale = new Vector3(
|
||||
parentScale.x != 0f ? targetScale / parentScale.x : targetScale,
|
||||
parentScale.y != 0f ? targetScale / parentScale.y : targetScale,
|
||||
parentScale.z != 0f ? targetScale / parentScale.z : targetScale);
|
||||
}
|
||||
|
||||
// 返回整体 Canvas 的位置,使血条中心保持原来的高度。
|
||||
private Vector3 GetBarRootPosition()
|
||||
{
|
||||
float pixelToWorld = worldWidth / PixelWidth;
|
||||
float energyOffset = (TotalPixelHeight - PixelHeight) * 0.5f * pixelToWorld;
|
||||
return localBarPosition - Vector3.up * energyOffset;
|
||||
float worldEnergyOffset = (TotalPixelHeight - PixelHeight) * 0.5f * pixelToWorld;
|
||||
float localEnergyOffset = transform.lossyScale.y != 0f
|
||||
? worldEnergyOffset / transform.lossyScale.y
|
||||
: worldEnergyOffset;
|
||||
return localBarPosition - Vector3.up * localEnergyOffset;
|
||||
}
|
||||
|
||||
// 创建一行固定像素高度的世界空间 UI。
|
||||
|
||||
Reference in new issue
Block a user