53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class QTECanvas : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject m_qteButton;
|
|
|
|
private static QTECanvas s_instance;
|
|
public static QTECanvas Instance => s_instance;
|
|
|
|
public Action m_OnQTEHit;
|
|
public Action m_OnQTEMissed;
|
|
|
|
private void Awake()
|
|
{
|
|
if (s_instance != null)
|
|
{
|
|
Destroy(gameObject);
|
|
Debug.LogError("QTE already exists! Destroying");
|
|
return;
|
|
}
|
|
|
|
s_instance = this;
|
|
}
|
|
|
|
public void OnQTEHit()
|
|
{
|
|
//place for some visual/UI actions
|
|
m_OnQTEHit?.Invoke();
|
|
Debug.Log("OnQTEHit");
|
|
}
|
|
|
|
public void OnQTEMissed()
|
|
{
|
|
m_OnQTEMissed?.Invoke();
|
|
Debug.Log("OnQTEMissed");
|
|
}
|
|
|
|
public QTEButton SpawnButton(QTEElement element)
|
|
{
|
|
QTEButton button = Instantiate(m_qteButton).GetComponent<QTEButton>();
|
|
button.m_QteElement = new QTEElement(element);
|
|
var btnTransform = button.transform;
|
|
button.m_OnHit += OnQTEHit;
|
|
button.m_OnMissed += OnQTEMissed;
|
|
btnTransform.SetParent(transform);
|
|
btnTransform.localPosition = element.m_startingPos;
|
|
return button;
|
|
}
|
|
}
|
|
} |