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

public class QTE : MonoBehaviour
{
    public float maxTime = 1.0f;
    public KeyCode buttonToPress = KeyCode.A;
    public bool completed = false;

	bool active = false;
	LevelManager levelManager;
	EnterLight player;
	InputToPress inputToPressUI;

    // Start is called before the first frame update
    void Start()
    {
		player = FindObjectOfType<EnterLight>();
		levelManager = FindObjectOfType<LevelManager>();
		inputToPressUI = FindObjectOfType<InputToPress>();

	}

    // Update is called once per frame
    void Update()
    {

	}

	private void OnTriggerEnter(Collider other) {
		if (!completed) {
			KeyCode[] arr = new KeyCode[] { KeyCode.W, KeyCode.A, KeyCode.S, KeyCode.D };
			buttonToPress = arr[Random.Range(0, arr.Length)];
			Debug.Log("Collison: " + name + ", " + buttonToPress);
			levelManager.beginQTE(player, this);
			inputToPressUI.Activate(buttonToPress, maxTime);
			completed = true;
		}
	}
}
