根据提供的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,78 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 金矿建筑,定时产出金币
|
||||
/// </summary>
|
||||
public class GoldMine : MonoBehaviour
|
||||
{
|
||||
[Header("金币产出")]
|
||||
[Tooltip("每次产出的金币数量")]
|
||||
[SerializeField] private int goldPerProduction = 50;
|
||||
|
||||
[Tooltip("产出间隔(秒)")]
|
||||
[SerializeField] private float productionInterval = 5f;
|
||||
|
||||
[Header("可选:血条和进度条")]
|
||||
[SerializeField] private WorldHealthBar healthBar;
|
||||
|
||||
private float productionTimer = 0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 如果没有手动指定,尝试自动获取
|
||||
if (healthBar == null)
|
||||
{
|
||||
healthBar = GetComponent<WorldHealthBar>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 初始化进度条(使用能量条显示产出进度)
|
||||
if (healthBar != null)
|
||||
{
|
||||
healthBar.maxEnergy = 100f;
|
||||
healthBar.currentEnergy = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GoldManager.Instance == null) return;
|
||||
|
||||
productionTimer += Time.deltaTime;
|
||||
|
||||
// 更新进度条
|
||||
if (healthBar != null)
|
||||
{
|
||||
float progress = Mathf.Clamp01(productionTimer / productionInterval);
|
||||
healthBar.currentEnergy = progress * 100f;
|
||||
}
|
||||
|
||||
// 达到产出时间
|
||||
if (productionTimer >= productionInterval)
|
||||
{
|
||||
ProduceGold();
|
||||
productionTimer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProduceGold()
|
||||
{
|
||||
if (GoldManager.Instance != null)
|
||||
{
|
||||
GoldManager.Instance.AddGold(goldPerProduction);
|
||||
Debug.Log($"{gameObject.name} 产出金币 +{goldPerProduction}");
|
||||
|
||||
// 可以在这里播放特效和音效
|
||||
// TODO: 添加金币产出特效
|
||||
}
|
||||
}
|
||||
|
||||
// 在编辑器中显示信息
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(transform.position + Vector3.up * 2f, 0.5f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user