mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 17:37:38 +02:00
No way, fireworks is now feature-complete???! he did da impossible PART 2 (#298)
* Started * Added bomb * Just need more explosion types ig * Count ins :D * Remix 5 background * This was painful * Shity particles * particle adjustments * stuff --------- Co-authored-by: ev <85412919+evdial@users.noreply.github.com>
This commit is contained in:
@ -2,6 +2,8 @@ using HeavenStudio.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using NaughtyBezierCurves;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
@ -9,8 +11,57 @@ namespace HeavenStudio.Games.Loaders
|
||||
public static class AgbFireworkLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("fireworks", "Fireworks \n<color=#eb5454>[INITIALIZATION ONLY]</color>", "0058CE", false, false, new List<GameAction>()
|
||||
return new Minigame("fireworks", "Fireworks", "0058CE", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("firework", "Firework")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.PreSpawnFirework(e.beat, false, e["whereToSpawn"], e["toggle"], e["explosionType"]); },
|
||||
defaultLength = 4f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
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("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"]); },
|
||||
defaultLength = 2f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
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("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?")
|
||||
}
|
||||
},
|
||||
new GameAction("bomb", "Bomb")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.SpawnBomb(e.beat, e["toggle"]); },
|
||||
defaultLength = 3f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?")
|
||||
}
|
||||
},
|
||||
new GameAction("countIn", "Count-In")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; Fireworks.CountIn(e.beat, e["count"]); },
|
||||
defaultLength = 1f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("count", Fireworks.CountInType.CountOne, "Count", "Which count should 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>()
|
||||
{
|
||||
new Param("toggle", true, "Remix 5", "Should the background from Remix 5 tengoku appear?")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -21,16 +72,229 @@ namespace HeavenStudio.Games
|
||||
using Scripts_Fireworks;
|
||||
public class Fireworks : Minigame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
public enum ExplosionType
|
||||
{
|
||||
|
||||
UniformBig = 0,
|
||||
UniformDonut = 1,
|
||||
UniformSwirl = 2,
|
||||
UniformSmile = 3,
|
||||
MixedCircular = 4
|
||||
}
|
||||
public struct QueuedFirework
|
||||
{
|
||||
public float beat;
|
||||
public bool isSparkler;
|
||||
public int whereToSpawn;
|
||||
public bool practice;
|
||||
public int explosionType;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
if (cond.isPlaying && !cond.isPaused)
|
||||
{
|
||||
if (queuedFireworks.Count > 0)
|
||||
{
|
||||
foreach (var firework in queuedFireworks)
|
||||
{
|
||||
SpawnFirework(firework.beat, firework.isSparkler, firework.whereToSpawn, firework.practice, firework.explosionType);
|
||||
}
|
||||
queuedFireworks.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeBackgroundAppearance(bool doIt)
|
||||
{
|
||||
faces.SetActive(doIt);
|
||||
stars.SetActive(!doIt);
|
||||
}
|
||||
|
||||
public static void CountIn(float 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(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType)
|
||||
{
|
||||
if (isSparkler)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("fireworks/sparkler", beat, 1, 1, false, 0.223f)
|
||||
}, forcePlay: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("fireworks/rocket", beat)
|
||||
}, forcePlay: true);
|
||||
}
|
||||
if (GameManager.instance.currentGame == "fireworks")
|
||||
{
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate
|
||||
{
|
||||
Fireworks.instance.SpawnFirework(beat, isSparkler, whereToSpawn, practice, explosionType);
|
||||
})
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
queuedFireworks.Add(new QueuedFirework { beat = beat, isSparkler = isSparkler, whereToSpawn = whereToSpawn, practice = practice, explosionType = explosionType });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType)
|
||||
{
|
||||
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;
|
||||
spawnedRocket.Init(beat, explosionType);
|
||||
}
|
||||
|
||||
public void SpawnBomb(float beat, bool practice)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("fireworks/bomb");
|
||||
if (practice)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("fireworks/practiceHai", beat + 2),
|
||||
}, forcePlay: true);
|
||||
}
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 1, delegate
|
||||
{
|
||||
FireworksBomb spawnedBomb = Instantiate(bomb, bombSpawn, false);
|
||||
spawnedBomb.curve = bombCurve;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
65
Assets/Scripts/Games/Fireworks/FireworksBomb.cs
Normal file
65
Assets/Scripts/Games/Fireworks/FireworksBomb.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_Fireworks
|
||||
{
|
||||
public class FireworksBomb : PlayerActionObject
|
||||
{
|
||||
public BezierCurve3D curve;
|
||||
private bool exploded;
|
||||
private Fireworks game;
|
||||
private float startBeat;
|
||||
private Animator anim;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
game = Fireworks.instance;
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
public void Init(float beat)
|
||||
{
|
||||
game.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, Just, Out, Out);
|
||||
startBeat = beat;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
if (exploded) return;
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, 1f);
|
||||
transform.position = curve.GetPoint(flyPos);
|
||||
if (flyPos > 2) Destroy(gameObject);
|
||||
}
|
||||
|
||||
void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
anim.DoScaledAnimationAsync("ExplodeBomb", 0.25f);
|
||||
exploded = true;
|
||||
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(startBeat + 3f, delegate { Destroy(gameObject); })
|
||||
});
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("fireworks/miss");
|
||||
|
||||
return;
|
||||
}
|
||||
Success();
|
||||
}
|
||||
|
||||
void Success()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("fireworks/explodeBomb");
|
||||
game.FadeFlashColor(Color.white, new Color(1, 1, 1, 0), 0.5f);
|
||||
}
|
||||
|
||||
void Out(PlayerActionEvent caller) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
11
Assets/Scripts/Games/Fireworks/FireworksBomb.cs.meta
Normal file
11
Assets/Scripts/Games/Fireworks/FireworksBomb.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d25335cea525ce4397a2f83a3050aef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -8,18 +8,62 @@ namespace HeavenStudio.Games.Scripts_Fireworks
|
||||
{
|
||||
public class Rocket : PlayerActionObject
|
||||
{
|
||||
[SerializeField] ParticleSystem particleBarelyEffect;
|
||||
[SerializeField] private List<ParticleSystem> particleEffects = new List<ParticleSystem>();
|
||||
[SerializeField] ParticleSystem selectedParticleEffect;
|
||||
[SerializeField] Animator anim;
|
||||
public bool isSparkler;
|
||||
private Fireworks game;
|
||||
public float startBeat;
|
||||
private bool exploded;
|
||||
private float startY;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
|
||||
game = Fireworks.instance;
|
||||
startY = transform.position.y;
|
||||
}
|
||||
|
||||
public void Init(float beat, int explosionToChoose)
|
||||
{
|
||||
startBeat = beat;
|
||||
game.ScheduleInput(beat, isSparkler ? 1f : 3f, InputType.STANDARD_DOWN, Just, Out, Out);
|
||||
anim.DoScaledAnimationAsync(isSparkler ? "Sparkler" : "Rocket", isSparkler ? 1f : 0.5f);
|
||||
selectedParticleEffect = particleEffects[explosionToChoose];
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
var cond = Conductor.instance;
|
||||
float normalizedBeat = cond.GetPositionFromBeat(startBeat, isSparkler ? 1f : 3f);
|
||||
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));
|
||||
transform.position = new Vector3(transform.position.x, newPosY, transform.position.z);
|
||||
}
|
||||
if (normalizedBeat > 3f && !selectedParticleEffect.isPlaying) Destroy(gameObject);
|
||||
}
|
||||
|
||||
void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("fireworks/miss");
|
||||
particleBarelyEffect.Play();
|
||||
anim.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
Success();
|
||||
}
|
||||
|
||||
void Success()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("fireworks/explodeRocket");
|
||||
selectedParticleEffect.Play();
|
||||
anim.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void Out(PlayerActionEvent caller) { }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user