mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:47:37 +02:00
Playable lockstep + Mr. Upbeat fix! (Lockstep is missing recolorable switchsteppers, many of them, and bach portraits) (#227)
* Added sfx, sprites and folders neccesary. And also made an empty game object for working dough * Started work on the background * Implemented all unanimated sprites * Added Init * Added Prefabs * Added Jumping and Idle Animatins for the Dough Dudes * SmallFix * Start Interval Event Implemented * Added Audio and Small and Big Ball events * Code Improvement + starting making the balls * Added bezier curves * Added First Rendition of Balls * Added NPC Balls and starting doing small transporting animations * SmallFixes * SmallSoundChanges * Implemented Audio and prefunction, not done with it though * In process of fixing set interval * Added more prefunction stuff and also started working on player input * Tried adding player balls, not done, many bugs to fix * Reverted trying to make the playerenterdoughball handle inputs, gonna do it through the main script instead * Sat up input code for later * Input works now! Need to add barely and wrong input animations and fix bugs * Tiny fix * Added first draft of wronginput animations * Finished all input anims, trying to fix bugs * Added finished Spaceship animations * Added Mr Game and Watch WIP and lifting dough dudes * Finished GANDW, fixed some bugs and still fixing bugs, almost done! * DONE * Begun development on tambourine * Working Dough Polish * Added many animations for tambourine * Added Events * Inputs added, near completion * Miss Anims * Animation changes * DONE * fix * FIXED??? * FIXED FOR REAL * Begun fixing lockstep, just needs small fixes and features * Smol fix-ish * Started work on mr upbeat * MrUpbeat fixed, finishing up lockstep * Added BG to lockstep * Added bg colour change * Done with my part
This commit is contained in:
@ -17,65 +17,46 @@ namespace HeavenStudio.Games.Loaders
|
||||
return new Minigame("lockstep", "Lockstep \n<color=#eb5454>[WIP]</color>", "0058CE", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", "Bop")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Bop(e.beat, e["toggle"]); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Bop(e.beat, e["toggle"]); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Reset Pose", "Resets to idle pose.")
|
||||
},
|
||||
defaultLength = 1f,
|
||||
},
|
||||
|
||||
|
||||
|
||||
defaultLength = 1f,
|
||||
},
|
||||
new GameAction("hai", "Hai!")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); },
|
||||
defaultLength = 1f,
|
||||
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);}
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat); },
|
||||
defaultLength = 1f,
|
||||
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Hai(e.beat);}
|
||||
},
|
||||
new GameAction("offbeatSwitch", "Switch to Offbeat")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatSwitch(e.beat); },
|
||||
defaultLength = 8f
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OffbeatSwitch(e.beat); },
|
||||
defaultLength = 8f
|
||||
},
|
||||
new GameAction("onbeatSwitch", "Switch to Onbeat")
|
||||
{
|
||||
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OnbeatSwitch(e.beat); },
|
||||
defaultLength = 2f
|
||||
},
|
||||
new GameAction("marching", "Stepping")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e.length);},
|
||||
defaultLength = 4f,
|
||||
resizable = true
|
||||
},
|
||||
new GameAction("set colours", "Set Background Colours")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Lockstep.instance.SetbackgroundColours(e["colorA"], e["colorB"]); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OffbeatSwitch(e.beat); },
|
||||
defaultLength = 2f
|
||||
|
||||
|
||||
new Param("colorA", Lockstep.defaultBGColorOn, "Onbeat", "Select the color that appears for the onbeat."),
|
||||
new Param("colorB", Lockstep.defaultBGColorOff, "Offbeat", "Select the color that appears for the offbeat."),
|
||||
},
|
||||
|
||||
new GameAction("marching", "Onbeat Stepping")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatStep(e.beat, e.length); },
|
||||
defaultLength = 4f,
|
||||
resizable = true,
|
||||
hidden = true
|
||||
},
|
||||
|
||||
new GameAction("startStepping", "Start Stepping")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.BeginStepping(e.beat); },
|
||||
defaultLength = 1f,
|
||||
hidden = true
|
||||
|
||||
},
|
||||
|
||||
new GameAction("test1", "onbeat march test")
|
||||
{
|
||||
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.OnbeatMarch(e.beat); },
|
||||
defaultLength = 1f,
|
||||
hidden = true
|
||||
}
|
||||
|
||||
defaultLength = 0.5f,
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -87,78 +68,96 @@ namespace HeavenStudio.Games
|
||||
// using Scripts_Lockstep;
|
||||
public class Lockstep : Minigame
|
||||
{
|
||||
private static Color _defaultBGColorOn;
|
||||
public static Color defaultBGColorOn
|
||||
{
|
||||
get
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#f0338d", out _defaultBGColorOn);
|
||||
return _defaultBGColorOn;
|
||||
}
|
||||
}
|
||||
|
||||
private static Color _defaultBGColorOff;
|
||||
public static Color defaultBGColorOff
|
||||
{
|
||||
get
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#BC318B", out _defaultBGColorOff);
|
||||
return _defaultBGColorOff;
|
||||
}
|
||||
}
|
||||
|
||||
// private Animator stepswitcher;
|
||||
|
||||
public Color currentBGOnColor;
|
||||
public Color currentBGOffColor;
|
||||
|
||||
public Animator stepswitcherP;
|
||||
public Animator stepswitcher0;
|
||||
public Animator stepswitcher1;
|
||||
|
||||
public GameObject Player;
|
||||
[Header("Components")]
|
||||
[SerializeField] Animator stepswitcherP;
|
||||
[SerializeField] Animator stepswitcher0;
|
||||
[SerializeField] Animator stepswitcher1;
|
||||
[SerializeField] SpriteRenderer background;
|
||||
|
||||
|
||||
[Header("Properties")]
|
||||
public GameEvent bop = new GameEvent();
|
||||
public bool goStep;
|
||||
static List<float> queuedInputs = new List<float>();
|
||||
HowMissed currentMissStage;
|
||||
public enum HowMissed
|
||||
{
|
||||
NotMissed = 0,
|
||||
MissedOff = 1,
|
||||
MissedOn = 2
|
||||
}
|
||||
bool offColorActive;
|
||||
|
||||
public float steppingLength;
|
||||
public float steppingStartBeat;
|
||||
private float lastReportedBeat = 0f;
|
||||
public static Lockstep instance;
|
||||
|
||||
|
||||
public static Lockstep instance { get; set; }
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
goStep = false;
|
||||
currentBGOnColor = defaultBGColorOn;
|
||||
currentBGOffColor = defaultBGColorOff;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
||||
{
|
||||
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public void Update()
|
||||
{
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
if (goStep)
|
||||
if (cond.isPlaying && !cond.isPaused)
|
||||
{
|
||||
print("stepping is on");
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
if (queuedInputs.Count > 0)
|
||||
{
|
||||
print("one small step for switch");
|
||||
Jukebox.PlayOneShotGame("Lockstep/marchOnBeat1");
|
||||
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
foreach (var input in queuedInputs)
|
||||
{
|
||||
ScheduleInput(cond.songPositionInBeats, input - cond.songPositionInBeats, InputType.STANDARD_DOWN, Just, Miss, Nothing);
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(input, delegate { EvaluateMarch(); }),
|
||||
});
|
||||
}
|
||||
queuedInputs.Clear();
|
||||
}
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
|
||||
{
|
||||
currentMissStage = HowMissed.NotMissed;
|
||||
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
|
||||
var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch");
|
||||
Jukebox.PlayOneShotGame("lockstep/miss");
|
||||
stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow())
|
||||
{
|
||||
//Jukebox.PlayOneShot("miss");
|
||||
|
||||
|
||||
var beatAnimCheck = Math.Round(Conductor.instance.songPositionInBeats * 2);
|
||||
print("check: " + beatAnimCheck);
|
||||
var stepPlayerAnim = (beatAnimCheck % 2 != 0 ? "OffbeatMarch" : "OnbeatMarch");
|
||||
|
||||
Jukebox.PlayOneShotGame("lockstep/miss");
|
||||
stepswitcherP.DoScaledAnimationAsync(stepPlayerAnim, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Bop(float beat, bool reset)
|
||||
{
|
||||
|
||||
if(reset)
|
||||
if (reset)
|
||||
{
|
||||
stepswitcher0.DoScaledAnimationAsync("BopReset", 0.5f);
|
||||
stepswitcher1.DoScaledAnimationAsync("BopReset", 0.5f);
|
||||
@ -172,10 +171,6 @@ namespace HeavenStudio.Games
|
||||
stepswitcherP.DoScaledAnimationAsync("Bop", 0.5f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Hai(float beat)
|
||||
@ -183,23 +178,30 @@ namespace HeavenStudio.Games
|
||||
Jukebox.PlayOneShotGame("lockstep/switch1");
|
||||
}
|
||||
|
||||
public void BeginStepping(float beat)
|
||||
{
|
||||
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { goStep = true; }),
|
||||
});
|
||||
|
||||
print("Start Stepping");
|
||||
print(goStep);
|
||||
}
|
||||
|
||||
|
||||
public void OnbeatSwitch(float beat)
|
||||
public static void OnbeatSwitch(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
{
|
||||
new MultiSound.Sound("lockstep/switch5", beat),
|
||||
new MultiSound.Sound("lockstep/switch6", beat + 0.5f),
|
||||
new MultiSound.Sound("lockstep/switch5", beat + 1f),
|
||||
new MultiSound.Sound("lockstep/switch6", beat + 1.5f)
|
||||
}, forcePlay: true);
|
||||
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(false); }),
|
||||
new BeatAction.Action(beat + 0.5f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(true); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(false); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(true); }),
|
||||
new BeatAction.Action(beat + 2f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(false); }),
|
||||
});
|
||||
}
|
||||
|
||||
public static void OffbeatSwitch(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("lockstep/switch1", beat),
|
||||
new MultiSound.Sound("lockstep/switch1", beat + 1f),
|
||||
new MultiSound.Sound("lockstep/switch1", beat + 2f),
|
||||
@ -210,44 +212,142 @@ namespace HeavenStudio.Games
|
||||
new MultiSound.Sound("lockstep/switch4", beat + 5.5f),
|
||||
new MultiSound.Sound("lockstep/switch4", beat + 6.5f),
|
||||
new MultiSound.Sound("lockstep/switch4", beat + 7.5f),
|
||||
}, forcePlay: false);
|
||||
}, forcePlay: true);
|
||||
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(true); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(false); }),
|
||||
new BeatAction.Action(beat + 2f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(true); }),
|
||||
new BeatAction.Action(beat + 3f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(false); }),
|
||||
new BeatAction.Action(beat + 3.5f, delegate { if (GameManager.instance.currentGame == "lockstep") Lockstep.instance.ChangeBeatBackGroundColour(true); }),
|
||||
});
|
||||
}
|
||||
|
||||
public void OffbeatSwitch(float beat)
|
||||
public static void Marching(float beat, float length)
|
||||
{
|
||||
var sound = new MultiSound.Sound[]
|
||||
if (GameManager.instance.currentGame == "lockstep")
|
||||
{
|
||||
for (int i = 0; i < length + 1; i++)
|
||||
{
|
||||
new MultiSound.Sound("lockstep/switch5", beat),
|
||||
new MultiSound.Sound("lockstep/switch6", beat + 0.5f),
|
||||
new MultiSound.Sound("lockstep/switch5", beat + 1f),
|
||||
new MultiSound.Sound("lockstep/switch6", beat + 1.5f)
|
||||
};
|
||||
|
||||
|
||||
MultiSound.Play(sound);
|
||||
|
||||
|
||||
Lockstep.instance.ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, Lockstep.instance.Just, Lockstep.instance.Miss, Lockstep.instance.Nothing);
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + i, delegate { Lockstep.instance.EvaluateMarch(); }),
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < length + 1; i++)
|
||||
{
|
||||
queuedInputs.Add(beat + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnbeatStep(float beat, float length)
|
||||
public void EvaluateMarch()
|
||||
{
|
||||
/*marching.length = length;
|
||||
marching.startBeat = beat;
|
||||
print("onbeatstep len: " + marching.length);
|
||||
print("onbeatstep start: " + marching.startBeat);*/
|
||||
var cond = Conductor.instance;
|
||||
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
|
||||
if (beatAnimCheck % 2 != 0)
|
||||
{
|
||||
stepswitcher0.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
|
||||
stepswitcher1.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnbeatMarch(float beat)
|
||||
public void Just(PlayerActionEvent caller, float state)
|
||||
{
|
||||
|
||||
stepswitcher0.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
stepswitcher1.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
Jukebox.PlayOneShotGame("lockstep/marchOnbeat1");
|
||||
|
||||
|
||||
|
||||
currentMissStage = HowMissed.NotMissed;
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
|
||||
if (beatAnimCheck % 2 != 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("lockstep/tink");
|
||||
stepswitcherP.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("lockstep/tink");
|
||||
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Success();
|
||||
}
|
||||
|
||||
public void Success()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
|
||||
if (beatAnimCheck % 2 != 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame($"lockstep/marchOffbeat{UnityEngine.Random.Range(1, 3)}");
|
||||
stepswitcherP.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame($"lockstep/marchOnbeat{UnityEngine.Random.Range(1, 3)}");
|
||||
stepswitcherP.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
var beatAnimCheck = Math.Round(cond.songPositionInBeats * 2);
|
||||
|
||||
if (beatAnimCheck % 2 != 0 && currentMissStage != HowMissed.MissedOff)
|
||||
{
|
||||
stepswitcherP.Play("OffbeatMiss", 0, 0);
|
||||
Jukebox.PlayOneShotGame("lockstep/wayOff");
|
||||
currentMissStage = HowMissed.MissedOff;
|
||||
}
|
||||
else if (beatAnimCheck % 2 == 0 && currentMissStage != HowMissed.MissedOn)
|
||||
{
|
||||
stepswitcherP.Play("OnbeatMiss", 0, 0);
|
||||
Jukebox.PlayOneShotGame("lockstep/wayOff");
|
||||
currentMissStage = HowMissed.MissedOn;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeBeatBackGroundColour(bool off)
|
||||
{
|
||||
if (off)
|
||||
{
|
||||
background.color = currentBGOffColor;
|
||||
offColorActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
background.color = currentBGOnColor;
|
||||
offColorActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetbackgroundColours(Color onColor, Color offColor)
|
||||
{
|
||||
currentBGOnColor = onColor;
|
||||
currentBGOffColor = offColor;
|
||||
|
||||
if (offColorActive)
|
||||
{
|
||||
background.color = currentBGOffColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
background.color = currentBGOnColor;
|
||||
}
|
||||
}
|
||||
|
||||
public void Nothing(PlayerActionEvent caller) {}
|
||||
}
|
||||
}
|
||||
|
@ -15,23 +15,22 @@ namespace HeavenStudio.Games.Loaders
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("mrUpbeat", "Mr. Upbeat", "FFFFFF", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("prepare", "Prepare")
|
||||
new GameAction("stepping", "Start Stepping")
|
||||
{
|
||||
function = delegate { MrUpbeat.instance.SetInterval(eventCaller.currentEntity.beat); },
|
||||
defaultLength = 0.5f,
|
||||
resizable = true,
|
||||
inactiveFunction = delegate { MrUpbeat.Beep(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }
|
||||
},
|
||||
new GameAction("go", "Start Stepping")
|
||||
{
|
||||
function = delegate { MrUpbeat.instance.Go(eventCaller.currentEntity.beat); },
|
||||
defaultLength = 4f,
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; MrUpbeat.Stepping(e.beat, e.length); },
|
||||
defaultLength = 4f,
|
||||
resizable = true
|
||||
},
|
||||
new GameAction("ding!", "Finish Stepping")
|
||||
new GameAction("blipping", "Beeping")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; MrUpbeat.instance.Blipping(e.beat, e.length); },
|
||||
defaultLength = 4f,
|
||||
resizable = true
|
||||
},
|
||||
new GameAction("ding!", "Ding!")
|
||||
{
|
||||
function = delegate { MrUpbeat.instance.Ding(eventCaller.currentEntity["toggle"]); },
|
||||
defaultLength = 0.5f,
|
||||
defaultLength = 0.5f,
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Applause")
|
||||
@ -49,148 +48,144 @@ namespace HeavenStudio.Games
|
||||
public class MrUpbeat : Minigame
|
||||
{
|
||||
[Header("References")]
|
||||
public GameObject metronome;
|
||||
public Animator metronomeAnim;
|
||||
public UpbeatMan man;
|
||||
public GameObject bt;
|
||||
private static MultiSound beeps; //only used when this game isn't active.
|
||||
|
||||
public GameEvent beat = new GameEvent();
|
||||
public bool canGo = false;
|
||||
public int beatCount = 0;
|
||||
|
||||
public float beatOffset = 0f;
|
||||
[Header("Properties")]
|
||||
static List<queuedUpbeatInputs> queuedInputs = new List<queuedUpbeatInputs>();
|
||||
public struct queuedUpbeatInputs
|
||||
{
|
||||
public float beat;
|
||||
public bool goRight;
|
||||
}
|
||||
|
||||
public static MrUpbeat instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
canGo = false;
|
||||
man.stepTimes = 0;
|
||||
SetInterval(0);
|
||||
var pos = Conductor.instance.songPositionInBeats;
|
||||
StartCoroutine(Upbeat(pos - Mathf.Round(pos)));
|
||||
}
|
||||
|
||||
List<float> gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go").Select(c => c.beat).ToList();
|
||||
|
||||
if (gos.Count > 0)
|
||||
void OnDestroy()
|
||||
{
|
||||
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
||||
{
|
||||
var nextInterval = gos.IndexOf(Mathp.GetClosestInList(gos, Conductor.instance.songPositionInBeats));
|
||||
beatOffset = gos[nextInterval];
|
||||
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
public void Update()
|
||||
{
|
||||
List<DynamicBeatmap.DynamicEntity> gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go");
|
||||
for (int i = 0; i < gos.Count; i++)
|
||||
var cond = Conductor.instance;
|
||||
if (cond.isPlaying && !cond.isPaused)
|
||||
{
|
||||
if ((gos[i].beat - 0.15f) <= Conductor.instance.songPositionInBeats && (gos[i].beat + gos[i].length) - 0.15f > Conductor.instance.songPositionInBeats)
|
||||
if (queuedInputs.Count > 0)
|
||||
{
|
||||
canGo = true;
|
||||
break;
|
||||
} else
|
||||
{
|
||||
canGo = false;
|
||||
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"); }),
|
||||
});
|
||||
}
|
||||
}
|
||||
queuedInputs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (canGo)
|
||||
{
|
||||
var songPos = Conductor.instance.songPositionInBeats - beatOffset;
|
||||
metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * songPos) * 60);
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat))
|
||||
{
|
||||
StartCoroutine(Upbeat());
|
||||
if (canGo)
|
||||
{
|
||||
if (beatCount % 2 == 0)
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft");
|
||||
|
||||
Beat(Mathf.Round(Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGameSwitch(float beat)
|
||||
{
|
||||
foreach (var entity in GameManager.instance.Beatmap.entities)
|
||||
{
|
||||
if (entity.beat > beat) //the list is sorted based on the beat of the entity, so this should work fine.
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (entity.datamodel != "mrUpbeat/prepare" || entity.beat + entity.length < beat) //check for prepares that happen before the switch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetInterval(entity.beat);
|
||||
break;
|
||||
}
|
||||
if(beeps != null)
|
||||
{
|
||||
beeps.Delete(); //the beeps are only for when the game isn't active
|
||||
beeps = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInterval(float beat)
|
||||
{
|
||||
beatCount = 0;
|
||||
man.targetBeat = beat + 320f;
|
||||
man.Idle();
|
||||
}
|
||||
|
||||
public void Go(float beat)
|
||||
{
|
||||
beatCount = 0;
|
||||
}
|
||||
|
||||
public void Ding(bool applause)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/ding");
|
||||
if (applause)
|
||||
Jukebox.PlayOneShot("applause");
|
||||
if (applause) Jukebox.PlayOneShot("applause");
|
||||
}
|
||||
|
||||
public void Beat(float beat)
|
||||
public void Blipping(float beat, float length)
|
||||
{
|
||||
beatCount++;
|
||||
|
||||
GameObject _beat = Instantiate(bt);
|
||||
_beat.transform.parent = bt.transform.parent;
|
||||
_beat.SetActive(true);
|
||||
UpbeatStep s = _beat.GetComponent<UpbeatStep>();
|
||||
s.startBeat = beat;
|
||||
s.beatOffset = beatOffset;
|
||||
for (int i = 0; i < length + 1; i++)
|
||||
{
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + i, delegate { man.Blip(); }),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator Upbeat(float offset = 0)
|
||||
public static void Stepping(float beat, float length)
|
||||
{
|
||||
yield return new WaitForSeconds(Conductor.instance.secPerBeat * 0.5f - offset);
|
||||
man.Blip();
|
||||
if (GameManager.instance.currentGame == "mrUpbeat")
|
||||
{
|
||||
float offSet = 0;
|
||||
if (!MrUpbeat.instance.isPlaying(MrUpbeat.instance.metronomeAnim, "MetronomeIdle") && !MrUpbeat.instance.isPlaying(MrUpbeat.instance.metronomeAnim, "MetronomeGoRight"))
|
||||
{
|
||||
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"); }),
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < length + 1; i++)
|
||||
{
|
||||
queuedInputs.Add(new queuedUpbeatInputs
|
||||
{
|
||||
beat = beat + i,
|
||||
goRight = i % 2 == 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Beep(float beat, float length)
|
||||
public void Success(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if(GameManager.instance.currentGame == "mrUpbeat") //this function is only meant for making beeps while the game is inactive
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (beeps != null)
|
||||
{
|
||||
beeps.Delete();
|
||||
}
|
||||
MultiSound.Sound[] beepSounds = new MultiSound.Sound[Mathf.CeilToInt(length)];
|
||||
for(int i = 0; i < beepSounds.Length; i++)
|
||||
{
|
||||
beepSounds[i] = new MultiSound.Sound("mrUpbeat/blip", beat + 0.5f + i);
|
||||
}
|
||||
beeps = MultiSound.Play(beepSounds, forcePlay:true);
|
||||
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) {}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_MrUpbeat
|
||||
{
|
||||
public class UpbeatStep : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private bool passedFirst = false;
|
||||
public float beatOffset = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerActionInit(gameObject, startBeat);
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Hit(true, true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 0.35f) >= 1 && !passedFirst)
|
||||
{
|
||||
if(MrUpbeat.instance.man.stepTimes % 2 != Math.Round(startBeat - beatOffset) % 2)
|
||||
Hit(false);
|
||||
passedFirst = true;
|
||||
}
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 0.65f) >= 1)
|
||||
Hit(false);
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 0.5f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Hit(true);
|
||||
} else if (state.notPerfect())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit(bool hit, bool force = false)
|
||||
{
|
||||
if (force) MrUpbeat.instance.man.Step();
|
||||
else if (!hit) MrUpbeat.instance.man.Fall();
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 671722aab5d7ff34da139a076534caf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user