141 lines
3.7 KiB
C#
141 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using SHADE;
|
|
|
|
|
|
public class Cutscene : Script
|
|
{
|
|
|
|
public float duration = 3.0f;
|
|
|
|
private Renderable pic1Renderable;
|
|
private Renderable pic2Renderable;
|
|
private Renderable pic3Renderable;
|
|
|
|
private Transform pic1Tran;
|
|
private Transform pic2Tran;
|
|
private Transform pic3Tran;
|
|
|
|
private float alphaIn = 0.0f;
|
|
//private float alphaOut = 1.0f;
|
|
private float time = 0.0f;
|
|
private bool showPic1 = true;
|
|
private bool showPic2 = false;
|
|
private bool showPic3 = false;
|
|
public float slideSpeed = 5.0f;
|
|
|
|
public GameObject cutscene1Points;
|
|
private List<Transform> listOfCutscene1Points;
|
|
|
|
public GameObject cutscene1Pics;
|
|
private List<Renderable> listOfCutscene1Pics;
|
|
|
|
protected override void awake()
|
|
{
|
|
listOfCutscene1Points = cutscene1Points.GetComponentsInChildren<Transform>().ToList();
|
|
if (listOfCutscene1Points.Count == 0)
|
|
Debug.LogError("Cutscene1Points Empty");
|
|
|
|
listOfCutscene1Pics = cutscene1Pics.GetComponentsInChildren<Renderable>().ToList();
|
|
if (listOfCutscene1Pics.Count == 0)
|
|
Debug.LogError("Cutscene1Pics Empty");
|
|
|
|
if (listOfCutscene1Pics[0])
|
|
{
|
|
pic1Renderable = listOfCutscene1Pics[0].GetComponent<Renderable>();
|
|
pic1Tran = listOfCutscene1Pics[0].GetComponent<Transform>();
|
|
pic1Renderable.Material.SetProperty<float>("data.alpha" , 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC1 MISSING");
|
|
|
|
if (listOfCutscene1Pics[1])
|
|
{
|
|
pic2Renderable = listOfCutscene1Pics[1].GetComponent<Renderable>();
|
|
pic2Tran = listOfCutscene1Pics[1].GetComponent<Transform>();
|
|
pic2Renderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC2 MISSING");
|
|
|
|
if (listOfCutscene1Pics[2])
|
|
{
|
|
pic3Renderable = listOfCutscene1Pics[2].GetComponent<Renderable>();
|
|
pic3Tran = listOfCutscene1Pics[2].GetComponent<Transform>();
|
|
pic3Renderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC3 MISSING");
|
|
|
|
}
|
|
|
|
protected override void update()
|
|
{
|
|
|
|
if (showPic1)
|
|
{
|
|
pic1Tran.LocalPosition = Vector3.Lerp(pic1Tran.LocalPosition, listOfCutscene1Points[0].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
alphaIn = 1.0f;
|
|
|
|
pic1Renderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic1 = false;
|
|
showPic2 = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic2)
|
|
{
|
|
pic2Tran.LocalPosition = Vector3.Lerp(pic2Tran.LocalPosition, listOfCutscene1Points[1].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
alphaIn = 1.0f;
|
|
|
|
pic2Renderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic2 = false;
|
|
showPic3 = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic3)
|
|
{
|
|
pic3Tran.LocalPosition = Vector3.Lerp(pic3Tran.LocalPosition, listOfCutscene1Points[2].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
alphaIn = 1.0f;
|
|
|
|
pic3Renderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic3 = false;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|