mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-11 04:05:11 +00:00
36afef6f9e
* lotta stuffs
* dj school bug fixed
* dog ninja overhauled AGAIN. you can start a cue outside of the game now (something i planned months ago lol)
* also two objects will not overlap when they're the same but when they're not the same they will overlap
* commiting cause im gonna try half-recoding meat grinder
* also im trying to fix mrupbeat's beeping cuz oh my god how is this not fixed yet
* meat grinder finished + tap trial bug fixed + mute dog ninja
MUTE DOG NINJA ONLY WHEN INACTIVE ‼️
* last minute stuff + mr upbeat
i will be reworking mr upbeat in another branch but i wanna not bloat this pr any further so bleehhhh :P
* dj school final bug fix
228 lines
No EOL
8.2 KiB
C#
228 lines
No EOL
8.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using System;
|
|
using Starpelly;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
{
|
|
using static Minigames;
|
|
public static class AgbUpbeatLoader
|
|
{
|
|
public static Minigame AddGame(EventCaller eventCaller) {
|
|
return new Minigame("mrUpbeat", "Mr. Upbeat", "ffffff", false, false, new List<GameAction>()
|
|
{
|
|
new GameAction("stepping", "Start Stepping")
|
|
{
|
|
preFunction = delegate {var e = eventCaller.currentEntity; MrUpbeat.Stepping(e.beat, e.length); },
|
|
defaultLength = 4f,
|
|
resizable = true,
|
|
},
|
|
new GameAction("blipping", "Beeping")
|
|
{
|
|
function = delegate {var e = eventCaller.currentEntity; MrUpbeat.Blipping(e.beat, e.length); },
|
|
defaultLength = 4f,
|
|
resizable = true,
|
|
inactiveFunction = delegate {var e = eventCaller.currentEntity; MrUpbeat.Blipping(e.beat, e.length); },
|
|
},
|
|
new GameAction("ding!", "Ding!")
|
|
{
|
|
function = delegate { MrUpbeat.instance.Ding(eventCaller.currentEntity["toggle"]); },
|
|
defaultLength = 0.5f,
|
|
parameters = new List<Param>()
|
|
{
|
|
new Param("toggle", false, "Applause")
|
|
}
|
|
},
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace HeavenStudio.Games
|
|
{
|
|
using Scripts_MrUpbeat;
|
|
|
|
public class MrUpbeat : Minigame
|
|
{
|
|
static List<float> queuedBeeps = new List<float>();
|
|
static List<queuedUpbeatInputs> queuedInputs = new List<queuedUpbeatInputs>();
|
|
public struct queuedUpbeatInputs
|
|
{
|
|
public float beat;
|
|
public bool goRight;
|
|
}
|
|
|
|
[Header("References")]
|
|
public Animator metronomeAnim;
|
|
public UpbeatMan man;
|
|
|
|
[Header("Properties")]
|
|
bool startLeft;
|
|
|
|
public static MrUpbeat instance;
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
|
{
|
|
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
|
if (queuedBeeps.Count > 0) queuedBeeps.Clear();
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
var cond = Conductor.instance;
|
|
if (cond.isPlaying && !cond.isPaused)
|
|
{
|
|
if (queuedInputs.Count > 0)
|
|
{
|
|
foreach (var input in queuedInputs)
|
|
{
|
|
ScheduleInput(cond.songPositionInBeats, input.beat - cond.songPositionInBeats, InputType.STANDARD_DOWN, Success, Miss, Nothing);
|
|
if (input.goRight)
|
|
{
|
|
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(input.beat - 0.5f, delegate { MrUpbeat.instance.metronomeAnim.DoScaledAnimationAsync("MetronomeGoLeft", 0.5f); }),
|
|
new BeatAction.Action(input.beat - 0.5f, delegate { Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight"); }),
|
|
});
|
|
}
|
|
else
|
|
{
|
|
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(input.beat - 0.5f, delegate { MrUpbeat.instance.metronomeAnim.DoScaledAnimationAsync("MetronomeGoRight", 0.5f); }),
|
|
new BeatAction.Action(input.beat - 0.5f, delegate { Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft"); }),
|
|
});
|
|
}
|
|
}
|
|
if (queuedInputs.Count % 2 != 0)
|
|
{
|
|
startLeft = true;
|
|
}
|
|
else
|
|
{
|
|
startLeft = false;
|
|
}
|
|
queuedInputs.Clear();
|
|
}
|
|
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
|
|
{
|
|
man.Step();
|
|
}
|
|
}
|
|
|
|
if (queuedBeeps.Count > 0) {
|
|
var beepAnims = new List<BeatAction.Action>();
|
|
foreach (var item in queuedBeeps)
|
|
{
|
|
beepAnims.Add(new BeatAction.Action(item, delegate { man.blipAnimator.Play("Blip", 0, 0); }));
|
|
}
|
|
BeatAction.New(instance.gameObject, beepAnims);
|
|
queuedBeeps.Clear();
|
|
}
|
|
}
|
|
|
|
public void Ding(bool applause)
|
|
{
|
|
Jukebox.PlayOneShotGame("mrUpbeat/ding");
|
|
if (applause) Jukebox.PlayOneShot("applause");
|
|
}
|
|
|
|
public static void Blipping(float beat, float length)
|
|
{
|
|
List<MultiSound.Sound> beeps = new List<MultiSound.Sound>();
|
|
|
|
for (int i = 0; i < length + 1; i++)
|
|
{
|
|
beeps.Add(new MultiSound.Sound("mrUpbeat/blip", beat + i));
|
|
queuedBeeps.Add(beat + i);
|
|
}
|
|
|
|
MultiSound.Play(beeps.ToArray(), forcePlay: true);
|
|
}
|
|
|
|
public static void Stepping(float beat, float length)
|
|
{
|
|
if (GameManager.instance.currentGame == "mrUpbeat")
|
|
{
|
|
float offSet = 0;
|
|
if (MrUpbeat.instance.startLeft)
|
|
{
|
|
offSet = 1;
|
|
}
|
|
for (int i = 0; i < length + 1; i++)
|
|
{
|
|
MrUpbeat.instance.ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, MrUpbeat.instance.Success, MrUpbeat.instance.Miss, MrUpbeat.instance.Nothing);
|
|
if ((i + offSet) % 2 == 0)
|
|
{
|
|
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat + i - 0.5f, delegate { MrUpbeat.instance.metronomeAnim.DoScaledAnimationAsync("MetronomeGoLeft", 0.5f); }),
|
|
new BeatAction.Action(beat + i - 0.5f, delegate { Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight"); }),
|
|
});
|
|
}
|
|
else
|
|
{
|
|
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat + i - 0.5f, delegate { MrUpbeat.instance.metronomeAnim.DoScaledAnimationAsync("MetronomeGoRight", 0.5f); }),
|
|
new BeatAction.Action(beat + i - 0.5f, delegate { Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft"); }),
|
|
});
|
|
}
|
|
|
|
}
|
|
if ((length + 1) % 2 != 0)
|
|
{
|
|
MrUpbeat.instance.startLeft = true;
|
|
}
|
|
else
|
|
{
|
|
MrUpbeat.instance.startLeft = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < length + 1; i++)
|
|
{
|
|
queuedInputs.Add(new queuedUpbeatInputs
|
|
{
|
|
beat = beat + i,
|
|
goRight = i % 2 == 0
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Success(PlayerActionEvent caller, float state)
|
|
{
|
|
man.Step();
|
|
}
|
|
|
|
public void Miss(PlayerActionEvent caller)
|
|
{
|
|
man.Fall();
|
|
}
|
|
|
|
bool isPlaying(Animator anim, string stateName)
|
|
{
|
|
if (anim.GetCurrentAnimatorStateInfo(0).IsName(stateName) &&
|
|
anim.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public void Nothing(PlayerActionEvent caller) {}
|
|
}
|
|
} |