48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Beyond;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MoveStep : MonoBehaviour
|
|
{
|
|
private const float movementThreshold = 0.75f;
|
|
|
|
[SerializeField]
|
|
private Transform movementTransform;
|
|
|
|
private float startingPositionX, startingPositionZ;
|
|
|
|
private bool xMovement = false, yMovement = false;
|
|
|
|
public BaseStepController baseStepController;
|
|
|
|
private void Awake()
|
|
{
|
|
baseStepController.OnEvaluationStart += () =>
|
|
{
|
|
startingPositionX = movementTransform.position.x;
|
|
startingPositionZ = movementTransform.position.z;
|
|
StartCoroutine(WaitForHorizontalInput());
|
|
StartCoroutine(WaitForVerticalInput());
|
|
};
|
|
baseStepController.ConditionsAreMet += () => xMovement && yMovement;
|
|
}
|
|
|
|
private IEnumerator WaitForHorizontalInput()
|
|
{
|
|
yield return new WaitUntil(() => MathF.Abs(movementTransform.position.x - startingPositionX) > movementThreshold);
|
|
xMovement = true;
|
|
}
|
|
|
|
private IEnumerator WaitForVerticalInput()
|
|
{
|
|
yield return new WaitUntil(() => MathF.Abs(movementTransform.position.z - startingPositionZ) > movementThreshold);
|
|
yMovement = true;
|
|
}
|
|
|
|
private IEnumerator WaitForMovementInput()
|
|
{
|
|
yield return new WaitUntil(() => xMovement && yMovement);
|
|
}
|
|
} |