2025-05-08 17:21:26 +08:00

46 lines
1016 B
C#

using QFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XMLTool;
public class PlayerController : MonoSingleton<PlayerController>
{
private PlayerController() { }
public class HasDevice
{
public Device device;
public int count;
}
Dictionary<string, HasDevice> hasDevices = new Dictionary<string, HasDevice>();
public void DropDevice(string key, int count = 1)
{
if (hasDevices.ContainsKey(key))
{
hasDevices[key].count -= count;
if (hasDevices[key].count <= 0)
{
hasDevices.Remove(key);
}
}
}
public void PickDevice(string key, int count = 1)
{
if (hasDevices.ContainsKey(key))
{
hasDevices[(string)key].count += count;
}
else
{
hasDevices.Add(key, new HasDevice() { count = count, device = DeviceController.Instance.GetDevice(key) });
}
}
}