From 31da780d3db98c65fc8cc98fbcf0e67e9182d995 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Mon, 27 Feb 2023 04:05:40 +0100 Subject: [PATCH] Boom (#319) --- .../Games/Fireworks/FireworkHolder.prefab | 53 +++++++++++++------ Assets/Scripts/Games/Fireworks/Fireworks.cs | 18 ++++--- Assets/Scripts/Games/Fireworks/Rocket.cs | 43 ++++++++++++++- 3 files changed, 89 insertions(+), 25 deletions(-) diff --git a/Assets/Resources/Prefabs/Games/Fireworks/FireworkHolder.prefab b/Assets/Resources/Prefabs/Games/Fireworks/FireworkHolder.prefab index 96016183..88dbfb72 100644 --- a/Assets/Resources/Prefabs/Games/Fireworks/FireworkHolder.prefab +++ b/Assets/Resources/Prefabs/Games/Fireworks/FireworkHolder.prefab @@ -72,6 +72,17 @@ MonoBehaviour: anim: {fileID: 7858206046593675365} isSparkler: 0 startBeat: 0 + applause: 0 + mixedCircularPS: + - {fileID: 7664406765439523904} + - {fileID: 3673341205867944704} + - {fileID: 4167151421496848976} + GreenOne: {fileID: 5765098608399448656, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + GreenTwo: {fileID: 4752919973026276924, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + BlueOne: {fileID: -6520747926329190954, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + BlueTwo: {fileID: 6428321784998494127, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + RedOne: {fileID: -4336169615699320128, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + RedTwo: {fileID: -590329476313837788, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} --- !u!1 &8256302341307776916 GameObject: m_ObjectHideFlags: 0 @@ -1092,7 +1103,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.size - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: InitialModule.startSpeed.scalar @@ -1121,7 +1132,7 @@ PrefabInstance: - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[0].sprite value: - objectReference: {fileID: 5765098608399448656, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[1].sprite value: @@ -1519,16 +1530,16 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} ---- !u!4 &5350963641646200442 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 7040894076345082557, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} - m_PrefabInstance: {fileID: 3167216702444885191} - m_PrefabAsset: {fileID: 0} --- !u!198 &6724070840057534837 stripped ParticleSystem: m_CorrespondingSourceObject: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} m_PrefabInstance: {fileID: 3167216702444885191} m_PrefabAsset: {fileID: 0} +--- !u!4 &5350963641646200442 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 7040894076345082557, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} + m_PrefabInstance: {fileID: 3167216702444885191} + m_PrefabAsset: {fileID: 0} --- !u!1001 &3817871415756461651 PrefabInstance: m_ObjectHideFlags: 0 @@ -1870,16 +1881,16 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} ---- !u!4 &6146720836347458798 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 7040894076345082557, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} - m_PrefabInstance: {fileID: 3817871415756461651} - m_PrefabAsset: {fileID: 0} --- !u!198 &4782622495038528481 stripped ParticleSystem: m_CorrespondingSourceObject: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} m_PrefabInstance: {fileID: 3817871415756461651} m_PrefabAsset: {fileID: 0} +--- !u!4 &6146720836347458798 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 7040894076345082557, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} + m_PrefabInstance: {fileID: 3817871415756461651} + m_PrefabAsset: {fileID: 0} --- !u!1001 &4551524690038054270 PrefabInstance: m_ObjectHideFlags: 0 @@ -2216,7 +2227,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.size - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: ClampVelocityModule.x.scalar @@ -2261,7 +2272,7 @@ PrefabInstance: - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[0].sprite value: - objectReference: {fileID: -4336169615699320128, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[1].sprite value: @@ -2392,6 +2403,11 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} +--- !u!198 &3673341205867944704 stripped +ParticleSystem: + m_CorrespondingSourceObject: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} + m_PrefabInstance: {fileID: 4926604151301346994} + m_PrefabAsset: {fileID: 0} --- !u!1001 &5435400981192353645 PrefabInstance: m_ObjectHideFlags: 0 @@ -2983,7 +2999,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.size - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: InitialModule.startSpeed.scalar @@ -3012,7 +3028,7 @@ PrefabInstance: - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[0].sprite value: - objectReference: {fileID: -6520747926329190954, guid: 106ee017e5083fb428d5c224afd8cb96, type: 3} + objectReference: {fileID: 0} - target: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} propertyPath: UVModule.sprites.Array.data[1].sprite value: @@ -3143,6 +3159,11 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} +--- !u!198 &4167151421496848976 stripped +ParticleSystem: + m_CorrespondingSourceObject: {fileID: 8549103140033023410, guid: 2b7f3b3b11d182f48a2ef357c8e876fc, type: 3} + m_PrefabInstance: {fileID: 5724134643533168610} + m_PrefabAsset: {fileID: 0} --- !u!1001 &5833564722906346759 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/Fireworks/Fireworks.cs b/Assets/Scripts/Games/Fireworks/Fireworks.cs index 53aec1f1..7339312c 100644 --- a/Assets/Scripts/Games/Fireworks/Fireworks.cs +++ b/Assets/Scripts/Games/Fireworks/Fireworks.cs @@ -15,25 +15,27 @@ namespace HeavenStudio.Games.Loaders { new GameAction("firework", "Firework") { - preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, false, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"]); }, + preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, false, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"], e["offSet"]); }, defaultLength = 4f, parameters = new List() { new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Where to spawn?", "Where should the firework spawn?"), new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Explosion Pattern", "What pattern should the firework explode with?"), new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"), + new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "What vertical Offset should the rocket have?"), new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?") } }, new GameAction("sparkler", "Sparkler") { - preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, true, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"]); }, + preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, true, e["whereToSpawn"], e["toggle"], e["explosionType"], e["applause"], e["offSet"]); }, defaultLength = 2f, parameters = new List() { new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Where to spawn?", "Where should the firework spawn?"), new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Explosion Pattern", "What pattern should the firework explode with?"), new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"), + new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "What vertical Offset should the rocket have?"), new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?") } }, @@ -91,6 +93,7 @@ namespace HeavenStudio.Games public bool practice; public int explosionType; public bool applause; + public float verticalOffset; } public enum WhereToSpawn { @@ -142,7 +145,7 @@ namespace HeavenStudio.Games { foreach (var firework in queuedFireworks) { - SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType, firework.applause); + SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType, firework.applause, firework.verticalOffset); } queuedFireworks.Clear(); } @@ -186,7 +189,7 @@ namespace HeavenStudio.Games } } - public static void PreSpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause) + public static void PreSpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset) { if (isSparkler) { @@ -208,18 +211,18 @@ namespace HeavenStudio.Games { new BeatAction.Action(beat, delegate { - Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType, applause); + Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType, applause, verticalOffset); }) }); } else { - queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType, applause = applause }); + queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType, applause = applause, verticalOffset = verticalOffset }); } } - void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause) + void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset) { if (isSparkler && practice) { @@ -254,6 +257,7 @@ namespace HeavenStudio.Games } Rocket spawnedRocket = Instantiate(firework, spawnPoint, false); spawnedRocket.isSparkler = isSparkler; + spawnedRocket.offSet = verticalOffset; spawnedRocket.applause = applause; spawnedRocket.Init(beat, explosionType); } diff --git a/Assets/Scripts/Games/Fireworks/Rocket.cs b/Assets/Scripts/Games/Fireworks/Rocket.cs index d4336711..0a40d2e6 100644 --- a/Assets/Scripts/Games/Fireworks/Rocket.cs +++ b/Assets/Scripts/Games/Fireworks/Rocket.cs @@ -18,16 +18,55 @@ namespace HeavenStudio.Games.Scripts_Fireworks public bool applause; private bool exploded; private float startY; + public float offSet; + [SerializeField] List mixedCircularPS = new List(); + [SerializeField] Sprite GreenOne; + [SerializeField] Sprite GreenTwo; + [SerializeField] Sprite BlueOne; + [SerializeField] Sprite BlueTwo; + [SerializeField] Sprite RedOne; + [SerializeField] Sprite RedTwo; void Awake() { game = Fireworks.instance; - startY = transform.position.y; + List colors = new List() + { + "Green", + "Red", + "Blue" + }; + for (int i = 0; i < mixedCircularPS.Count; i++) + { + var ts = mixedCircularPS[i].textureSheetAnimation; + var pickedColor = colors[UnityEngine.Random.Range(0, colors.Count)]; + switch (pickedColor) + { + case "Green": + ts.AddSprite(GreenOne); + ts.AddSprite(GreenTwo); + break; + case "Red": + ts.AddSprite(RedOne); + ts.AddSprite(RedTwo); + break; + case "Blue": + ts.AddSprite(BlueOne); + ts.AddSprite(BlueTwo); + break; + default: + ts.AddSprite(GreenOne); + ts.AddSprite(GreenTwo); + break; + } + colors.Remove(pickedColor); + } } public void Init(float beat, int explosionToChoose) { startBeat = beat; + startY = transform.position.y - offSet; game.ScheduleInput(beat, isSparkler ? 1f : 3f, InputType.STANDARD_DOWN, Just, Out, Out); anim.DoScaledAnimationAsync(isSparkler ? "Sparkler" : "Rocket", isSparkler ? 1f : 0.5f); selectedParticleEffect = particleEffects[explosionToChoose]; @@ -40,7 +79,7 @@ namespace HeavenStudio.Games.Scripts_Fireworks if (!exploded && cond.isPlaying && !cond.isPaused) { EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.Linear); - float newPosY = func(startY, 7f, normalizedBeat * (isSparkler ? 0.5f : 0.4f)); + float newPosY = func(startY, 7f - offSet, normalizedBeat * (isSparkler ? 0.5f : 0.4f)); transform.position = new Vector3(transform.position.x, newPosY, transform.position.z); } if (normalizedBeat > 3f && !selectedParticleEffect.isPlaying) Destroy(gameObject);