diff --git a/Assets/Scripts/Controller/PlayerController.cs b/Assets/Scripts/Controller/PlayerController.cs new file mode 100644 index 00000000..d9bb945b --- /dev/null +++ b/Assets/Scripts/Controller/PlayerController.cs @@ -0,0 +1,45 @@ +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) }); + } + + } + +} diff --git a/Assets/Scripts/Controller/PlayerController.cs.meta b/Assets/Scripts/Controller/PlayerController.cs.meta new file mode 100644 index 00000000..5daecb62 --- /dev/null +++ b/Assets/Scripts/Controller/PlayerController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d963e03aaa61c0241a2a7b3a8e7bf611 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index ebc95d0e..f7cd8253 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -58,6 +58,8 @@ namespace XMLTool public string BoxColliderCenter { get; set; } public bool MeshCollider { get; set; } + + public int Count = -1; }