using QFramework; using System.Collections; using System.Collections.Generic; using UnityEngine; using XMLTool; public class PlayerController : MonoSingleton { private PlayerController() { } public class HasDevice { public Device device; public int count; } Dictionary hasDevices = new Dictionary(); 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) }); } } }