From b9b4a6ec97e5ab5ebb9f75c78eb28faef5ee0322 Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Mon, 15 Aug 2022 21:14:00 -0500 Subject: [PATCH 1/7] Update ClappyTrio.cs --- Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs index 244090be5..9555292fe 100644 --- a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs +++ b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs @@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Loaders public static Minigame AddGame(EventCaller eventCaller) { return new Minigame("clappyTrio", "The Clappy Trio", "29E7FF", false, false, new List() { - new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 3, true), + new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 1, true), new GameAction("bop", delegate { ClappyTrio.instance.Bop(eventCaller.currentEntity.beat); } ), new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(eventCaller.currentEntity.toggle ? 3 : 0); }, parameters: new List() { From 88f59efe15a594ce608b510bca522b78e45d591b Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Mon, 15 Aug 2022 21:45:48 -0500 Subject: [PATCH 2/7] default obj colors --- Assets/Scripts/Games/KarateMan/KarateMan.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Games/KarateMan/KarateMan.cs b/Assets/Scripts/Games/KarateMan/KarateMan.cs index 2e08328ba..db3938123 100644 --- a/Assets/Scripts/Games/KarateMan/KarateMan.cs +++ b/Assets/Scripts/Games/KarateMan/KarateMan.cs @@ -81,9 +81,9 @@ namespace HeavenStudio.Games.Loaders ), new GameAction("set object colors", delegate { var e = eventCaller.currentEntity; KarateMan.UpdateMaterialColour(e.colorA, e.colorB, e.colorC); }, 0.5f, false, new List() { - new Param("colorA", new Color(), "Joe Body Color", "The color to use for Karate Joe's body"), - new Param("colorB", new Color(), "Joe Highlight Color", "The color to use for Karate Joe's highlights"), - new Param("colorC", new Color(), "Item Color", "The color to use for the thrown items"), + new Param("colorA", new Color(1,1,1,1), "Joe Body Color", "The color to use for Karate Joe's body"), + new Param("colorB", new Color(0.81f,0.81f,0.81f,1), "Joe Highlight Color", "The color to use for Karate Joe's highlights"), + new Param("colorC", new Color(1,1,1,1), "Item Color", "The color to use for the thrown items"), }, inactiveFunction: delegate { var e = eventCaller.currentEntity; KarateMan.UpdateMaterialColour(e.colorA, e.colorB, e.colorC); } ), From 886de49a894c47353753085baf4d3c97f1e8e076 Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Tue, 16 Aug 2022 22:21:04 -0500 Subject: [PATCH 3/7] start work on screen shake --- Assets/Scripts/GameCamera.cs | 32 +++++++++++++++++++++++++++++++- Assets/Scripts/Minigames.cs | 8 ++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/GameCamera.cs b/Assets/Scripts/GameCamera.cs index b6082697e..e81377fa4 100644 --- a/Assets/Scripts/GameCamera.cs +++ b/Assets/Scripts/GameCamera.cs @@ -15,6 +15,7 @@ namespace HeavenStudio private List positionEvents = new List(); private List rotationEvents = new List(); private List scaleEvents = new List(); + private List shakeEvents = new List(); /** default cam position, for quick-resetting @@ -30,6 +31,7 @@ namespace HeavenStudio private static Vector3 position; private static Vector3 rotEluer; private static Vector3 scale; + private static Vector3 shakeResult; /** camera's last transformation @@ -38,6 +40,7 @@ namespace HeavenStudio private static Vector3 positionLast; private static Vector3 rotEluerLast; private static Vector3 scaleLast; + private static Vector3 shakeLast; /** transformations to apply *after* the global transform, @@ -89,20 +92,27 @@ namespace HeavenStudio rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate camera" }); positionEvents.AddRange(EventCaller.GetAllInGameManagerList("gameManager", new string[] { "rotate camera" })); + //screen shake time baybee + + shakeEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "screen shake" }); + + //scale (TODO) // scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale camera" }); UpdateCameraTranslate(); UpdateCameraRotate(); + SetShakeIntensity(); } private void Update() { UpdateCameraTranslate(); UpdateCameraRotate(); + SetShakeIntensity(); Camera cam = GetCamera(); - cam.transform.localPosition = position + additionalPosition; + cam.transform.localPosition = position + additionalPosition + shakeResult; cam.transform.eulerAngles = rotEluer + additionalRotEluer; cam.transform.localScale = Vector3.Scale(scale, additionalScale); } @@ -147,6 +157,26 @@ namespace HeavenStudio } } + //scren shake spaghetti + private void SetShakeIntensity() + { + foreach (var e in shakeEvents) + { + float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length); + if (prog >= 0f) + { + EasingFunction.Function func = EasingFunction.GetEasingFunction(e.ease); + float dx = func(positionLast.x, e.valA, Mathf.Min(prog, 1f)); + float dy = func(positionLast.y, e.valA, Mathf.Min(prog, 1f)); + shakeResult = new Vector3(dx, dy); + } + if (prog > 1f) + { + shakeLast = new Vector3(e.valA, e.valA); + } + } + } + public static void ResetTransforms() { position = defaultPosition; diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index cdb9132ef..08d3ecda1 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -332,6 +332,14 @@ namespace HeavenStudio new Param("ease", EasingFunction.Ease.Linear, "Ease") }, hidden: false ), + new GameAction("screen shake", delegate + { + //TODO: move cam + }, 1f, true, new List() + { + new Param("valA", new EntityTypes.Float(0, 50, 10), "Intensity") + } ), + new GameAction("move camera", delegate { //TODO: move cam From 52078ac4cd6d020855db09ea3946bdd380247ecc Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Tue, 16 Aug 2022 22:24:39 -0500 Subject: [PATCH 4/7] Intensity input fully functional now time for, ugh, math. --- Assets/Scripts/GameCamera.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/Scripts/GameCamera.cs b/Assets/Scripts/GameCamera.cs index e81377fa4..0096a280c 100644 --- a/Assets/Scripts/GameCamera.cs +++ b/Assets/Scripts/GameCamera.cs @@ -23,6 +23,7 @@ namespace HeavenStudio public static Vector3 defaultPosition = new Vector3(0, 0, -10); public static Vector3 defaultRotEluer = new Vector3(0, 0, 0); public static Vector3 defaultScale = new Vector3(16, 9, 1); + public static Vector3 defaultShake = new Vector3(0, 0, 0); /** camera's current transformation @@ -182,6 +183,7 @@ namespace HeavenStudio position = defaultPosition; rotEluer = defaultRotEluer; scale = defaultScale; + shakeResult = defaultShake; } public static void ResetAdditionalTransforms() From b4a029ba3f92f39f1b748580442797c74a49bc9a Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Tue, 16 Aug 2022 22:30:22 -0500 Subject: [PATCH 5/7] automatically go back to old camera --- Assets/Scripts/GameCamera.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/GameCamera.cs b/Assets/Scripts/GameCamera.cs index 0096a280c..eb91009c5 100644 --- a/Assets/Scripts/GameCamera.cs +++ b/Assets/Scripts/GameCamera.cs @@ -173,7 +173,7 @@ namespace HeavenStudio } if (prog > 1f) { - shakeLast = new Vector3(e.valA, e.valA); + shakeResult = new Vector3(0, 0); } } } From a46b747898a6c046eda30102bbd4c906a3766e49 Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Wed, 17 Aug 2022 11:31:55 -0500 Subject: [PATCH 6/7] something --- Assets/Scripts/GameCamera.cs | 4 +++- Assets/Scripts/Minigames.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/GameCamera.cs b/Assets/Scripts/GameCamera.cs index eb91009c5..a87002cf3 100644 --- a/Assets/Scripts/GameCamera.cs +++ b/Assets/Scripts/GameCamera.cs @@ -150,6 +150,7 @@ namespace HeavenStudio float dy = func(rotEluerLast.y, e.valB, Mathf.Min(prog, 1f)); float dz = func(rotEluerLast.z, e.valC, Mathf.Min(prog, 1f)); rotEluer = new Vector3(dx, dy, dz); + } if (prog > 1f) { @@ -169,7 +170,8 @@ namespace HeavenStudio EasingFunction.Function func = EasingFunction.GetEasingFunction(e.ease); float dx = func(positionLast.x, e.valA, Mathf.Min(prog, 1f)); float dy = func(positionLast.y, e.valA, Mathf.Min(prog, 1f)); - shakeResult = new Vector3(dx, dy); + shakeResult = new Vector3(Mathf.Sin(dx * 3.14159265f * 5f) * e.valA, Mathf.Sin(dy * 3.14159265f * 10f) * e.valA); + } if (prog > 1f) { diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 08d3ecda1..7fe4fb040 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -337,7 +337,7 @@ namespace HeavenStudio //TODO: move cam }, 1f, true, new List() { - new Param("valA", new EntityTypes.Float(0, 50, 10), "Intensity") + new Param("valA", new EntityTypes.Float(0, 10, 2), "Intensity") } ), new GameAction("move camera", delegate From 9356b058261cff4a5f9fd06564d9d7699461d7e9 Mon Sep 17 00:00:00 2001 From: ThatZeoMan <67521686+ThatZeoMan@users.noreply.github.com> Date: Wed, 17 Aug 2022 14:43:18 -0500 Subject: [PATCH 7/7] fully functional screen shake its a lil smooth at lower intensities but it works! lots of "complicated" "math" going on here. thanks for all the help, minenice! recommended settings - intensity: 2 length: 0.25 --- Assets/Scripts/GameCamera.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/GameCamera.cs b/Assets/Scripts/GameCamera.cs index a87002cf3..3f98f1c54 100644 --- a/Assets/Scripts/GameCamera.cs +++ b/Assets/Scripts/GameCamera.cs @@ -170,7 +170,7 @@ namespace HeavenStudio EasingFunction.Function func = EasingFunction.GetEasingFunction(e.ease); float dx = func(positionLast.x, e.valA, Mathf.Min(prog, 1f)); float dy = func(positionLast.y, e.valA, Mathf.Min(prog, 1f)); - shakeResult = new Vector3(Mathf.Sin(dx * 3.14159265f * 5f) * e.valA, Mathf.Sin(dy * 3.14159265f * 10f) * e.valA); + shakeResult = new Vector3(Mathf.Cos(dx * e.length * 20f) * (e.valA / 2), Mathf.Cos(dy * e.length * 30f) * (e.valA / 2)); } if (prog > 1f)