HeavenStudioPlus/Assets/Scripts/Games/Fireworks/Fireworks.cs

319 lines
13 KiB
C#
Raw Normal View History

2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
2022-03-13 14:35:22 +00:00
using System;
using System.Collections.Generic;
using UnityEngine;
using NaughtyBezierCurves;
using DG.Tweening;
2022-03-13 14:35:22 +00:00
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
public static class AgbFireworkLoader
{
public static Minigame AddGame(EventCaller eventCaller) {
return new Minigame("fireworks", "Fireworks \n<color=#adadad>(Hanabi)</color>", "000820", false, false, new List<GameAction>()
{
new GameAction("firework", "Firework")
{
2023-02-27 03:05:40 +00:00
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<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Side", "Choose the side this firework should spawn on."),
new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Pattern", "Choose the pattern that this firework should explode into."),
new Param("applause", false, "Applause", "Toggle if applause should play if you successfully hit this cue."),
new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "Choose the verical offset for this firework."),
new Param("toggle", false, "Count-In", "Toggle if a count-in should automatically play for this cue, as shown in the practice of the original game.")
}
},
new GameAction("sparkler", "Sparkler")
{
2023-02-27 03:05:40 +00:00
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<Param>()
{
new Param("whereToSpawn", Fireworks.WhereToSpawn.Middle, "Side", "Choose the side this sparkler should spawn on."),
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("explosionType", Fireworks.ExplosionType.MixedCircular, "Pattern", "Choose the pattern that this sparkler should explode into."),
new Param("applause", false, "Applause", "Toggle if applause should play if you successfully hit this cue."),
new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "Choose the vertical offset for this sparkler."),
new Param("toggle", false, "Count-In", "Toggle if a count-in should automatically play for this cue, as shown in the practice of the original game.")
}
},
new GameAction("bomb", "Bomb")
{
function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.SpawnBomb(e.beat, e["toggle"], e["applause"]); },
defaultLength = 3f,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("applause", false, "Applause", "Toggle if applause should play if you successfully hit this cue."),
new Param("toggle", false, "Count-In", "Toggle if a count-in should automatically play for this cue, as shown in the practice of the original game.")
}
},
new GameAction("countIn", "Count-In")
{
preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.CountIn(e.beat, e["count"]); },
defaultLength = 1f,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("count", Fireworks.CountInType.CountOne, "Type", "Set the number to be said.")
}
},
new GameAction("altBG", "Background Appearance")
{
function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.ChangeBackgroundAppearance(e["toggle"]); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
Mass Text Update (#615) * Air Rally Text Update * Blue Bear Text Update * Board Meeting Text Update * Built To Scale DS Text Update also changed Air Rally's assetbundle tag from "normal" to "keep" * Catchy Tune Text Update also changed some minor wording in Board Meeting and Built To Scale DS * Cheer Readers Text Update * The Clappy Trio Text Update * Coin Toss Text Update * Crop Stomp Text Update * DJ School Text Update * Dog Ninja Text Update * Double Date Text Update * Drumming Practice Text Update * Fan Club Text Update * Fireworks Text Update * Second Contact Text Update * Flipper-Flop Text Update also fix an error in Catchy Tune * Fork Lifter Text Update * Glee Club Text Update * Karate Man Text Update also minor updates to other games * Kitties! Text Update * Launch Party Text Update * Lockstep Text Update * Marching Orders Text Update * Meat Grinder Text Update also fixed an error in Second Contact * Mr. Upbeat Text Update * Munchy Monk Text Update * Octopus Machine Text Update * Pajama Party Text Update * Quiz Show Text Update also changed some wording in meat grinder * Rhythm Rally Text Update * Rhythm Somen Text Update that was easy * Rhythm Tweezers Text Update * Ringside Text Update * Rockers Text Update this sucked * Samurai Slice DS Text Update * See Saw Text Update * Sneaky Spirits Text Update * Spaceball Text Update * Space Dance Text Update * Space Soccer Text Update * Splashdown Text Update * Tambourine Text Update * Tap Trial Text Update * Tap Troupe Text Update * The Dazzles Text Update * Toss Boys Text Update * Tram & Pauline Text Update also added translation for Fireworks * Tunnel Text Update * Wizard's Waltz Text Update * Working Dough Text Update * fix compiler errors * fix editor offset bug(?) * fix missing param in second contact * Ball Redispense text * remove space soccer swing * Trick on the Class Text Update * Non-Game Text Update * fix pre-function sorting * camera shake ease * remove a bunch of prints * rhythm tweezers bug fix * Update Credits.txt * ssds nop samurai bop * swap order of shake properties * Update FirstContact.cs --------- Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-15 02:04:10 +00:00
new Param("toggle", true, "Remix 5", "Togle if the background from Remix 5 (GBA) should appear.")
}
}
},
new List<string>() {"agb", "normal"},
"agbexplode", "en",
new List<string>() {}
);
}
}
}
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games
2022-03-13 14:35:22 +00:00
{
using Scripts_Fireworks;
public class Fireworks : Minigame
{
public enum ExplosionType
{
UniformBig = 0,
UniformDonut = 1,
UniformSwirl = 2,
UniformSmile = 3,
MixedCircular = 4
}
public struct QueuedFirework
{
public double beat;
public bool isSparkler;
public int whereToSpawn;
public bool practice;
public int explosionType;
public bool applause;
2023-02-27 03:05:40 +00:00
public float verticalOffset;
}
public enum WhereToSpawn
{
Left = 0,
Right = 1,
Middle = 2
}
public enum CountInType
{
CountOne = 0,
CountTwo = 1,
CountThree = 2,
CountHey = 3
}
[Header("Components")]
[SerializeField] Transform spawnLeft;
[SerializeField] Transform spawnRight;
[SerializeField] Transform spawnMiddle;
[SerializeField] Transform bombSpawn;
[SerializeField] Rocket firework;
[SerializeField] FireworksBomb bomb;
[SerializeField] BezierCurve3D bombCurve;
[SerializeField] SpriteRenderer flashWhite;
[SerializeField] GameObject faces;
[SerializeField] GameObject stars;
[Header("Properties")]
Tween flashTween;
public static List<QueuedFirework> queuedFireworks = new List<QueuedFirework>();
public static Fireworks instance;
void OnDestroy()
{
if (queuedFireworks.Count > 0) queuedFireworks.Clear();
foreach (var evt in scheduledInputs)
{
evt.Disable();
}
}
void Awake()
2022-03-13 14:35:22 +00:00
{
instance = this;
2022-03-13 14:35:22 +00:00
}
void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (queuedFireworks.Count > 0)
{
foreach (var firework in queuedFireworks)
{
2023-02-27 03:05:40 +00:00
SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType, firework.applause, firework.verticalOffset);
}
queuedFireworks.Clear();
}
}
}
public void ChangeBackgroundAppearance(bool doIt)
{
faces.SetActive(doIt);
stars.SetActive(!doIt);
}
public static void CountIn(double beat, int count)
{
switch (count)
{
case (int)CountInType.CountOne:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/count1", beat)
}, forcePlay: true);
break;
case (int)CountInType.CountTwo:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/count2", beat)
}, forcePlay: true);
break;
case (int)CountInType.CountThree:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/count3", beat)
}, forcePlay: true);
break;
case (int)CountInType.CountHey:
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/countHey", beat)
}, forcePlay: true);
break;
}
}
public static void PreSpawnFirework(double beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset)
{
if (isSparkler)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/nuei", beat, 1, 1, false, 0.223f)
}, forcePlay: true);
}
else
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/rocket_2", beat)
}, forcePlay: true);
}
if (GameManager.instance.currentGame == "fireworks")
{
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
2023-02-27 03:05:40 +00:00
Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType, applause, verticalOffset);
})
});
}
else
{
2023-02-27 03:05:40 +00:00
queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType, applause = applause, verticalOffset = verticalOffset });
}
}
void SpawnFirework(double beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset)
{
if (isSparkler && practice)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/practiceHai", beat + 1),
}, forcePlay: true);
}
else if (practice)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/practice1", beat),
new MultiSound.Sound("fireworks/practice2", beat + 1),
new MultiSound.Sound("fireworks/practice3", beat + 2),
new MultiSound.Sound("fireworks/practiceHai", beat + 3),
}, forcePlay: true);
}
Transform spawnPoint = spawnMiddle;
switch (whereToSpawn)
{
case (int)WhereToSpawn.Left:
spawnPoint = spawnLeft;
break;
case (int)WhereToSpawn.Right:
spawnPoint = spawnRight;
break;
default:
spawnPoint = spawnMiddle;
break;
}
Rocket spawnedRocket = Instantiate(firework, spawnPoint, false);
spawnedRocket.isSparkler = isSparkler;
2023-02-27 03:05:40 +00:00
spawnedRocket.offSet = verticalOffset;
spawnedRocket.applause = applause;
spawnedRocket.Init(beat, explosionType);
}
public void SpawnBomb(double beat, bool practice, bool applause)
{
SoundByte.PlayOneShotGame("fireworks/tamaya_4");
if (practice)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("fireworks/practiceHai", beat + 2),
}, forcePlay: true);
}
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 1, delegate
{
FireworksBomb spawnedBomb = Instantiate(bomb, bombSpawn, false);
spawnedBomb.curve = bombCurve;
spawnedBomb.applause = applause;
spawnedBomb.Init(beat + 1);
})
});
}
public void ChangeFlashColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
if (flashTween != null)
flashTween.Kill(true);
if (seconds == 0)
{
flashWhite.color = color;
}
else
{
flashTween = flashWhite.DOColor(color, seconds);
}
}
public void FadeFlashColor(Color start, Color end, float beats)
{
ChangeFlashColor(start, 0f);
ChangeFlashColor(end, beats);
2022-03-13 14:35:22 +00:00
}
}
}