mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-14 05:35:08 +00:00
78e5278ea8
* passed out seven times but here's your mr upbeat im so tired. and r1 is right here. but mr upbeat is better now i guess and dog ninja's bopping is fixed * also a little bit more
103 lines
No EOL
3.4 KiB
C#
103 lines
No EOL
3.4 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] Transform antennaLight;
|
|
[SerializeField] GameObject[] shadows;
|
|
[SerializeField] TMP_Text blipText;
|
|
|
|
public int blipSize = 0;
|
|
public bool shouldGrow;
|
|
public bool shouldBlip = true;
|
|
public string blipString = "M";
|
|
public bool canStep = false; // just disabled when you normally couldn't step, which is anything less than 2 beats before you would start stepping and any time after the Ding!
|
|
public bool canStepFromAnim = true; // disabled when stepping, then reenabled in the animation events. you can step JUST BARELY before the animation ends in fever
|
|
|
|
private static MrUpbeat game;
|
|
|
|
void Awake()
|
|
{
|
|
game = MrUpbeat.instance;
|
|
|
|
canStep = false;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
blipText.transform.localPosition = new Vector3(antennaLight.position.x, antennaLight.position.y + 0.7f);
|
|
|
|
if (PlayerInput.GetIsAction(MrUpbeat.InputAction_BasicPress) && !game.IsExpectingInputNow(MrUpbeat.InputAction_BasicPress)
|
|
&& canStep && canStepFromAnim) {
|
|
Step(true);
|
|
}
|
|
}
|
|
|
|
public void RecursiveBlipping(double beat)
|
|
{
|
|
if (game.stopBlipping) {
|
|
game.stopBlipping = false;
|
|
return;
|
|
}
|
|
if (shouldBlip) {
|
|
Blipping();
|
|
}
|
|
BeatAction.New(this, new List<BeatAction.Action>() {
|
|
new BeatAction.Action(beat + 1, delegate { RecursiveBlipping(beat + 1); })
|
|
});
|
|
}
|
|
|
|
public void Blipping()
|
|
{
|
|
SoundByte.PlayOneShotGame("mrUpbeat/blip");
|
|
blipAnim.Play("Blip" + (blipSize + 1), 0, 0);
|
|
blipText.gameObject.SetActive(blipSize >= 4);
|
|
|
|
blipText.text = blipString != "" ? blipString : "";
|
|
if (shouldGrow && blipSize < 4) blipSize++;
|
|
}
|
|
|
|
public void Step(bool isInput = false)
|
|
{
|
|
if (isInput || FacingCorrectly()) {
|
|
shadows[0].SetActive(transform.localScale.x < 0);
|
|
shadows[1].SetActive(transform.localScale.x > 0);
|
|
Flip();
|
|
}
|
|
|
|
anim.DoScaledAnimationAsync("Step", 0.5f);
|
|
SoundByte.PlayOneShotGame("mrUpbeat/step");
|
|
}
|
|
|
|
public void Fall()
|
|
{
|
|
anim.DoScaledAnimationAsync(FacingCorrectly() ? "FallR" : "FallL", 1f);
|
|
SoundByte.PlayOneShot("miss");
|
|
shadows[0].SetActive(false);
|
|
shadows[1].SetActive(false);
|
|
Flip();
|
|
}
|
|
|
|
void Flip() {
|
|
var scale = transform.localScale;
|
|
transform.localScale = new Vector3(-scale.x, scale.y, scale.z);
|
|
}
|
|
|
|
|
|
public bool FacingCorrectly() => (game.stepIterate % 2 == 0) == (transform.localScale.x < 0);
|
|
|
|
// animation event
|
|
public void ToggleStepping(int canStep) // why do unity animation events not support booleans??? this is a 1 for true or 0 for false
|
|
{
|
|
canStepFromAnim = canStep == 1;
|
|
}
|
|
}
|
|
} |