152 lines
4.0 KiB
C#
152 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using SHADE;
|
|
|
|
|
|
public class Cutscene : Script
|
|
{
|
|
|
|
public float duration = 3.0f;
|
|
|
|
private Renderable pic1aRenderable;
|
|
private Renderable pic1bRenderable;
|
|
private Renderable pic1cRenderable;
|
|
|
|
private Transform pic1aTran;
|
|
private Transform pic1bTran;
|
|
private Transform pic1cTran;
|
|
|
|
private float alphaIn = 0.0f;
|
|
//private float alphaOut = 1.0f;
|
|
private float time = 0.0f;
|
|
private bool showPic1a = true;
|
|
private bool showPic1b = false;
|
|
private bool showPic1c = false;
|
|
private bool cutsceneDone = 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])
|
|
{
|
|
pic1aRenderable = listOfCutscene1Pics[0].GetComponent<Renderable>();
|
|
pic1aTran = listOfCutscene1Pics[0].GetComponent<Transform>();
|
|
pic1aRenderable.Material.SetProperty<float>("data.alpha" , 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC1 MISSING");
|
|
|
|
if (listOfCutscene1Pics[1])
|
|
{
|
|
pic1bRenderable = listOfCutscene1Pics[1].GetComponent<Renderable>();
|
|
pic1bTran = listOfCutscene1Pics[1].GetComponent<Transform>();
|
|
pic1bRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC2 MISSING");
|
|
|
|
if (listOfCutscene1Pics[2])
|
|
{
|
|
pic1cRenderable = listOfCutscene1Pics[2].GetComponent<Renderable>();
|
|
pic1cTran = listOfCutscene1Pics[2].GetComponent<Transform>();
|
|
pic1cRenderable.Material.SetProperty<float>("data.alpha", 0.0f);
|
|
}
|
|
else
|
|
Debug.LogError("PIC3 MISSING");
|
|
|
|
}
|
|
|
|
protected override void update()
|
|
{
|
|
|
|
if (showPic1a)
|
|
{
|
|
pic1aTran.LocalPosition = Vector3.Lerp(pic1aTran.LocalPosition, listOfCutscene1Points[0].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic1aTran.LocalPosition = listOfCutscene1Points[0].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic1aRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic1a = false;
|
|
showPic1b = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic1b)
|
|
{
|
|
pic1bTran.LocalPosition = Vector3.Lerp(pic1bTran.LocalPosition, listOfCutscene1Points[1].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic1bTran.LocalPosition = listOfCutscene1Points[1].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic1bRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic1b = false;
|
|
showPic1c = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
if (showPic1c)
|
|
{
|
|
pic1cTran.LocalPosition = Vector3.Lerp(pic1cTran.LocalPosition, listOfCutscene1Points[2].LocalPosition, slideSpeed * Time.DeltaTimeF);
|
|
if (time < duration)
|
|
{
|
|
alphaIn = SHADE.Math.Lerp(0.0f, 1.0f, time / duration);
|
|
time += Time.DeltaTimeF;
|
|
}
|
|
else
|
|
{
|
|
pic1cTran.LocalPosition = listOfCutscene1Points[2].LocalPosition;
|
|
alphaIn = 1.0f;
|
|
}
|
|
|
|
pic1cRenderable.Material.SetProperty<float>("data.alpha", alphaIn);
|
|
if (alphaIn >= 1.0f)
|
|
{
|
|
showPic1c = false;
|
|
cutsceneDone = true;
|
|
time = 0;
|
|
alphaIn = 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|