mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:07:38 +02:00
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:
13
Assets/Scripts/Util/AnimationHelpers.cs
Normal file
13
Assets/Scripts/Util/AnimationHelpers.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Util/AnimationHelpers.cs.meta
Normal file
11
Assets/Scripts/Util/AnimationHelpers.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 790eba0f95f13f34992936566436eab1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Assets/Scripts/Util/BeatAction.cs
Normal file
47
Assets/Scripts/Util/BeatAction.cs
Normal 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Util/BeatAction.cs.meta
Normal file
11
Assets/Scripts/Util/BeatAction.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a46fad3208ea5224aa38fdf3de0a9dec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user