```
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
@@ -0,0 +1,60 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GoldSystem : MonoBehaviour
|
||||
{
|
||||
public static GoldSystem Instance { get; private set; }
|
||||
|
||||
[Header("金币配置")]
|
||||
[Min(0)] public int startingGold = 200;
|
||||
[Min(0)] public int maxGold = 9999;
|
||||
|
||||
[Header("UI(可选)")]
|
||||
public Text goldText;
|
||||
|
||||
public int CurrentGold { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
CurrentGold = startingGold;
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public bool TrySpend(int amount)
|
||||
{
|
||||
if (amount < 0 || CurrentGold < amount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CurrentGold -= amount;
|
||||
UpdateUI();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddGold(int amount)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentGold = Mathf.Min(CurrentGold + amount, maxGold);
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (goldText != null)
|
||||
{
|
||||
goldText.text = CurrentGold.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user