아이템 드랍 및 인벤토리 기능 구현
This commit is contained in:
23
Assets/Scripts/Player/PlayerInventory.cs
Normal file
23
Assets/Scripts/Player/PlayerInventory.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class PlayerInventory : NetworkBehaviour
|
||||
{
|
||||
// 아이템 이름과 개수를 저장
|
||||
private Dictionary<string, int> items = new Dictionary<string, int>();
|
||||
|
||||
public void AddItem(ItemData data)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
|
||||
if (items.ContainsKey(data.itemName))
|
||||
items[data.itemName]++;
|
||||
else
|
||||
items.Add(data.itemName, 1);
|
||||
|
||||
Debug.Log($"[Inventory] {data.itemName} 획득! (현재: {items[data.itemName]}개)");
|
||||
|
||||
// 여기서 클라이언트 UI를 갱신하는 ClientRpc를 호출할 수 있습니다.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user