318 lines
8.4 KiB
C#
318 lines
8.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using SHADE;
|
|
|
|
|
|
public class CutsceneEnd : Script
|
|
{
|
|
public uint nextScene;
|
|
public float duration = 3.0f;
|
|
public float skipDuration = 0.1f;
|
|
private float oldDuration = 0.0f;
|
|
|
|
private Renderable pic4aRenderable;
|
|
private Renderable pic4bRenderable;
|
|
private Renderable pic4cRenderable;
|
|
private Renderable pic5aRenderable;
|
|
private Renderable pic5bRenderable;
|
|
|
|
private Transform pic4aTran;
|
|
private Transform pic4bTran;
|
|
private Transform pic4cTran;
|
|
private Transform pic5aTran;
|
|
private Transform pic5bTran;
|
|
|
|
private float alphaIn = 0.0f;
|
|
private float time = 0.0f;
|
|
private bool showPic4a = true;
|
|
private bool showPic4b = false;
|
|
private bool showPic4c = false;
|
|
private bool showPic5a = true;
|
|
private bool showPic5b = false;
|
|
|
|
private bool skip = false;
|
|
|
|
public GameObject cutscene4Points;
|
|
private List<Transform> listOfCutscene4Points;
|
|
|
|
public GameObject cutscene4Pics;
|
|
private List<Renderable> listOfCutscene4Pics;
|
|
|
|
public GameObject cutscene5Points;
|
|
private List<Transform> listOfCutscene5Points;
|
|
|
|
public GameObject cutscene5Pics;
|
|
private List<Renderable> listOfCutscene5Pics;
|
|
|
|
private TextRenderable text4;
|
|
private TextRenderable text5;
|
|
|
|
public GameObject canvas4;
|
|
public GameObject canvas5;
|
|
|
|
private bool cutscene4Done = false;
|
|
private bool cutscene5Done = false;
|
|
|
|
protected override void awake()
|
|
{
|
|
initCutscene4();
|
|
initCutscene5();
|
|
}
|
|
|
|
protected override void update()
|
|
{
|
|
Canvas4();
|
|
Canvas5();
|
|
|
|
if (Input.GetKeyDown(Input.KeyCode.Space) && !skip && (!cutscene4Done || !cutscene5Done))
|
|
{
|
|
skip = true;
|
|
oldDuration = duration;
|
|
duration = skipDuration;
|
|
}
|
|
|
|
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene4Done && canvas4.IsActiveSelf)
|
|
{
|
|
canvas4.SetActive(false);
|
|
canvas5.SetActive(true);
|
|
duration = oldDuration;
|
|
skip = false;
|
|
}
|
|
|
|
if (Input.GetKeyDown(Input.KeyCode.Space) && cutscene5Done && canvas5.IsActiveSelf)
|
|
{
|
|
SceneManager.ChangeScene(nextScene);
|
|
}
|
|
}
|
|
|
|
private void Canvas4()
|
|
{
|
|
if (canvas4.IsActiveSelf)
|
|
{
|
|
if (showPic4a)
|
|
{
|
|
if (time < duration)
|
|
{
|
|
pic4aTran.LocalPosition = Vector3.Lerp(pic4aTran.LocalPosition, listOfCutscene4Points[0].LocalPosition, time / duration);
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic4aTran.LocalPosition = listOfCutscene4Points[0].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic4aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic4a = false;
|
|
showPic4b = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic4b)
|
|
{
|
|
if (time < duration)
|
|
{
|
|
pic4bTran.LocalPosition = Vector3.Lerp(pic4bTran.LocalPosition, listOfCutscene4Points[1].LocalPosition, time / duration);
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic4bTran.LocalPosition = listOfCutscene4Points[1].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic4bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic4b = false;
|
|
showPic4c = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic4c)
|
|
{
|
|
if (time < duration)
|
|
{
|
|
pic4cTran.LocalPosition = Vector3.Lerp(pic4cTran.LocalPosition, listOfCutscene4Points[2].LocalPosition, time / duration);
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic4cTran.LocalPosition = listOfCutscene4Points[2].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic4cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic4c = false;
|
|
cutscene4Done = true;
|
|
text4.Enabled = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Canvas5()
|
|
{
|
|
if (canvas5.IsActiveSelf)
|
|
{
|
|
if (showPic5a)
|
|
{
|
|
if (time < duration)
|
|
{
|
|
pic5aTran.LocalPosition = Vector3.Lerp(pic5aTran.LocalPosition, listOfCutscene5Points[0].LocalPosition, time / duration);
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic5aTran.LocalPosition = listOfCutscene5Points[0].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic5aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic5a = false;
|
|
showPic5b = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic5b)
|
|
{
|
|
if (time < duration)
|
|
{
|
|
pic5bTran.LocalPosition = Vector3.Lerp(pic5bTran.LocalPosition, listOfCutscene5Points[1].LocalPosition, time / duration);
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic5bTran.LocalPosition = listOfCutscene5Points[1].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic5bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic5b = false;
|
|
text5.Enabled = true;
|
|
cutscene5Done = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void initCutscene4()
|
|
{
|
|
if (cutscene4Points)
|
|
listOfCutscene4Points = cutscene4Points.GetComponentsInChildren<Transform>().ToList();
|
|
else
|
|
Debug.LogError("Cutscene4Points Missing");
|
|
|
|
if (listOfCutscene4Points.Count == 0)
|
|
Debug.LogError("Cutscene4Points Empty");
|
|
|
|
listOfCutscene4Pics = cutscene4Pics.GetComponentsInChildren<Renderable>().ToList();
|
|
if (listOfCutscene4Pics.Count == 0)
|
|
Debug.LogError("Cutscene4Pics Empty");
|
|
|
|
if (listOfCutscene4Pics[0])
|
|
{
|
|
pic4aRenderable = listOfCutscene4Pics[0].GetComponent<Renderable>();
|
|
pic4aTran = listOfCutscene4Pics[0].GetComponent<Transform>();
|
|
pic4aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("SCENE 4 PIC1 MISSING");
|
|
|
|
if (listOfCutscene4Pics[1])
|
|
{
|
|
pic4bRenderable = listOfCutscene4Pics[1].GetComponent<Renderable>();
|
|
pic4bTran = listOfCutscene4Pics[1].GetComponent<Transform>();
|
|
pic4bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("SCENE 4 PIC2 MISSING");
|
|
|
|
if (listOfCutscene4Pics[2])
|
|
{
|
|
pic4cRenderable = listOfCutscene4Pics[2].GetComponent<Renderable>();
|
|
pic4cTran = listOfCutscene4Pics[2].GetComponent<Transform>();
|
|
pic4cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("SCENE 1 PIC3 MISSING");
|
|
|
|
if (canvas4)
|
|
{
|
|
text4 = canvas4.GetComponentInChildren<TextRenderable>();
|
|
text4.Enabled = false;
|
|
}
|
|
else
|
|
Debug.LogError("Canvas 4 missing");
|
|
}
|
|
|
|
private void initCutscene5()
|
|
{
|
|
if (cutscene5Points)
|
|
listOfCutscene5Points = cutscene5Points.GetComponentsInChildren<Transform>().ToList();
|
|
else
|
|
Debug.LogError("cutscene5Points Missing");
|
|
|
|
if (listOfCutscene5Points.Count == 0)
|
|
Debug.LogError("Cutscene5Points Empty");
|
|
|
|
listOfCutscene5Pics = cutscene5Pics.GetComponentsInChildren<Renderable>().ToList();
|
|
if (listOfCutscene5Pics.Count == 0)
|
|
Debug.LogError("Cutscene5Pics Empty");
|
|
|
|
if (listOfCutscene5Pics[0])
|
|
{
|
|
pic5aRenderable = listOfCutscene5Pics[0].GetComponent<Renderable>();
|
|
pic5aTran = listOfCutscene5Pics[0].GetComponent<Transform>();
|
|
pic5aRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("SCENE 5 PIC1 MISSING");
|
|
|
|
if (listOfCutscene5Pics[1])
|
|
{
|
|
pic5bRenderable = listOfCutscene5Pics[1].GetComponent<Renderable>();
|
|
pic5bTran = listOfCutscene5Pics[1].GetComponent<Transform>();
|
|
pic5bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("SCENE 5 PIC2 MISSING");
|
|
|
|
if (canvas5)
|
|
{
|
|
text5 = canvas5.GetComponentInChildren<TextRenderable>();
|
|
text5.Enabled = false;
|
|
canvas5.SetActive(false);
|
|
}
|
|
else
|
|
Debug.LogError("Canvas 5 missing");
|
|
|
|
}
|
|
}
|
|
|