mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-23 10:05:14 +00:00
63a2814caa
* make BeatActions coroutines instead of componentrs * pooled scheduled sounds implement S' entity seek * remove debug prints from last two changes * implement absolute time tracking implement DSP time resyncing * optimize GameManager * update TMPro * update IDE packages * fix dsp sync making the drift worse * fix issue with the JSL dll * relocate debug print * make scheduled pitch setter functional * any cpu
86 lines
No EOL
2.5 KiB
C#
86 lines
No EOL
2.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
namespace HeavenStudio.Games.Scripts_MrUpbeat
|
|
{
|
|
public class UpbeatMan : MonoBehaviour
|
|
{
|
|
[Header("References")]
|
|
[SerializeField] Animator anim;
|
|
[SerializeField] Animator blipAnim;
|
|
[SerializeField] GameObject[] shadows;
|
|
[SerializeField] TMP_Text blipText;
|
|
|
|
public int blipSize = 0;
|
|
public bool shouldGrow;
|
|
public bool shouldBlip = true;
|
|
public string blipString = "M";
|
|
|
|
static MrUpbeat game;
|
|
|
|
void Awake()
|
|
{
|
|
game = MrUpbeat.instance;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
blipText.transform.localScale = Vector3.one;
|
|
|
|
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN)) {
|
|
Step(true);
|
|
}
|
|
}
|
|
|
|
public void RecursiveBlipping(double beat)
|
|
{
|
|
if (game.stopBlipping) {
|
|
game.stopBlipping = false;
|
|
return;
|
|
}
|
|
if (shouldBlip) {
|
|
Blipping(beat);
|
|
}
|
|
BeatAction.New(this, new List<BeatAction.Action>() {
|
|
new BeatAction.Action(beat + 1, delegate { RecursiveBlipping(beat + 1); })
|
|
});
|
|
}
|
|
|
|
public void Blipping(double beat)
|
|
{
|
|
SoundByte.PlayOneShotGame("mrUpbeat/blip");
|
|
blipAnim.Play("Blip"+(blipSize+1), 0, 0);
|
|
blipText.text = (blipSize == 4 && blipString != "") ? blipString : "";
|
|
if (shouldGrow && blipSize < 4) blipSize++;
|
|
}
|
|
|
|
public void Step(bool isInput = false)
|
|
{
|
|
if (isInput || ((game.stepIterate % 2 == 0) == IsMirrored())) {
|
|
shadows[0].SetActive(IsMirrored());
|
|
shadows[1].SetActive(!IsMirrored());
|
|
transform.localScale = new Vector3((IsMirrored() ? 1 : -1), 1, 1);
|
|
}
|
|
|
|
anim.DoScaledAnimationAsync("Step", 0.5f);
|
|
SoundByte.PlayOneShotGame("mrUpbeat/step");
|
|
}
|
|
|
|
public void Fall()
|
|
{
|
|
anim.DoScaledAnimationAsync((game.stepIterate % 2 == 0) == IsMirrored() ? "FallR" : "FallL", 1f);
|
|
SoundByte.PlayOneShot("miss");
|
|
shadows[0].SetActive(false);
|
|
shadows[1].SetActive(false);
|
|
transform.localScale = new Vector3((IsMirrored() ? 1 : -1), 1, 1);
|
|
}
|
|
|
|
bool IsMirrored()
|
|
{
|
|
return transform.localScale != Vector3.one;
|
|
}
|
|
}
|
|
} |