新增人物控制类
This commit is contained in:
parent
bc0f6483b3
commit
5e11329b86
45
Assets/Scripts/Controller/PlayerController.cs
Normal file
45
Assets/Scripts/Controller/PlayerController.cs
Normal file
@ -0,0 +1,45 @@
|
||||
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) });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Controller/PlayerController.cs.meta
Normal file
11
Assets/Scripts/Controller/PlayerController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d963e03aaa61c0241a2a7b3a8e7bf611
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -58,6 +58,8 @@ namespace XMLTool
|
||||
public string BoxColliderCenter { get; set; }
|
||||
public bool MeshCollider { get; set; }
|
||||
|
||||
|
||||
public int Count = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user