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:
@ -52,22 +52,6 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
minigames[minigames.FindIndex(c => c.name == minigamesInBeatmap[i].name)].holder = Resources.Load<GameObject>($"Games/{minigamesInBeatmap[i].name}");
|
||||
}
|
||||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
string[] e = GameManager.instance.Beatmap.entities[i].datamodel.Split('/');
|
||||
try
|
||||
{
|
||||
if (minigames.Find(c => c.name == e[0]).actions.Find(c => c.actionName == e[1]).playerAction == true && e[0] != "gameManager")
|
||||
{
|
||||
GameManager.instance.playerEntities.Add(GameManager.instance.Beatmap.entities[i]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning(GameManager.instance.Beatmap.entities[i].datamodel + " " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -92,9 +76,6 @@ namespace RhythmHeavenMania
|
||||
Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
action.function.Invoke();
|
||||
|
||||
if (action.playerAction == true)
|
||||
GameManager.instance.currentPlayerEvent++;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
9
Assets/Scripts/GameEvent.cs
Normal file
9
Assets/Scripts/GameEvent.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
public class GameEvent
|
||||
{
|
||||
public float length;
|
||||
public float startBeat;
|
||||
public float lastReportedBeat;
|
||||
}
|
||||
}
|
11
Assets/Scripts/GameEvent.cs.meta
Normal file
11
Assets/Scripts/GameEvent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2b5bd1181291e346b57ddd994b54e8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -70,7 +70,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
}
|
||||
comboIndex++;
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
AnimPlay("PunchLeft");
|
||||
}
|
||||
else if (normalizedBeat >= 1.25f && comboIndex < 2)
|
||||
{
|
||||
@ -86,7 +86,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit_Alt");
|
||||
}
|
||||
comboIndex++;
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
AnimPlay("PunchRight");
|
||||
}
|
||||
else if (normalizedBeat >= 1.5f && comboIndex < 3)
|
||||
{
|
||||
@ -98,7 +98,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit2");
|
||||
}
|
||||
comboIndex++;
|
||||
anim.Play("ComboCrouch", 0, 0);
|
||||
AnimPlay("ComboCrouch");
|
||||
}
|
||||
else if (normalizedBeat >= 1.75f && comboIndex < 4)
|
||||
{
|
||||
@ -114,7 +114,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/comboMiss");
|
||||
}
|
||||
comboIndex++;
|
||||
anim.Play("ComboKick", 0, 0);
|
||||
AnimPlay("ComboKick");
|
||||
}
|
||||
else if (normalizedBeat >= 2f && comboIndex < 5)
|
||||
{
|
||||
@ -126,7 +126,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/comboHit3");
|
||||
}
|
||||
comboIndex++;
|
||||
anim.Play("ComboCrouchPunch", 0, 0);
|
||||
AnimPlay("ComboCrouchPunch");
|
||||
}
|
||||
else if (normalizedBeat >= 2.05f)
|
||||
{
|
||||
@ -140,7 +140,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
else
|
||||
{
|
||||
// fail anim
|
||||
anim.Play("ComboMiss");
|
||||
AnimPlay("ComboMiss");
|
||||
ResetCombo();
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
{
|
||||
if (kickC != null) StopCoroutine(kickC);
|
||||
hitBarrel = false;
|
||||
anim.Play("Kick", 0, 0);
|
||||
AnimPlay("Kick");
|
||||
}
|
||||
|
||||
if (Conductor.instance.songPositionInBeats > barrelBeat + 3)
|
||||
@ -167,7 +167,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
if (kickC != null) StopCoroutine(kickC);
|
||||
hitBarrel = false;
|
||||
// should be inebetween for this
|
||||
anim.Play("Idle", 0, 0);
|
||||
AnimPlay("Idle");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -244,7 +244,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
barrelBeat = Conductor.instance.songPositionInBeats;
|
||||
hitBarrel = true;
|
||||
yield return new WaitForSeconds(0.17f);
|
||||
anim.Play("KickPrepare", 0, 0);
|
||||
AnimPlay("KickPrepare");
|
||||
}
|
||||
|
||||
private void Swing()
|
||||
@ -313,9 +313,9 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
AnimPlay("PunchLeft");
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
AnimPlay("PunchRight");
|
||||
}
|
||||
|
||||
public void HitEffectF(Vector3 pos)
|
||||
@ -327,6 +327,12 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
Destroy(hit, 0.06f);
|
||||
}
|
||||
|
||||
public void AnimPlay(string name)
|
||||
{
|
||||
anim.Play(name, 0, 0);
|
||||
anim.speed = 1;
|
||||
}
|
||||
|
||||
private void BarrelDestroy(Pot p, bool combo)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
|
@ -22,15 +22,20 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
public SpriteRenderer BGSprite;
|
||||
|
||||
private bool bgEnabled;
|
||||
private float newBeat, newBeatBop;
|
||||
private float newBeat;
|
||||
|
||||
private float bopLength;
|
||||
private float bopBeat;
|
||||
public GameEvent bop = new GameEvent();
|
||||
public GameEvent prepare = new GameEvent();
|
||||
|
||||
private float bgBeat;
|
||||
|
||||
public GameObject comboRef;
|
||||
|
||||
public GameObject HIT3Ref;
|
||||
|
||||
public Sprite[] Numbers;
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class BGSpriteC
|
||||
{
|
||||
@ -122,10 +127,10 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/punchKick1", beat + 1f),
|
||||
new MultiSound.Sound("karateman/punchKick2", beat + 1.5f),
|
||||
new MultiSound.Sound("karateman/punchKick3", beat + 1.75f),
|
||||
new MultiSound.Sound("karateman/punchKick4", beat + 2.25f)
|
||||
new MultiSound.Sound("karateman/punchKick1", beat + 1f),
|
||||
new MultiSound.Sound("karateman/punchKick2", beat + 1.5f),
|
||||
new MultiSound.Sound("karateman/punchKick3", beat + 1.75f),
|
||||
new MultiSound.Sound("karateman/punchKick4", beat + 2.25f)
|
||||
});
|
||||
break;
|
||||
}
|
||||
@ -154,15 +159,28 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref newBeatBop, bopBeat % 1))
|
||||
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= bopBeat && Conductor.instance.songPositionInBeats < bopBeat + bopLength)
|
||||
if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length)
|
||||
{
|
||||
float compare = KarateJoe.anim.GetCurrentAnimatorStateInfo(0).speed;
|
||||
if (KarateJoe.anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= compare && !KarateJoe.anim.IsInTransition(0))
|
||||
if (KarateJoe.anim.IsAnimationNotPlaying())
|
||||
KarateJoe.anim.Play("Bop", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (prepare.length > 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= prepare.startBeat && Conductor.instance.songPositionInBeats < prepare.startBeat + prepare.length)
|
||||
{
|
||||
if (KarateJoe.anim.IsAnimationNotPlaying())
|
||||
KarateJoe.AnimPlay("Prepare");
|
||||
}
|
||||
else
|
||||
{
|
||||
KarateJoe.AnimPlay("Idle");
|
||||
prepare.length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BGFXOn()
|
||||
@ -178,13 +196,38 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
public void Bop(float beat, float length)
|
||||
{
|
||||
bopLength = length;
|
||||
bopBeat = beat;
|
||||
bop.length = length;
|
||||
bop.startBeat = beat;
|
||||
}
|
||||
|
||||
public void Hit3(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/hit", beat), new MultiSound.Sound("karateman/three", beat + 0.5f) });
|
||||
GameObject hit3 = Instantiate(HIT3Ref, this.transform);
|
||||
hit3.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[2];
|
||||
BeatAction.New(hit3, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { hit3.transform.GetChild(0).gameObject.SetActive(true); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Destroy(hit3); })
|
||||
});
|
||||
}
|
||||
|
||||
public void Hit4(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/hit", beat), new MultiSound.Sound("karateman/four", beat + 0.5f) });
|
||||
GameObject hit4 = Instantiate(HIT3Ref, this.transform);
|
||||
hit4.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[3];
|
||||
BeatAction.New(hit4, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { hit4.transform.GetChild(0).gameObject.SetActive(true); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Destroy(hit4); })
|
||||
});
|
||||
}
|
||||
|
||||
public void Prepare(float beat, float length)
|
||||
{
|
||||
prepare.startBeat = beat;
|
||||
prepare.length = length;
|
||||
}
|
||||
|
||||
public void CreateBomb(Transform parent, Vector2 scale, ref GameObject shadow)
|
||||
|
@ -51,7 +51,7 @@ namespace RhythmHeavenMania.Editor
|
||||
var entity = GameManager.instance.Beatmap.entities[i];
|
||||
var e = GameManager.instance.Beatmap.entities[i];
|
||||
|
||||
AddEventObject(e.datamodel, false, new Vector3(e.beat, Mathp.Round2Nearest(Random.Range(0, -LayersRect.rect.height), LayerHeight())), i);
|
||||
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), i);
|
||||
}
|
||||
|
||||
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
|
||||
@ -322,7 +322,7 @@ namespace RhythmHeavenMania.Editor
|
||||
else
|
||||
{
|
||||
eventObj.resizable = true;
|
||||
if (gameAction.defaultLength != GameManager.instance.Beatmap.entities[entityId].length)
|
||||
if (gameAction.defaultLength != GameManager.instance.Beatmap.entities[entityId].length && dragNDrop == false)
|
||||
{
|
||||
g.GetComponent<RectTransform>().sizeDelta = new Vector2(GameManager.instance.Beatmap.entities[entityId].length, LayerHeight());
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
{
|
||||
this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
// this.transform.GetChild(i).gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,6 +155,8 @@ namespace RhythmHeavenMania.Editor
|
||||
startPosY = mousePos.y - this.transform.position.y;
|
||||
|
||||
moving = true;
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
public void OnUp()
|
||||
@ -210,13 +212,14 @@ namespace RhythmHeavenMania.Editor
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
public void OnLeftUp()
|
||||
{
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
resizing = false;
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
public void OnRightDown()
|
||||
@ -238,13 +241,13 @@ namespace RhythmHeavenMania.Editor
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
public void OnRightUp()
|
||||
{
|
||||
resizing = false;
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
private void SetPivot(Vector2 pivot)
|
||||
@ -272,6 +275,8 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
eligibleToMove = true;
|
||||
}
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
private void OnComplete()
|
||||
|
124
Assets/Scripts/LevelEditor/WaveformVisual.cs
Normal file
124
Assets/Scripts/LevelEditor/WaveformVisual.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
public class WaveformVisual : MonoBehaviour
|
||||
{
|
||||
public new AudioSource audio;
|
||||
|
||||
public RawImage image;
|
||||
|
||||
public int width;
|
||||
|
||||
public Color col;
|
||||
|
||||
int resolution = 60;
|
||||
|
||||
float[] waveForm;
|
||||
float[] samples;
|
||||
|
||||
Texture2D texture;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audio = Conductor.instance.musicSource;
|
||||
GetComponent<RectTransform>().sizeDelta = new Vector2(Conductor.instance.SongLengthInBeats(), GetComponent<RectTransform>().sizeDelta.y);
|
||||
texture = new Texture2D(width, 100, TextureFormat.RGBA32, false);
|
||||
CreateWaveForm();
|
||||
}
|
||||
|
||||
// This two are from unity answer (I mixed up)
|
||||
public void CreateWaveForm()
|
||||
{
|
||||
resolution = audio.clip.frequency / resolution;
|
||||
|
||||
samples = new float[audio.clip.samples * audio.clip.channels];
|
||||
audio.clip.GetData(samples, 0);
|
||||
|
||||
int s = 0;
|
||||
while (s < samples.Length)
|
||||
{
|
||||
samples[s] = samples[s] * 0.5F;
|
||||
++s;
|
||||
}
|
||||
audio.clip.SetData(samples, 0);
|
||||
|
||||
waveForm = new float[(samples.Length / resolution)];
|
||||
|
||||
for (int i = 0; i < waveForm.Length; i++)
|
||||
{
|
||||
waveForm[i] = 0;
|
||||
|
||||
for (int ii = 0; ii < resolution; ii++)
|
||||
{
|
||||
waveForm[i] += Mathf.Abs(samples[(i * resolution) + ii]);
|
||||
}
|
||||
|
||||
waveForm[i] /= resolution;
|
||||
}
|
||||
|
||||
MakeTexture(width, 100, waveForm, col);
|
||||
}
|
||||
|
||||
public void MakeTexture(int width, int height, float[] waveform, Color col)
|
||||
{
|
||||
texture = new Texture2D(width, height, TextureFormat.RGBA32, false);
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
texture.SetPixel(x, y, Color.black);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < waveform.Length; x++)
|
||||
{
|
||||
for (int y = 0; y <= waveform[x] * ((float)height * .75f); y++)
|
||||
{
|
||||
texture.SetPixel(x, (height / 2) + y, col);
|
||||
texture.SetPixel(x, (height / 2) - y, col);
|
||||
}
|
||||
}
|
||||
|
||||
texture.Apply();
|
||||
|
||||
image.texture = texture;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//script from unity doc.
|
||||
float[] spectrum = new float[1024];
|
||||
|
||||
AudioListener.GetSpectrumData(spectrum, 0, FFTWindow.Rectangular);
|
||||
|
||||
/*for (int i = 1; i < spectrum.Length - 1; i++)
|
||||
{
|
||||
Debug.DrawLine(new Vector3(i - 1, spectrum[i] + 10, 0), new Vector3(i, spectrum[i + 1] + 10, 0), Color.red);
|
||||
Debug.DrawLine(new Vector3(i - 1, Mathf.Log(spectrum[i - 1]) + 10, 2), new Vector3(i, Mathf.Log(spectrum[i]) + 10, 2), Color.cyan);
|
||||
Debug.DrawLine(new Vector3(Mathf.Log(i - 1), spectrum[i - 1] - 10, 1), new Vector3(Mathf.Log(i), spectrum[i] - 10, 1), Color.green);
|
||||
Debug.DrawLine(new Vector3(Mathf.Log(i - 1), Mathf.Log(spectrum[i - 1]), 3), new Vector3(Mathf.Log(i), Mathf.Log(spectrum[i]), 3), Color.blue);
|
||||
}
|
||||
|
||||
//script from unity answer
|
||||
for (int i = 0; i < waveForm.Length - 1; i++)
|
||||
{
|
||||
Vector3 sv = new Vector3(i * .01f, waveForm[i] * 10, 0);
|
||||
Vector3 ev = new Vector3(i * .01f, -waveForm[i] * 10, 0);
|
||||
|
||||
Debug.DrawLine(sv, ev, Color.yellow);
|
||||
}*/
|
||||
|
||||
int current = audio.timeSamples / resolution;
|
||||
current *= 2;
|
||||
|
||||
Vector3 c = new Vector3(current * .01f, 0, 0);
|
||||
|
||||
Debug.DrawLine(c, c + Vector3.up * 10, Color.white);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/WaveformVisual.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/WaveformVisual.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29c850cbdd078e94aa96bb4fb67cdc8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -34,15 +34,13 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
public string actionName;
|
||||
public EventCallback function;
|
||||
public bool playerAction = false;
|
||||
public float defaultLength;
|
||||
public bool resizable;
|
||||
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool playerAction = false, bool resizable = false)
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool resizable = false)
|
||||
{
|
||||
this.actionName = actionName;
|
||||
this.function = function;
|
||||
this.playerAction = playerAction;
|
||||
this.defaultLength = defaultLength;
|
||||
this.resizable = resizable;
|
||||
}
|
||||
@ -61,11 +59,11 @@ namespace RhythmHeavenMania
|
||||
}),
|
||||
new Minigame("forkLifter", "Fork Lifter", "FFFFFF", new List<GameAction>()
|
||||
{
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 0); }, 3, true),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 1); }, 3, true),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 2); }, 3, true),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 3); }, 3, true),
|
||||
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f, true),
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 0); }, 3),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 1); }, 3),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 2); }, 3),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(eventCaller.currentBeat, 3); }, 3),
|
||||
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }, 0.5f),
|
||||
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
|
||||
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
|
||||
}),
|
||||
@ -78,24 +76,26 @@ namespace RhythmHeavenMania
|
||||
}),
|
||||
new Minigame("spaceball", "Spaceball", "00A518", new List<GameAction>()
|
||||
{
|
||||
new GameAction("shoot", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, false, eventCaller.currentType); }, 2, true),
|
||||
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, true, eventCaller.currentType); }, 3, true),
|
||||
new GameAction("shoot", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, false, eventCaller.currentType); }, 2),
|
||||
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, true, eventCaller.currentType); }, 3),
|
||||
new GameAction("costume", delegate { Spaceball.instance.Costume(eventCaller.currentType); } ),
|
||||
new GameAction("alien", delegate { Spaceball.instance.alien.Show(eventCaller.currentBeat); } ),
|
||||
new GameAction("cameraZoom", delegate { }, 4, false, true ),
|
||||
new GameAction("cameraZoom", delegate { }, 4, true ),
|
||||
}),
|
||||
new Minigame("karateman", "Karate Man", "70A8D8", new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(eventCaller.currentBeat, eventCaller.currentLength); }, 0.5f, true, true),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 0); }, 2, true),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 1); }, 2, true),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 2); }, 2, true),
|
||||
new GameAction("ball", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 3); }, 2, true),
|
||||
new GameAction("kick", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 4); }, 4.5f, true),
|
||||
new GameAction("combo", delegate { KarateMan.instance.Combo(eventCaller.currentBeat); }, 4f, true),
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(eventCaller.currentBeat, eventCaller.currentLength); }, 0.5f, true),
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 0); }, 2),
|
||||
new GameAction("bulb", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 1); }, 2),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 2); }, 2),
|
||||
new GameAction("ball", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 3); }, 2),
|
||||
new GameAction("kick", delegate { KarateMan.instance.Shoot(eventCaller.currentBeat, 4); }, 4.5f),
|
||||
new GameAction("combo", delegate { KarateMan.instance.Combo(eventCaller.currentBeat); }, 4f),
|
||||
new GameAction("hit3", delegate { KarateMan.instance.Hit3(eventCaller.currentBeat); }),
|
||||
new GameAction("hit4", delegate { KarateMan.instance.Hit4(eventCaller.currentBeat); }),
|
||||
new GameAction("prepare", delegate { KarateMan.instance.Prepare(eventCaller.currentBeat, eventCaller.currentLength); }, 1f, true),
|
||||
new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ),
|
||||
new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }),
|
||||
new GameAction("hit3", delegate { KarateMan.instance.Hit3(eventCaller.currentBeat); }),
|
||||
})
|
||||
};
|
||||
}
|
||||
|
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