mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
Mr. Upbeat Rework (#418)
* everything but the text * new spritesheet (thank u sean) * better/more accurate background color * bg color changing with fade (code courtesy of ras) * mr. upbeat blip color changing * full blip implementation, with size changing and text display * text is still weird (gray box around all the letters) but i hope that's an easy fix. * almost done just need to fix the text and get rid of the reliance on the ding! block * finishing touches + a buncha testing everything works!!! and i don't think i left anything out * forgot an n lol * oh my god i hate mr. downbeat this "force" option is not very intuitive to use. nor is it coded amazingly. but i do not care. if you really wanna use it then mess around and see what works
This commit is contained in:
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
using TMPro;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
@ -11,60 +12,61 @@ namespace HeavenStudio.Games.Scripts_MrUpbeat
|
||||
public class UpbeatMan : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
public MrUpbeat game;
|
||||
public Animator animator;
|
||||
public Animator blipAnimator;
|
||||
public GameObject[] shadows;
|
||||
[SerializeField] Animator anim;
|
||||
[SerializeField] Animator blipAnim;
|
||||
[SerializeField] Animator letterAnim;
|
||||
[SerializeField] GameObject[] shadows;
|
||||
[SerializeField] TMP_Text blipText;
|
||||
|
||||
public float targetBeat = 0.25f;
|
||||
public int stepTimes = 0;
|
||||
private bool stepped = false;
|
||||
private bool onGround = false;
|
||||
public int blipSize = 0;
|
||||
public string blipString = "M";
|
||||
|
||||
public GameEvent blip = new GameEvent();
|
||||
|
||||
public void Idle()
|
||||
public void Blip()
|
||||
{
|
||||
stepTimes = 0;
|
||||
transform.localScale = new Vector3(1, 1);
|
||||
animator.Play("Idle", 0, 0);
|
||||
float c = Conductor.instance.songPositionInBeats;
|
||||
// checks if the position is on an offbeat; accurate until you get down to 20 fps or so (i.e unplayable)
|
||||
float pos = ((MathF.Floor(c * 10)/10 % 1) == 0.5f) ? MathF.Floor(c) : MathF.Round(c);
|
||||
|
||||
// recursive, should happen on the offbeat (unless downbeatMod is different)
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() {
|
||||
new BeatAction.Action(pos + MrUpbeat.downbeatMod, delegate {
|
||||
if (MrUpbeat.shouldBlip) {
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/blip");
|
||||
blipAnim.Play("Blip"+(blipSize+1), 0, 0);
|
||||
blipText.text = (blipSize == 4 && blipString != "") ? blipString : "";
|
||||
}
|
||||
}),
|
||||
new BeatAction.Action(pos + MrUpbeat.downbeatMod + 0.999f, delegate {
|
||||
Blip();
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
public void Step()
|
||||
{
|
||||
stepTimes++;
|
||||
|
||||
bool x = (stepTimes % 2 == 1);
|
||||
shadows[0].SetActive(!x);
|
||||
shadows[1].SetActive(x);
|
||||
transform.localScale = new Vector3(x ? -1 : 1, 1);
|
||||
|
||||
animator.Play("Step", 0, 0);
|
||||
anim.DoScaledAnimationAsync("Step", 0.5f);
|
||||
letterAnim.DoScaledAnimationAsync(x ? "StepRight" : "StepLeft", 0.5f);
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/step");
|
||||
|
||||
onGround = false;
|
||||
CheckShadows();
|
||||
}
|
||||
|
||||
public void Fall()
|
||||
{
|
||||
animator.Play("Fall", 0, 0);
|
||||
blipSize = 0;
|
||||
blipAnim.Play("Idle", 0, 0);
|
||||
blipText.text = "";
|
||||
|
||||
anim.DoScaledAnimationAsync("Fall", 0.5f);
|
||||
Jukebox.PlayOneShot("miss");
|
||||
shadows[0].SetActive(false);
|
||||
shadows[1].SetActive(false);
|
||||
onGround = true;
|
||||
}
|
||||
|
||||
private void CheckShadows()
|
||||
{
|
||||
if (onGround) return;
|
||||
|
||||
if (stepTimes % 2 == 1)
|
||||
{
|
||||
shadows[0].SetActive(false);
|
||||
shadows[1].SetActive(true);
|
||||
transform.localScale = new Vector3(-1, 1);
|
||||
} else
|
||||
{
|
||||
shadows[0].SetActive(true);
|
||||
shadows[1].SetActive(false);
|
||||
transform.localScale = new Vector3(1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user