Files
Northbound/Assets/Scripts/CoreResourceManager.cs
dal4segno f3923079a4 건설 모드에서 클릭이 잘 작동하지 않는 문제 수정
건설 모드 UI가 클릭되어 건설되지 않는 문제 수정
JMO Asset 위치 조정
Tower, Monster, Creep의 Hit/Destroy FX Prefab 설정 (Template Level)
Tower에 체력바 추가 (최초 건설 시, 체력 변경 시 등장)
Tower 관련 디버깅 로그 정리
건설 토대의 사이즈가 비정상적인 문제 수정
2026-02-25 01:41:58 +09:00

81 lines
2.0 KiB
C#

using Unity.Netcode;
using UnityEngine;
namespace Northbound
{
/// <summary>
/// Core의 자원을 관리하고 다른 시스템에서 접근할 수 있도록 하는 매니저
/// </summary>
public class CoreResourceManager : MonoBehaviour
{
private static CoreResourceManager _instance;
public static CoreResourceManager Instance => _instance;
[Header("References")]
public Core mainCore; // 메인 코어 참조
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
}
/// <summary>
/// 자원을 사용할 수 있는지 확인
/// </summary>
public bool CanAfford(int cost)
{
if (mainCore == null)
{
Debug.LogWarning("메인 코어가 설정되지 않았습니다.");
return false;
}
return mainCore.CanConsumeResource(cost);
}
/// <summary>
/// 자원을 소비
/// </summary>
public void SpendResources(int amount)
{
if (mainCore == null)
{
Debug.LogWarning("메인 코어가 설정되지 않았습니다.");
return;
}
mainCore.ConsumeResourceServerRpc(amount);
}
/// <summary>
/// 자원을 환불 (건설 실패 시 등)
/// </summary>
public void AddResources(int amount)
{
if (mainCore == null)
{
Debug.LogWarning("메인 코어가 설정되지 않았습니다.");
return;
}
mainCore.AddResource(amount);
}
/// <summary>
/// 현재 자원량 가져오기
/// </summary>
public int GetCurrentResources()
{
if (mainCore == null)
return 0;
return mainCore.TotalResources;
}
}
}