AstrlJelly f540241fb7
Mr. Upbeat Re-Re-Rework (#525)
* so much

* reworked everything (AGAIN.)
 -everything just uses recursive methods and beatactions, and only uses the update loop for inactive queuing
* count-ins
 -need hq 4 sound effect, kitties doesn't have the og :(
* mr. downbeat rere-revived (unfortunately enough.)
* huge change to how stepping works, to make it so you can't step over it the wrong way, and so that missing looks good
* added missing miss anim, which happens in the same way as the og
* added a check on game switch to use the last bg change/blip color block's attributes
 -i think i might add these to other games; it should make the process of remixing more intuitive and fun, even if it's a small change

currently all i'm missing is blip jank fix. but im not staying up another hour for that lol

* letter/blip jank fixed + force stepping

* instead of being a separate animator, the letter is instead set to have a scale of (1, 1, 1) in the update loop, so that no graphical bugs happen even when the scale is changed.
* hopefully this new system is a lot less janky, but if bugs do still come up they'll be a lot easier to fix now
2023-08-12 03:32:33 +00:00

86 lines
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(gameObject, 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;
}
}
}