summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Input
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-17 10:12:31 +0800
committerchai <chaifix@163.com>2020-10-17 10:12:31 +0800
commitf99c4d56cf95c563e95d3965ffd6d8ba33b660ee (patch)
treecbec1f362d5eb0fd2ee67885cae17a527796f41c /Assets/Scripts/Input
parentecb0cbe03d3eef32fdb7b43fa3c60f0f241b0129 (diff)
*ability system
Diffstat (limited to 'Assets/Scripts/Input')
-rw-r--r--Assets/Scripts/Input/Command.cs4
-rw-r--r--Assets/Scripts/Input/InputManager.cs15
2 files changed, 17 insertions, 2 deletions
diff --git a/Assets/Scripts/Input/Command.cs b/Assets/Scripts/Input/Command.cs
index 7649af58..fae88684 100644
--- a/Assets/Scripts/Input/Command.cs
+++ b/Assets/Scripts/Input/Command.cs
@@ -24,7 +24,9 @@ public struct Command
{
public CommandCode code; // 指令码
public float time; // 触发时间
- public int id;
+ public int id;
+
+ public static Command Blank = new Command(CommandCode.Blank, 0);
public Command(CommandCode code, float time)
{
diff --git a/Assets/Scripts/Input/InputManager.cs b/Assets/Scripts/Input/InputManager.cs
index 95f63ad7..25daf848 100644
--- a/Assets/Scripts/Input/InputManager.cs
+++ b/Assets/Scripts/Input/InputManager.cs
@@ -5,9 +5,18 @@ using UnityEngine;
public class InputManager : Singleton<InputManager>
{
private List<Command> m_CommandRecord;
- private Command m_CurrentCommand;
private readonly int kCommandRecords = 10;
+ // 本帧内的指令,会在下一帧被清空
+ private Command m_CurrentCommand;
+ public Command CurrentCommand
+ {
+ get
+ {
+ return m_CurrentCommand;
+ }
+ }
+
public void Init()
{
m_CommandRecord = new List<Command>();
@@ -48,6 +57,10 @@ public class InputManager : Singleton<InputManager>
if(m_CommandRecord.Count > 10)
m_CommandRecord.RemoveRange(0, m_CommandRecord.Count - 10);
}
+ else if(m_CurrentCommand.code != CommandCode.Blank)
+ {
+ m_CurrentCommand = Command.Blank;
+ }
}
string CommandCodeToString(CommandCode cmd)