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;
|
2023-02-20 19:22:50 +00:00
|
|
|
using NaughtyBezierCurves;
|
|
|
|
using DG.Tweening;
|
2022-03-13 14:35:22 +00:00
|
|
|
|
2022-04-12 16:14:46 +00:00
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class AgbFireworkLoader
|
|
|
|
{
|
|
|
|
public static Minigame AddGame(EventCaller eventCaller) {
|
2023-02-21 21:56:01 +00:00
|
|
|
return new Minigame("fireworks", "Fireworks \n<color=#adadad>(Hanabi)</color>", "0058CE", false, false, new List<GameAction>()
|
2022-04-12 16:14:46 +00:00
|
|
|
{
|
2023-02-20 19:22:50 +00:00
|
|
|
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"]); },
|
2023-02-20 19:22:50 +00:00
|
|
|
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?"),
|
2023-02-21 21:56:01 +00:00
|
|
|
new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"),
|
2023-02-27 03:05:40 +00:00
|
|
|
new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "What vertical Offset should the rocket have?"),
|
2023-02-20 19:22:50 +00:00
|
|
|
new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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"]); },
|
2023-02-20 19:22:50 +00:00
|
|
|
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?"),
|
2023-02-21 21:56:01 +00:00
|
|
|
new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"),
|
2023-02-27 03:05:40 +00:00
|
|
|
new Param("offSet", new EntityTypes.Float(0, 4, 0), "Vertical Offset", "What vertical Offset should the rocket have?"),
|
2023-02-20 19:22:50 +00:00
|
|
|
new Param("toggle", false, "Practice Count-In", "Should the count-in from the fireworks practice play?")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new GameAction("bomb", "Bomb")
|
|
|
|
{
|
2023-02-21 21:56:01 +00:00
|
|
|
function = delegate {var e = eventCaller.currentEntity; Fireworks.instance.SpawnBomb(e.beat, e["toggle"], e["applause"]); },
|
2023-02-20 19:22:50 +00:00
|
|
|
defaultLength = 3f,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2023-02-21 21:56:01 +00:00
|
|
|
new Param("applause", false, "Applause", "Should an applause play after successfully hitting this cue?"),
|
2023-02-20 19:22:50 +00:00
|
|
|
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?")
|
|
|
|
}
|
|
|
|
}
|
2022-04-12 16:14:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2023-02-20 19:22:50 +00:00
|
|
|
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;
|
2023-02-21 21:56:01 +00:00
|
|
|
public bool applause;
|
2023-02-27 03:05:40 +00:00
|
|
|
public float verticalOffset;
|
2023-02-20 19:22:50 +00:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
void Awake()
|
2022-03-13 14:35:22 +00:00
|
|
|
{
|
2023-02-20 19:22:50 +00:00
|
|
|
instance = this;
|
2022-03-13 14:35:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
2023-02-20 19:22:50 +00:00
|
|
|
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);
|
2023-02-20 19:22:50 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-27 03:05:40 +00:00
|
|
|
public static void PreSpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset)
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
|
|
|
if (isSparkler)
|
|
|
|
{
|
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
2023-02-22 03:48:24 +00:00
|
|
|
new MultiSound.Sound("fireworks/nuei", beat, 1, 1, false, 0.223f)
|
2023-02-20 19:22:50 +00:00
|
|
|
}, forcePlay: true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
2023-02-22 03:48:24 +00:00
|
|
|
new MultiSound.Sound("fireworks/rocket_2", beat)
|
2023-02-20 19:22:50 +00:00
|
|
|
}, forcePlay: true);
|
|
|
|
}
|
|
|
|
if (GameManager.instance.currentGame == "fireworks")
|
|
|
|
{
|
|
|
|
BeatAction.New(instance.gameObject, 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);
|
2023-02-20 19:22:50 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
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 });
|
2023-02-20 19:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-27 03:05:40 +00:00
|
|
|
void SpawnFirework(float beat, bool isSparkler, int whereToSpawn, bool practice, int explosionType, bool applause, float verticalOffset)
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
|
|
|
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;
|
2023-02-21 21:56:01 +00:00
|
|
|
spawnedRocket.applause = applause;
|
2023-02-20 19:22:50 +00:00
|
|
|
spawnedRocket.Init(beat, explosionType);
|
|
|
|
}
|
|
|
|
|
2023-02-21 21:56:01 +00:00
|
|
|
public void SpawnBomb(float beat, bool practice, bool applause)
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
2023-02-22 03:48:24 +00:00
|
|
|
Jukebox.PlayOneShotGame("fireworks/tamaya_4");
|
2023-02-20 19:22:50 +00:00
|
|
|
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;
|
2023-02-21 21:56:01 +00:00
|
|
|
spawnedBomb.applause = applause;
|
2023-02-20 19:22:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|