네트워크 멀티플레이 대응
This commit is contained in:
@@ -50,7 +50,7 @@ namespace Northbound
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
if (IsServer)
|
||||
if (IsOwner)
|
||||
{
|
||||
_totalResources.Value = 0;
|
||||
_currentHealth.Value = maxHealth;
|
||||
@@ -88,7 +88,7 @@ namespace Northbound
|
||||
|
||||
public void TakeDamage(int damage, ulong attackerId)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (!IsOwner) return;
|
||||
if (_currentHealth.Value <= 0) return;
|
||||
|
||||
int actualDamage = Mathf.Min(damage, _currentHealth.Value);
|
||||
@@ -108,7 +108,7 @@ namespace Northbound
|
||||
|
||||
private void OnCoreDestroyed()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (!IsOwner) return;
|
||||
|
||||
Debug.Log($"<color=red>[Core] 코어가 파괴되었습니다! 게임 오버!</color>");
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Northbound
|
||||
/// </summary>
|
||||
public void AddResource(int amount)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (!IsOwner) return;
|
||||
|
||||
if (!unlimitedStorage)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ namespace Northbound
|
||||
{
|
||||
if (client.PlayerObject != null)
|
||||
{
|
||||
var playerInventory = client.PlayerObject.GetComponent<PlayerResourceInventory>();
|
||||
var playerInventory = client.PlayerObject.GetComponent<PlayerInventory>();
|
||||
if (playerInventory != null)
|
||||
{
|
||||
// 플레이어가 자원을 가지고 있어야 함
|
||||
@@ -264,10 +264,10 @@ namespace Northbound
|
||||
if (playerObject == null)
|
||||
return;
|
||||
|
||||
var playerInventory = playerObject.GetComponent<PlayerResourceInventory>();
|
||||
var playerInventory = playerObject.GetComponent<PlayerInventory>();
|
||||
if (playerInventory == null)
|
||||
{
|
||||
Debug.LogWarning($"플레이어 {playerId}에게 PlayerResourceInventory 컴포넌트가 없습니다.");
|
||||
Debug.LogWarning($"플레이어 {playerId}에게 PlayerInventory 컴포넌트가 없습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -304,8 +304,8 @@ namespace Northbound
|
||||
return;
|
||||
}
|
||||
|
||||
// 플레이어로부터 자원 차감
|
||||
playerInventory.RemoveResourceServerRpc(depositAmount);
|
||||
// 플레이어로부터 자원 차감 (RPC로 owner에게 요청)
|
||||
playerInventory.RemoveResourcesRpc(depositAmount);
|
||||
|
||||
// 코어에 자원 추가
|
||||
_totalResources.Value += depositAmount;
|
||||
|
||||
Reference in New Issue
Block a user