using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class JoystickInputHandler : InputHandler {
	//Key List -- 0 Left; 1 Right; 2 Jump; 3 Break
	public int joystickNumber = 1;
	private bool[] keyStates = new bool[4];

	//Key checking each frame
	void Update () {
		for (int i = 0; i < 4; i++) {
			keyStates [i] = false;
		}
		
		if (Input.GetAxis ("HorizontalJ" + joystickNumber) < -0.85f) {
			keyStates [0] = true;
		} else if (Input.GetAxis ("HorizontalJ" + joystickNumber) > 0.85f) {
			keyStates [1] = true;
		}
		
		if (Input.GetAxis ("VerticalJ" + joystickNumber) < -0.85f) {
			keyStates [2] = true;
		} else if (Input.GetAxis ("VerticalJ" + joystickNumber) > 0.85f) {
			keyStates [3] = true;
		}
	}

	//Method called by front classes
	public override bool GetButton(int key){
		return keyStates[key];
	}
}
