건설 모드에서 클릭이 잘 작동하지 않는 문제 수정
건설 모드 UI가 클릭되어 건설되지 않는 문제 수정 JMO Asset 위치 조정 Tower, Monster, Creep의 Hit/Destroy FX Prefab 설정 (Template Level) Tower에 체력바 추가 (최초 건설 시, 체력 변경 시 등장) Tower 관련 디버깅 로그 정리 건설 토대의 사이즈가 비정상적인 문제 수정
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Northbound
|
||||
public float heightOffset = 3f;
|
||||
public bool hideWhenFull = true;
|
||||
public float hideDelay = 3f;
|
||||
public float initialShowDuration = 2f; // 건설 완료 시 체력바 표시 시간
|
||||
|
||||
[Header("Colors")]
|
||||
public Color fullHealthColor = Color.green;
|
||||
@@ -28,8 +29,9 @@ namespace Northbound
|
||||
|
||||
private Building _building;
|
||||
private Camera _mainCamera;
|
||||
private float _lastDamageTime;
|
||||
private float _lastShowTime;
|
||||
private Canvas _canvas;
|
||||
private bool _initialized = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -59,6 +61,28 @@ namespace Northbound
|
||||
{
|
||||
_building = building;
|
||||
transform.localPosition = Vector3.up * heightOffset;
|
||||
|
||||
// 건설 완료 시 체력바 표시
|
||||
ShowBar(initialShowDuration);
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 체력바를 지정된 시간 동안 표시
|
||||
/// </summary>
|
||||
public void ShowBar(float duration = 0f)
|
||||
{
|
||||
if (barContainer != null)
|
||||
{
|
||||
barContainer.SetActive(true);
|
||||
_lastShowTime = Time.time;
|
||||
|
||||
// duration이 0보다 크면 그 시간 동안만 표시
|
||||
if (duration > 0)
|
||||
{
|
||||
_lastShowTime = Time.time + duration - hideDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateHealth(int currentHealth, int maxHealth)
|
||||
@@ -77,12 +101,8 @@ namespace Northbound
|
||||
healthText.text = $"{currentHealth}/{maxHealth}";
|
||||
}
|
||||
|
||||
// 체력바 표시/숨김
|
||||
if (barContainer != null)
|
||||
{
|
||||
_lastDamageTime = Time.time;
|
||||
barContainer.SetActive(true);
|
||||
}
|
||||
// 체력 변경 시 체력바 표시
|
||||
ShowBar();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -94,11 +114,11 @@ namespace Northbound
|
||||
}
|
||||
|
||||
// 체력이 가득 차면 숨김
|
||||
if (hideWhenFull && barContainer != null && _building != null)
|
||||
if (hideWhenFull && barContainer != null && _building != null && _initialized)
|
||||
{
|
||||
float healthPercentage = _building.GetHealthPercentage();
|
||||
|
||||
if (healthPercentage >= 1f && Time.time - _lastDamageTime > hideDelay)
|
||||
|
||||
if (healthPercentage >= 1f && Time.time - _lastShowTime > hideDelay)
|
||||
{
|
||||
barContainer.SetActive(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user