23 lines
659 B
C#
23 lines
659 B
C#
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를 호출할 수 있습니다.
|
|
}
|
|
} |