From c912dd2e4b8a031afa809881a88972c85bf4cfd6 Mon Sep 17 00:00:00 2001 From: Glence Date: Mon, 27 Feb 2023 15:33:58 +0800 Subject: [PATCH] WIP for cutscene and added test for KW --- Assets/Materials/UIMat_LoseScene.shmat | 2 +- Assets/Materials/UIMat_WinScene.shmat | 2 +- Assets/Scenes/CutScene.shade | 155 ++++++++++++++++++++++++ Assets/Scenes/CutScene.shade.shmeta | 3 + Assets/Scenes/MainMenu.shade | 25 +++- Assets/Scripts/UI/SC_Cutscene.cs | 140 +++++++++++++++++++++ Assets/Scripts/UI/SC_Cutscene.cs.shmeta | 3 + Assets/Scripts/UI/SC_MainMenu.cs | 19 +-- 8 files changed, 337 insertions(+), 12 deletions(-) create mode 100644 Assets/Scenes/CutScene.shade create mode 100644 Assets/Scenes/CutScene.shade.shmeta create mode 100644 Assets/Scripts/UI/SC_Cutscene.cs create mode 100644 Assets/Scripts/UI/SC_Cutscene.cs.shmeta diff --git a/Assets/Materials/UIMat_LoseScene.shmat b/Assets/Materials/UIMat_LoseScene.shmat index 5be3677e..1ad7b510 100644 --- a/Assets/Materials/UIMat_LoseScene.shmat +++ b/Assets/Materials/UIMat_LoseScene.shmat @@ -4,5 +4,5 @@ Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 54324293 - data.alpha: 0 + data.alpha: 1 data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Materials/UIMat_WinScene.shmat b/Assets/Materials/UIMat_WinScene.shmat index e9c36f65..786b9b70 100644 --- a/Assets/Materials/UIMat_WinScene.shmat +++ b/Assets/Materials/UIMat_WinScene.shmat @@ -4,5 +4,5 @@ Properties: data.color: {x: 1, y: 1, z: 1, w: 1} data.textureIndex: 57302694 - data.alpha: 0 + data.alpha: 1 data.beta: {x: 1, y: 1, z: 1} \ No newline at end of file diff --git a/Assets/Scenes/CutScene.shade b/Assets/Scenes/CutScene.shade new file mode 100644 index 00000000..d2f2b5f3 --- /dev/null +++ b/Assets/Scenes/CutScene.shade @@ -0,0 +1,155 @@ +- EID: 1 + Name: Canvas + IsActive: true + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: true + Scripts: ~ +- EID: 10 + Name: CutScene1 + IsActive: true + NumberOfChildren: 3 + Components: + UI Component: + Canvas ID: 1 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 2 + Name: pic1 + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -500, y: -1000, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 500, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: true + UI Component: + Canvas ID: 1 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 65542 + Name: pic2 + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 1000, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 500, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 123313564 + IsActive: true + UI Component: + Canvas ID: 1 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 5 + Name: pic3 + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 500, y: -1000, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 500, y: 1080, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129138332 + IsActive: true + UI Component: + Canvas ID: 1 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 3 + Name: Camera + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Camera Component: + Position: {x: 0, y: 0, z: 0} + Pitch: 0 + Yaw: 0 + Roll: 0 + Width: 1175 + Near: 0.00999999978 + Far: 10000 + Perspective: true + FOV: 90 + IsActive: true + Scripts: ~ +- EID: 7 + Name: CutsceneManager + IsActive: true + NumberOfChildren: 0 + Components: ~ + Scripts: + - Type: Cutscene + Enabled: true + duration: 3 + slideSpeed: 2 + cutscene1Points: 4 + cutscene1Pics: 10 +- EID: 4 + Name: CutScene_Points + IsActive: true + NumberOfChildren: 3 + Components: ~ + Scripts: ~ +- EID: 0 + Name: Pic1Point + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -500, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ +- EID: 8 + Name: Pic2Point + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ +- EID: 9 + Name: Pic3Point + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 500, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/CutScene.shade.shmeta b/Assets/Scenes/CutScene.shade.shmeta new file mode 100644 index 00000000..938521e5 --- /dev/null +++ b/Assets/Scenes/CutScene.shade.shmeta @@ -0,0 +1,3 @@ +Name: CutScene +ID: 91947920 +Type: 5 diff --git a/Assets/Scenes/MainMenu.shade b/Assets/Scenes/MainMenu.shade index 8d1bbcf3..0566ae0e 100644 --- a/Assets/Scenes/MainMenu.shade +++ b/Assets/Scenes/MainMenu.shade @@ -1,7 +1,7 @@ - EID: 0 Name: Canvas IsActive: true - NumberOfChildren: 3 + NumberOfChildren: 4 Components: Canvas Component: Canvas Width: 1920 @@ -84,6 +84,26 @@ Scripts: - Type: QuitButton Enabled: true +- EID: 7 + Name: Test + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0} + Rotate: {x: 0, y: 0, z: 3.14159274} + Scale: {x: 1920, y: 500, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 121834459 + IsActive: true + UI Component: + Canvas ID: 0 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ - EID: 2 Name: Light IsActive: true @@ -129,4 +149,5 @@ - Type: MainMenu Enabled: true sceneID: 96668835 - obj: 1 \ No newline at end of file + obj: 1 + test: 7 \ No newline at end of file diff --git a/Assets/Scripts/UI/SC_Cutscene.cs b/Assets/Scripts/UI/SC_Cutscene.cs new file mode 100644 index 00000000..c151b912 --- /dev/null +++ b/Assets/Scripts/UI/SC_Cutscene.cs @@ -0,0 +1,140 @@ +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 listOfCutscene1Points; + + public GameObject cutscene1Pics; + private List listOfCutscene1Pics; + + protected override void awake() + { + listOfCutscene1Points = cutscene1Points.GetComponentsInChildren().ToList(); + if (listOfCutscene1Points.Count == 0) + Debug.LogError("Cutscene1Points Empty"); + + listOfCutscene1Pics = cutscene1Pics.GetComponentsInChildren().ToList(); + if (listOfCutscene1Pics.Count == 0) + Debug.LogError("Cutscene1Pics Empty"); + + if (listOfCutscene1Pics[0]) + { + pic1Renderable = listOfCutscene1Pics[0].GetComponent(); + pic1Tran = listOfCutscene1Pics[0].GetComponent(); + pic1Renderable.Material.SetProperty("data.alpha" , 0.0f); + } + else + Debug.LogError("PIC1 MISSING"); + + if (listOfCutscene1Pics[1]) + { + pic2Renderable = listOfCutscene1Pics[1].GetComponent(); + pic2Tran = listOfCutscene1Pics[1].GetComponent(); + pic2Renderable.Material.SetProperty("data.alpha", 0.0f); + } + else + Debug.LogError("PIC2 MISSING"); + + if (listOfCutscene1Pics[2]) + { + pic3Renderable = listOfCutscene1Pics[2].GetComponent(); + pic3Tran = listOfCutscene1Pics[2].GetComponent(); + pic3Renderable.Material.SetProperty("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("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("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("data.alpha", alphaIn); + if (alphaIn >= 1.0f) + { + showPic3 = false; + time = 0; + alphaIn = 0; + } + } + + } +} + diff --git a/Assets/Scripts/UI/SC_Cutscene.cs.shmeta b/Assets/Scripts/UI/SC_Cutscene.cs.shmeta new file mode 100644 index 00000000..8130c77f --- /dev/null +++ b/Assets/Scripts/UI/SC_Cutscene.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_Cutscene +ID: 157565851 +Type: 9 diff --git a/Assets/Scripts/UI/SC_MainMenu.cs b/Assets/Scripts/UI/SC_MainMenu.cs index 8c887d3c..f7d7038f 100644 --- a/Assets/Scripts/UI/SC_MainMenu.cs +++ b/Assets/Scripts/UI/SC_MainMenu.cs @@ -9,6 +9,10 @@ public class MainMenu : Script public GameObject obj; private Renderable renderable; + //tbr + public GameObject test; + public Renderable testRenderable; + protected override void awake() { AudioHandler.audioClipHandlers["BGMMainMenu"] = Audio.CreateAudioClip("event:/Music/main_menu"); @@ -18,6 +22,9 @@ public class MainMenu : Script AudioHandler.audioClipHandlers["BGMMainMenu"].Play(); renderable = obj.GetComponent(); + + //tbr + testRenderable = test.GetComponent(); } protected override void start() @@ -27,17 +34,13 @@ public class MainMenu : Script { if (Input.GetKeyDown(Input.KeyCode.K) && obj) { - if (renderable.Material.GetProperty("data.alpha") == 1) + if (testRenderable.Material.GetProperty("data.alpha") == 1) { - Debug.Log("ALPHA ZERO"); - Debug.Log($"{obj.EntityId}"); - obj.GetComponent().Material.SetProperty("data.alpha", 0); + testRenderable.Material.SetProperty("data.alpha", 0); } - else if (renderable.Material.GetProperty("data.alpha") == 0) + else if (testRenderable.Material.GetProperty("data.alpha") == 0) { - Debug.Log("ALPHA ONE"); - Debug.Log($"{obj.EntityId}"); - obj.GetComponent().Material.SetProperty("data.alpha", 1); + testRenderable.Material.SetProperty("data.alpha", 1); } }