using UnityEngine;
namespace NextMind.Examples.NeuroTagGallery
{
///
/// Implementation of a .
/// During this step, one light of the environment is shut down and a point light is going left and right to show the difference between a lit and an unlit material.
///
public class LitUnlitStep : NeuroTagGalleryStep
{
[Header("Light")]
///
/// The light that will move left to right.
///
[SerializeField]
private Light rotatingLight;
///
/// The speed of the light movement.
///
[SerializeField]
private float speed;
///
/// The max rotation possible to the left for the moving light.
///
private Quaternion rotationLeft;
///
/// The max rotation possible to the right for the moving light.
///
private Quaternion rotationRight;
private float timer = 0f;
#region AbstractStep implementation
public override void OnEnterStep()
{
HubManager.Instance.ActivateLight(false);
}
public override void OnExitStep()
{
var hubManager = HubManager.Instance;
if (hubManager)
{
hubManager.ActivateLight(true);
}
}
#endregion
protected override void Awake()
{
base.Awake();
// Set the maximum rotation values.
rotationLeft = Quaternion.Euler(0f, -45f, 0f);
rotationRight = Quaternion.Euler(0f, 45f, 0f);
}
protected override void UpdateAnimation()
{
base.UpdateAnimation();
timer += Time.deltaTime;
float progress = (Mathf.Sin(timer * speed) + 1) / 2;
rotatingLight.transform.rotation = Quaternion.Lerp(rotationLeft, rotationRight, progress);
}
}
}