Files
HauntedBloodlines/Assets/Scripts/Puzzles/Mannequin/MannequinHandsMovementExtension.cs
2025-05-29 22:31:40 +03:00

45 lines
1.3 KiB
C#

using System.Collections;
using UnityEngine;
public class MannequinHandsMovementExtension : MonoBehaviour
{
public float secondsToWaitForLeftHandEvent;
public float secondsToWaitForRightHandEvent;
private Coroutine leftHandDoEventAfterSeconds;
private Coroutine rightHandDoEventAfterSeconds;
[SerializeField] private EventTrigger leftHandEventTrigger;
[SerializeField] private EventTrigger rightHandEventTrigger;
public void LeftHandDoEvent()
{
if (leftHandDoEventAfterSeconds != null)
{
leftHandDoEventAfterSeconds = StartCoroutine(LeftHandDoEventAfterSeconds());
}
}
public void RightHandDoEvent()
{
if (rightHandDoEventAfterSeconds != null)
{
rightHandDoEventAfterSeconds = StartCoroutine(RightHandDoEventAfterSeconds());
}
}
IEnumerator LeftHandDoEventAfterSeconds()
{
yield return new WaitForSeconds(secondsToWaitForLeftHandEvent);
leftHandEventTrigger.Invoke();
leftHandDoEventAfterSeconds = null;
}
IEnumerator RightHandDoEventAfterSeconds()
{
yield return new WaitForSeconds(secondsToWaitForRightHandEvent);
rightHandEventTrigger.Invoke();
rightHandDoEventAfterSeconds = null;
}
}