Files

46 lines
889 B
C#

using UnityEngine;
public class KeyHole : MonoBehaviour
{
public int index;
public Key key;
public InserKeysMinigameManager manager;
void Start()
{
}
void Update()
{
}
void OnMouseDown()
{
if (manager.isInputLocked) return;
Debug.Log("Keyhole " + index + " was tapped.");
if (key.isSelected)
{
key.transform.position = transform.position + key.insertedOffset;
key.transform.eulerAngles = key.insertedRotation;
Debug.Log("Key teleported to keyhole " + index);
if (manager.CheckKeyHole(index))
{
key.StartCoroutine(key.HandleWin());
}
else
{
Debug.Log("Wrong");
key.StartCoroutine(key.HandleWrongAttempt());
}
}
}
}