2023-02-20 19:22:50 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
using NaughtyBezierCurves;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_Fireworks
|
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
public class FireworksBomb : MonoBehaviour
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
|
|
|
public BezierCurve3D curve;
|
2023-02-21 21:56:01 +00:00
|
|
|
public bool applause;
|
2023-02-20 19:22:50 +00:00
|
|
|
private bool exploded;
|
|
|
|
private Fireworks game;
|
2023-06-10 19:13:29 +00:00
|
|
|
private double startBeat;
|
2023-02-20 19:22:50 +00:00
|
|
|
private Animator anim;
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
{
|
|
|
|
game = Fireworks.instance;
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void Init(double beat)
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
game.ScheduleInput(beat, 1f, Fireworks.InputAction_BasicPress, Just, Out, Out);
|
2023-02-20 19:22:50 +00:00
|
|
|
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;
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(game, new List<BeatAction.Action>()
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(startBeat + 3f, delegate { Destroy(gameObject); })
|
|
|
|
});
|
|
|
|
if (state >= 1f || state <= -1f)
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("fireworks/miss");
|
2023-02-20 19:22:50 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2023-02-21 21:56:01 +00:00
|
|
|
Success(caller);
|
2023-02-20 19:22:50 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 21:56:01 +00:00
|
|
|
void Success(PlayerActionEvent caller)
|
2023-02-20 19:22:50 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("fireworks/taikoExplode");
|
2023-02-20 19:22:50 +00:00
|
|
|
game.FadeFlashColor(Color.white, new Color(1, 1, 1, 0), 0.5f);
|
2023-06-10 19:13:29 +00:00
|
|
|
if (applause) SoundByte.PlayOneShot("applause", caller.timer + caller.startBeat + 1f);
|
2023-02-20 19:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Out(PlayerActionEvent caller) { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|