mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
878e07ae31
* tunnel tunnel tunnel * tunnel messes with the volume * tempo finder can now be reset by waiting now uses the conductor's time source if it exists and is playing * wip anims * Animations Finished * add tunnel sound * tunnel shader fix the left sound * add pre-sliced BG assets --------- Co-authored-by: Seanski2 <seanbenedit@gmail.com>
78 lines
No EOL
2.1 KiB
C#
78 lines
No EOL
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Editor
|
|
{
|
|
public class TempoFinder : Dialog
|
|
{
|
|
[SerializeField] private BPMText bpmText;
|
|
private bool pressed;
|
|
private double timePressed;
|
|
private double lastTimePressed = double.MinValue;
|
|
|
|
private void Awake()
|
|
{
|
|
pressed = false;
|
|
timePressed = 0f;
|
|
lastTimePressed = double.MinValue;
|
|
}
|
|
|
|
public void SwitchTempoDialog()
|
|
{
|
|
if (dialog.activeSelf)
|
|
{
|
|
dialog.SetActive(false);
|
|
timePressed = 0;
|
|
lastTimePressed = double.MinValue;
|
|
bpmText.ResetText();
|
|
}
|
|
else
|
|
{
|
|
ResetAllDialogs();
|
|
dialog.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void TapBPM()
|
|
{
|
|
pressed = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
bool conductorTimeSource = Conductor.instance != null && Conductor.instance.NotStopped();
|
|
timePressed += Time.deltaTime;
|
|
if (timePressed > 2)
|
|
{
|
|
timePressed = 0;
|
|
lastTimePressed = double.MinValue;
|
|
bpmText.ClearSamples();
|
|
pressed = false;
|
|
}
|
|
|
|
if (pressed)
|
|
{
|
|
if (!conductorTimeSource)
|
|
{
|
|
bpmText.ChangeText(timePressed);
|
|
lastTimePressed = double.MinValue;
|
|
}
|
|
else
|
|
{
|
|
if (lastTimePressed == double.MinValue)
|
|
{
|
|
bpmText.ChangeText(timePressed);
|
|
}
|
|
else
|
|
{
|
|
bpmText.ChangeText(Conductor.instance.songPositionAsDouble - lastTimePressed);
|
|
}
|
|
lastTimePressed = Conductor.instance.songPositionAsDouble;
|
|
}
|
|
timePressed = 0;
|
|
pressed = false;
|
|
}
|
|
}
|
|
}
|
|
} |