59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System.Collections;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
public class Key : MonoBehaviour
|
|
{
|
|
public bool isSelected = false;
|
|
public Vector3 insertedRotation;
|
|
public Vector3 insertedOffset;
|
|
public Vector3 wiggleOffset = new Vector3(0, 0, 10);
|
|
public float lockoutDuration = 3;
|
|
public InserKeysMinigameManager manager;
|
|
|
|
private Vector3 startPosition;
|
|
private Vector3 startRotation;
|
|
|
|
void Start()
|
|
{
|
|
startPosition = transform.parent.position;
|
|
startRotation = transform.parent.eulerAngles;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void OnMouseDown()
|
|
{
|
|
if (manager.isInputLocked) return;
|
|
|
|
isSelected = true;
|
|
Debug.Log("Key tapped - isSelected is now: " + isSelected);
|
|
}
|
|
|
|
public IEnumerator HandleWrongAttempt()
|
|
{
|
|
manager.isInputLocked = true;
|
|
|
|
Vector3 baseRot = transform.parent.eulerAngles;
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
transform.parent.eulerAngles = baseRot + wiggleOffset;
|
|
yield return new WaitForSeconds(0.08f);
|
|
transform.parent.eulerAngles = baseRot - wiggleOffset;
|
|
yield return new WaitForSeconds(0.08f);
|
|
}
|
|
transform.parent.eulerAngles = baseRot;
|
|
|
|
yield return new WaitForSeconds(lockoutDuration - 0.48f);
|
|
|
|
transform.parent.position = startPosition;
|
|
transform.parent.eulerAngles = startRotation;
|
|
isSelected = false;
|
|
|
|
manager.isInputLocked = false;
|
|
}
|
|
}
|