건축 및 고용에 비용 소모 기능 추가
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Northbound
|
||||
public float followDistance = 3f;
|
||||
public float movementSpeed = 3.5f;
|
||||
public int resourcesPerMining = 5;
|
||||
public int recruitmentCost = 10;
|
||||
|
||||
[Header("Interaction")]
|
||||
public string interactionAnimationTrigger = "Recruit";
|
||||
@@ -320,7 +321,17 @@ namespace Northbound
|
||||
|
||||
public bool CanInteract(ulong playerId)
|
||||
{
|
||||
return _ownerPlayerId.Value == ulong.MaxValue || _ownerPlayerId.Value == playerId;
|
||||
if (_ownerPlayerId.Value != ulong.MaxValue && _ownerPlayerId.Value != playerId)
|
||||
return false;
|
||||
|
||||
if (_ownerPlayerId.Value == ulong.MaxValue)
|
||||
{
|
||||
var coreResourceManager = CoreResourceManager.Instance;
|
||||
if (coreResourceManager != null && !coreResourceManager.CanAfford(recruitmentCost))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Interact(ulong playerId)
|
||||
@@ -348,6 +359,20 @@ namespace Northbound
|
||||
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
|
||||
private void RecruitWorkerServerRpc(ulong playerId, ulong workerNetObjectId)
|
||||
{
|
||||
var coreResourceManager = CoreResourceManager.Instance;
|
||||
if (coreResourceManager == null)
|
||||
{
|
||||
Debug.LogWarning("[Worker] CoreResourceManager 인스턴스를 찾을 수 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!coreResourceManager.CanAfford(recruitmentCost))
|
||||
{
|
||||
Debug.LogWarning($"[Worker] 코어 자원이 부족합니다. 필요: {recruitmentCost}");
|
||||
return;
|
||||
}
|
||||
|
||||
coreResourceManager.SpendResources(recruitmentCost);
|
||||
_ownerPlayerId.Value = playerId;
|
||||
SetState(WorkerState.Following);
|
||||
UpdatePlayerTransform();
|
||||
@@ -389,7 +414,11 @@ namespace Northbound
|
||||
{
|
||||
if (_ownerPlayerId.Value == ulong.MaxValue)
|
||||
{
|
||||
return "[E] 워커 채용";
|
||||
var coreResourceManager = CoreResourceManager.Instance;
|
||||
if (coreResourceManager != null && !coreResourceManager.CanAfford(recruitmentCost))
|
||||
return $"자원 부족 (필요: {recruitmentCost})";
|
||||
|
||||
return $"[E] 워커 채용 - 비용: {recruitmentCost}";
|
||||
}
|
||||
else if (NetworkManager.Singleton != null && _ownerPlayerId.Value == NetworkManager.Singleton.LocalClientId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user