mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-14 05:35:08 +00:00
50a1b7bcdb
* add Jukebox library todo: - saving / loading of new format - inferrence of unknown data like past versions - move the temporary float casts to proper use of double - make sound related functions take double for timing - inform people that the Jukebox sound player was renamed to SoundByte lol * make sound, input scheduling, and super curve use double precision * successfully load charts * editor works again v1 riqs can be saved and loaded * first tempo and volume markers are unmovable fix loading of charts' easing values * use gsync / freesync * update Jukebox refs to SoundByte * game events use double part 1 Air Rally - Glee Club converted * don't load song if chart load fails * finish conversion of all minigames * remove editor waveform toggle * timeline now respects added song offset length clear cache files on app close prepped notes for dsp sync * update timeline length when offset changed * update to latest Jukebox * make error panel object in global game manager * improve conductor music scheduling * added error message box fix first game events sometimes not playing
124 lines
No EOL
4 KiB
C#
124 lines
No EOL
4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
using HeavenStudio.Games;
|
|
|
|
namespace HeavenStudio.Common
|
|
{
|
|
public class SkillStarManager : MonoBehaviour
|
|
{
|
|
public enum StarState
|
|
{
|
|
None,
|
|
In,
|
|
Collected,
|
|
Out
|
|
}
|
|
public static SkillStarManager instance { get; private set; }
|
|
[SerializeField] private Animator starAnim;
|
|
[SerializeField] private ParticleSystem starParticle;
|
|
|
|
public double StarTargetTime { get { return starStart + starLength; } }
|
|
public bool IsEligible { get; private set; }
|
|
public bool IsCollected { get { return state == StarState.Collected; } }
|
|
|
|
double starStart = double.MaxValue;
|
|
float starLength = float.MaxValue;
|
|
StarState state = StarState.None;
|
|
Conductor cond;
|
|
|
|
// Start is called before the first frame update
|
|
public void Start()
|
|
{
|
|
cond = Conductor.instance;
|
|
instance = this;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (cond.songPositionInBeatsAsDouble > starStart && state == StarState.In)
|
|
{
|
|
double offset = cond.SecsToBeats(Minigame.AceStartTime()-1, cond.GetBpmAtBeat(StarTargetTime));
|
|
if (cond.songPositionInBeatsAsDouble <= starStart + starLength + offset)
|
|
starAnim.DoScaledAnimation("StarIn", starStart, starLength + (float)offset);
|
|
else
|
|
starAnim.Play("StarIn", -1, 1f);
|
|
|
|
offset = cond.SecsToBeats(Minigame.AceEndTime()-1, cond.GetBpmAtBeat(StarTargetTime));
|
|
if (cond.songPositionInBeatsAsDouble > starStart + starLength + offset)
|
|
KillStar();
|
|
}
|
|
}
|
|
|
|
public void DoStarPreview()
|
|
{
|
|
if (starAnim == null) return;
|
|
starAnim.Play("StarJust", -1, 0.5f);
|
|
starAnim.speed = 0f;
|
|
}
|
|
|
|
public void ResetStarPreview()
|
|
{
|
|
if (starAnim == null) return;
|
|
starAnim.Play("NoPose", -1, 0f);
|
|
starAnim.speed = 1f;
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
IsEligible = false;
|
|
cond = Conductor.instance;
|
|
state = StarState.None;
|
|
starAnim.Play("NoPose", -1, 0f);
|
|
starAnim.speed = 1f;
|
|
starStart = double.MaxValue;
|
|
starLength = float.MaxValue;
|
|
}
|
|
|
|
public void DoStarIn(double beat, float length)
|
|
{
|
|
if (!OverlaysManager.OverlaysEnabled) return;
|
|
IsEligible = true;
|
|
state = StarState.In;
|
|
starStart = beat;
|
|
starLength = length;
|
|
|
|
TimingAccuracyDisplay.instance.StartStarFlash();
|
|
|
|
starAnim.DoScaledAnimation("StarIn", beat, length);
|
|
}
|
|
|
|
public bool DoStarJust()
|
|
{
|
|
if (state == StarState.In &&
|
|
cond.songPositionInBeatsAsDouble >= StarTargetTime + cond.SecsToBeats(Minigame.AceStartTime()-1, cond.GetBpmAtBeat(StarTargetTime)) &&
|
|
cond.songPositionInBeatsAsDouble <= StarTargetTime + cond.SecsToBeats(Minigame.AceEndTime()-1, cond.GetBpmAtBeat(StarTargetTime))
|
|
)
|
|
{
|
|
state = StarState.Collected;
|
|
starAnim.Play("StarJust", -1, 0f);
|
|
starParticle.Play();
|
|
SoundByte.PlayOneShot("skillStar");
|
|
|
|
TimingAccuracyDisplay.instance.StopStarFlash();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void KillStar()
|
|
{
|
|
if (state == StarState.In && cond.songPositionInBeatsAsDouble >= starStart + starLength*0.5f || !cond.isPlaying)
|
|
{
|
|
IsEligible = false;
|
|
state = StarState.Out;
|
|
starAnim.Play("NoPose", -1, 0f);
|
|
|
|
TimingAccuracyDisplay.instance.StopStarFlash();
|
|
}
|
|
}
|
|
}
|
|
} |