49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class RotateCameraStep : MonoBehaviour //could be an interface and just use generic methods like start validate end etc
|
|
{
|
|
[SerializeField]
|
|
private Camera mainCam;
|
|
|
|
private bool hasSetXInput = false, hasSetYInput = false;
|
|
|
|
public BaseStepController baseStepController;
|
|
|
|
private float initialXRotation, initialYRotation;
|
|
|
|
private Transform cameraTransform;
|
|
|
|
private void Awake()
|
|
{
|
|
if (mainCam)
|
|
{
|
|
cameraTransform = mainCam.transform;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
baseStepController.OnEvaluationStart += () => { StartCoroutine(WaitForXCameraInput()); StartCoroutine(WaitForYCameraInput()); };
|
|
baseStepController.ConditionsAreMet += () => hasSetXInput && hasSetYInput;
|
|
}
|
|
|
|
private IEnumerator WaitForXCameraInput()
|
|
{
|
|
initialXRotation = cameraTransform.rotation.eulerAngles.x;
|
|
yield return new WaitUntil(() => cameraTransform.rotation.eulerAngles.x != initialXRotation);
|
|
hasSetXInput = true;
|
|
}
|
|
|
|
private IEnumerator WaitForYCameraInput()
|
|
{
|
|
initialYRotation = cameraTransform.rotation.eulerAngles.y;
|
|
yield return new WaitUntil(() => cameraTransform.rotation.eulerAngles.y != initialYRotation);
|
|
hasSetYInput = true;
|
|
}
|
|
}
|
|
} |