A lot of stuff (Read desc)

Beat action is now used to define one-off objects that is used by the beat but I don't wanna bother making a different script for. Example case: the "hit 3" sprite in Karate Man.

Animation helpers for functions I don't wanna rewrite 100,000 times.

General improvements for Karate Man, like prepare animation and some updates to game events.
This commit is contained in:
Braedon
2022-01-21 02:09:32 -05:00
parent 59aae67174
commit fa519d25d7
27 changed files with 2076 additions and 233 deletions

View File

@ -0,0 +1,13 @@
using UnityEngine;
namespace RhythmHeavenMania.Util
{
public static class AnimationHelpers
{
public static bool IsAnimationNotPlaying(this Animator anim)
{
float compare = anim.GetCurrentAnimatorStateInfo(0).speed;
return anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= compare && !anim.IsInTransition(0);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 790eba0f95f13f34992936566436eab1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RhythmHeavenMania.Util
{
public class BeatAction : MonoBehaviour
{
private int index;
private List<Action> actions = new List<Action>();
public delegate void EventCallback();
public class Action
{
public float beat { get; set; }
public EventCallback function { get; set; }
public Action(float beat, EventCallback function)
{
this.beat = beat;
this.function = function;
}
}
public static void New(GameObject prefab, List<Action> actions)
{
BeatAction beatAction = prefab.AddComponent<BeatAction>();
beatAction.actions = actions;
}
private void Update()
{
float songPositionInBeats = Conductor.instance.songPositionInBeats;
for (int i = 0; i < actions.Count; i++)
{
if (songPositionInBeats >= actions[i].beat && index == i)
{
actions[i].function.Invoke();
index++;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a46fad3208ea5224aa38fdf3de0a9dec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: