From c74d6d2ebdb2f4eb73f6a50c9af4b7d968e200b6 Mon Sep 17 00:00:00 2001 From: dal4segno Date: Wed, 4 Feb 2026 11:18:54 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4=EC=9D=98?= =?UTF-8?q?=20=EC=B5=9C=EB=8C=80=20=EC=9E=90=EC=9B=90=EC=9D=B4=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=EC=97=90=20=EC=A0=95=EC=9D=98?= =?UTF-8?q?=ED=95=9C=20=EA=B0=92=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 50으로 설정해도 100으로 작동하는 문제가 해결됨 --- Assets/Prefabs/Resource.prefab | 2 +- Assets/Scenes/GameMain.unity | 2 +- Assets/Scripts/PlayerResourceInventory.cs | 11 ++++++++ Assets/Scripts/ServerResourceManager.cs | 31 ++++++++++++++++++----- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Assets/Prefabs/Resource.prefab b/Assets/Prefabs/Resource.prefab index f0c4c6a..339c590 100644 --- a/Assets/Prefabs/Resource.prefab +++ b/Assets/Prefabs/Resource.prefab @@ -76,7 +76,7 @@ MonoBehaviour: maxResources: 200 resourcesPerGathering: 10 gatheringCooldown: 0 - resourceName: "\uAD11\uC11D" + resourceName: Mana rechargeInterval: 1 rechargeAmount: 5 _qualityPercentage: diff --git a/Assets/Scenes/GameMain.unity b/Assets/Scenes/GameMain.unity index a13f6e4..d462488 100644 --- a/Assets/Scenes/GameMain.unity +++ b/Assets/Scenes/GameMain.unity @@ -3482,7 +3482,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4412526746668541195, guid: 274613c415998a647a86a5e09950ce41, type: 3} propertyPath: m_AnchoredPosition.y - value: 0 + value: -100 objectReference: {fileID: 0} - target: {fileID: 4412526746668541195, guid: 274613c415998a647a86a5e09950ce41, type: 3} propertyPath: m_LocalEulerAnglesHint.x diff --git a/Assets/Scripts/PlayerResourceInventory.cs b/Assets/Scripts/PlayerResourceInventory.cs index 222dd25..b015eee 100644 --- a/Assets/Scripts/PlayerResourceInventory.cs +++ b/Assets/Scripts/PlayerResourceInventory.cs @@ -11,10 +11,21 @@ namespace Northbound public int CurrentResourceAmount => _displayAmount; public int MaxResourceCapacity => maxResourceCapacity; + [Rpc(SendTo.Server)] + private void SetMaxCapacityServerRpc(int maxCapacity) + { + var resourceManager = ServerResourceManager.Instance; + if (resourceManager != null) + { + resourceManager.SetPlayerMaxCapacity(OwnerClientId, maxCapacity); + } + } + public override void OnNetworkSpawn() { if (IsClient && IsOwner) { + SetMaxCapacityServerRpc(maxResourceCapacity); RequestResourceUpdateServerRpc(); } } diff --git a/Assets/Scripts/ServerResourceManager.cs b/Assets/Scripts/ServerResourceManager.cs index 27e0c46..a190f2c 100644 --- a/Assets/Scripts/ServerResourceManager.cs +++ b/Assets/Scripts/ServerResourceManager.cs @@ -9,6 +9,7 @@ namespace Northbound public static ServerResourceManager Instance { get; private set; } private Dictionary _playerResources = new Dictionary(); + private Dictionary _playerMaxCapacity = new Dictionary(); private NetworkVariable _resourcesData = new NetworkVariable(); private void Awake() @@ -51,6 +52,7 @@ namespace Northbound private void OnClientDisconnected(ulong clientId) { _playerResources.Remove(clientId); + _playerMaxCapacity.Remove(clientId); } public int GetPlayerResourceAmount(ulong clientId) @@ -64,27 +66,30 @@ namespace Northbound public bool CanAddResource(ulong clientId, int amount) { - if (_playerResources.TryGetValue(clientId, out var resource)) + if (_playerResources.TryGetValue(clientId, out var resource) && + _playerMaxCapacity.TryGetValue(clientId, out var maxCapacity)) { - return resource + amount <= 100; + return resource + amount <= maxCapacity; } return false; } public int GetAvailableSpace(ulong clientId) { - if (_playerResources.TryGetValue(clientId, out var resource)) + if (_playerResources.TryGetValue(clientId, out var resource) && + _playerMaxCapacity.TryGetValue(clientId, out var maxCapacity)) { - return 100 - resource; + return maxCapacity - resource; } return 0; } public void AddResource(ulong clientId, int amount) { - if (_playerResources.TryGetValue(clientId, out var resource)) + if (_playerResources.TryGetValue(clientId, out var resource) && + _playerMaxCapacity.TryGetValue(clientId, out var maxCapacity)) { - int actualAmount = Mathf.Min(amount, 100 - resource); + int actualAmount = Mathf.Min(amount, maxCapacity - resource); _playerResources[clientId] = resource + actualAmount; } } @@ -97,5 +102,19 @@ namespace Northbound _playerResources[clientId] = resource - actualAmount; } } + + public void SetPlayerMaxCapacity(ulong clientId, int maxCapacity) + { + _playerMaxCapacity[clientId] = maxCapacity; + } + + public int GetPlayerMaxCapacity(ulong clientId) + { + if (_playerMaxCapacity.TryGetValue(clientId, out var maxCapacity)) + { + return maxCapacity; + } + return 100; + } } }