159 lines
4.5 KiB
C#
159 lines
4.5 KiB
C#
using SHADE;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
|
|
namespace SHADE_Scripting.UI
|
|
{
|
|
public class PreviewLevel : Script
|
|
{
|
|
private List<Camera> listOfCamera;
|
|
|
|
public Vector3 endPoint1;
|
|
public Vector3 endPoint2;
|
|
public Vector3 endPoint3;
|
|
|
|
public GameObject playerCamera;
|
|
public float duration = 3.0f;
|
|
|
|
private bool point1Done = false;
|
|
private bool point2Done = false;
|
|
private bool point3Done = false;
|
|
|
|
private bool reset2 = true;
|
|
private bool reset3 = true;
|
|
|
|
private bool skip = false;
|
|
[NonSerialized]
|
|
private TweenThreadVec3 moveToEndPoint1;
|
|
[NonSerialized]
|
|
private TweenThreadVec3 moveToEndPoint2;
|
|
[NonSerialized]
|
|
private TweenThreadVec3 moveToEndPoint3;
|
|
|
|
protected override void awake()
|
|
{
|
|
listOfCamera = GameObject.GetComponentsInChildren<Camera>().ToList();
|
|
|
|
if (listOfCamera.Count == 0)
|
|
Debug.LogError("EMPTY PREVIEW POINTS");
|
|
|
|
listOfCamera[0].SetMainCamera();
|
|
|
|
moveToEndPoint1 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[0].GetComponent<Transform>().LocalPosition, endPoint1, EASING_METHOD.EASE_IN_SINE);
|
|
moveToEndPoint2 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[1].GetComponent<Transform>().LocalPosition, endPoint2, EASING_METHOD.EASE_IN_SINE);
|
|
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
|
|
}
|
|
|
|
protected override void update()
|
|
{
|
|
if (!SceneFadeInOut.Instance.FadeOutFinished() && !point1Done)
|
|
{
|
|
moveToEndPoint1.Reset();
|
|
return;
|
|
}
|
|
|
|
if (Input.GetKeyUp(Input.KeyCode.Space))
|
|
{
|
|
skip = true;
|
|
point1Done = true;
|
|
SceneFadeInOut.Instance.CallFadeIn();
|
|
SceneFadeInOut.Instance.alphaValue = 0.01f;
|
|
}
|
|
|
|
if (skip && SceneFadeInOut.Instance.FadeInFinished())
|
|
{
|
|
playerCamera.GetComponent<Camera>().SetMainCamera();
|
|
SceneFadeInOut.Instance.CallFadeOut();
|
|
}
|
|
|
|
if (skip && SceneFadeInOut.Instance.FadeOutFinished())
|
|
{
|
|
GameManager.Instance.PreviewLevelDone = true;
|
|
}
|
|
|
|
|
|
if (!skip)
|
|
{
|
|
if (!point1Done)
|
|
{
|
|
listOfCamera[0].GetComponent<Transform>().LocalPosition = moveToEndPoint1.GetValue();
|
|
if (moveToEndPoint1.IsCompleted())
|
|
{
|
|
point1Done = true;
|
|
SceneFadeInOut.Instance.CallFadeIn();
|
|
SceneFadeInOut.Instance.alphaValue = 0.01f;
|
|
}
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeInFinished() && point1Done)
|
|
{
|
|
listOfCamera[1].SetMainCamera();
|
|
SceneFadeInOut.Instance.CallFadeOut();
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeOutFinished() && point1Done)
|
|
{
|
|
if (!point2Done)
|
|
{
|
|
if (reset2)
|
|
{
|
|
moveToEndPoint2.Reset();
|
|
reset2 = false;
|
|
}
|
|
listOfCamera[1].GetComponent<Transform>().LocalPosition = moveToEndPoint2.GetValue();
|
|
if (moveToEndPoint2.IsCompleted())
|
|
{
|
|
point2Done = true;
|
|
SceneFadeInOut.Instance.CallFadeIn();
|
|
SceneFadeInOut.Instance.alphaValue = 0.01f;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeInFinished() && point2Done)
|
|
{
|
|
listOfCamera[2].SetMainCamera();
|
|
SceneFadeInOut.Instance.CallFadeOut();
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeOutFinished() && point2Done)
|
|
{
|
|
if (!point3Done)
|
|
{
|
|
if (reset3)
|
|
{
|
|
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
|
|
reset3 = false;
|
|
}
|
|
listOfCamera[2].GetComponent<Transform>().LocalPosition = moveToEndPoint3.GetValue();
|
|
if (moveToEndPoint3.IsCompleted())
|
|
{
|
|
point3Done = true;
|
|
SceneFadeInOut.Instance.CallFadeIn();
|
|
SceneFadeInOut.Instance.alphaValue = 0.01f;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeInFinished() && point3Done)
|
|
{
|
|
playerCamera.GetComponent<Camera>().SetMainCamera();
|
|
SceneFadeInOut.Instance.CallFadeOut();
|
|
}
|
|
|
|
if (SceneFadeInOut.Instance.FadeOutFinished() && point3Done)
|
|
{
|
|
GameManager.Instance.PreviewLevelDone = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|