using System.Collections;
using System.Collections.Generic;
public InputValue(AttackButton _button, InputType _type, float _time)
public AttackButton button;
public class InputSystem : Singleton<InputSystem>
public float inputLifetime = 2f;
List<InputValue> buffer = new List<InputValue>();
string bufferString = "";
for (int i = buffer.Count - 1; i >= 0; --i)
if (buffer[i].lifetime <= Time.time)
for (int i = buffer.Count - 1; i >= 0; --i)
bufferString += buffer[i].button + " ";
checkByKeycode(AttackButton.A, KeyCode.Joystick1Button0);
checkByKeycode(AttackButton.B, KeyCode.Joystick1Button1);
checkByKeycode(AttackButton.X, KeyCode.Joystick1Button2);
checkByKeycode(AttackButton.Y, KeyCode.Joystick1Button3);
if (Input.GetAxis("ControllerTriggers") < 0)
buffer.Add(new InputValue(AttackButton.LEFT_TRIGGER, InputType.HOLD, Time.time + inputLifetime));
if (Input.GetAxis("ControllerTriggers") > 0)
buffer.Add(new InputValue(AttackButton.RIGHT_TRIGGER, InputType.HOLD, Time.time + inputLifetime));
void checkByKeycode(AttackButton _button, KeyCode _code)
if (Input.GetKeyDown(_code))
buffer.Add(new InputValue(_button, InputType.DOWN, Time.time + inputLifetime));
else if (Input.GetKey(_code))
buffer.Add(new InputValue(_button, InputType.HOLD, Time.time + inputLifetime));
else if (Input.GetKeyUp(_code))
buffer.Add(new InputValue(_button, InputType.UP, Time.time + inputLifetime));
public static bool GetButtonDown(AttackButton _button)
foreach (InputValue value in Instance.buffer)
if (value.button == _button && value.type == InputType.DOWN)
public static bool GetButton(AttackButton _button)
foreach (InputValue value in Instance.buffer)
if (value.button == _button && value.type == InputType.HOLD)
public static bool GetButtonUp(AttackButton _button)
foreach (InputValue value in Instance.buffer)
if (value.button == _button && value.type == InputType.UP)