Files
GeoSusGame/Assets/KeyInsertMinigameAssets/Scripts/KeyHole.cs

46 lines
897 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.parent.position = transform.position + key.insertedOffset;
key.transform.parent.eulerAngles = key.insertedRotation;
Debug.Log("Key teleported to keyhole " + index);
if (manager.CheckKeyHole(index))
{
Debug.Log("Correct, You Win");
}
else
{
Debug.Log("Wrong");
key.StartCoroutine(key.HandleWrongAttempt());
}
}
}
}