mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 16:57:39 +02:00
Quiz Show and Tambourine Reworks (#505)
* Tambourine fully reworked * quiz show rework part 1 * quiz show rework part 2 * oopsie doopsie * el fix numbah two
This commit is contained in:
@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Jukebox;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
@ -15,29 +16,30 @@ namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
new GameAction("beat intervals", "Start Interval")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.StartInterval(e.beat, e.length); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; Tambourine.PreInterval(e.beat, e.length, e["auto"]); },
|
||||
defaultLength = 8f,
|
||||
resizable = true,
|
||||
priority = 1
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("auto", true, "Auto Pass Turn")
|
||||
}
|
||||
},
|
||||
new GameAction("shake", "Shake")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.MonkeyInput(e.beat, false); },
|
||||
defaultLength = 0.5f,
|
||||
priority = 2
|
||||
},
|
||||
new GameAction("hit", "Hit")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.MonkeyInput(e.beat, true); },
|
||||
defaultLength = 0.5f,
|
||||
priority = 2
|
||||
},
|
||||
new GameAction("pass turn", "Pass Turn")
|
||||
{
|
||||
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.PassTurn(e.beat, e.length); },
|
||||
preFunction = delegate
|
||||
{
|
||||
Tambourine.PrePassTurn(eventCaller.currentEntity.beat);
|
||||
},
|
||||
defaultLength = 1f,
|
||||
resizable = true,
|
||||
priority = 3
|
||||
preFunctionLength = 1f
|
||||
},
|
||||
new GameAction("bop", "Bop")
|
||||
{
|
||||
@ -113,9 +115,6 @@ namespace HeavenStudio.Games
|
||||
[SerializeField] Animator frogAnimator;
|
||||
|
||||
[Header("Variables")]
|
||||
bool intervalStarted;
|
||||
double intervalStartBeat;
|
||||
float beatInterval = 8f;
|
||||
float misses;
|
||||
bool frogPresent;
|
||||
bool monkeyGoBop;
|
||||
@ -132,13 +131,6 @@ namespace HeavenStudio.Games
|
||||
None
|
||||
}
|
||||
|
||||
static List<QueuedTambourineInput> queuedInputs = new List<QueuedTambourineInput>();
|
||||
struct QueuedTambourineInput
|
||||
{
|
||||
public bool hit;
|
||||
public double beatAwayFromStart;
|
||||
}
|
||||
|
||||
public static Tambourine instance;
|
||||
|
||||
void Awake()
|
||||
@ -150,18 +142,6 @@ namespace HeavenStudio.Games
|
||||
monkeyAnimator.Play("MonkeyIdle", 0, 0);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
||||
{
|
||||
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
||||
}
|
||||
foreach (var evt in scheduledInputs)
|
||||
{
|
||||
evt.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
@ -175,14 +155,6 @@ namespace HeavenStudio.Games
|
||||
handsAnimator.Play("Bop", 0, 0);
|
||||
}
|
||||
}
|
||||
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
||||
{
|
||||
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
||||
}
|
||||
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
|
||||
{
|
||||
intervalStarted = false;
|
||||
}
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN))
|
||||
{
|
||||
handsAnimator.Play("Shake", 0, 0);
|
||||
@ -190,7 +162,7 @@ namespace HeavenStudio.Games
|
||||
sweatAnimator.Play("Sweating", 0, 0);
|
||||
SummonFrog();
|
||||
ScoreMiss();
|
||||
if (!intervalStarted)
|
||||
if (!IntervalIsGoingOn())
|
||||
{
|
||||
sadFace.SetActive(true);
|
||||
}
|
||||
@ -202,77 +174,171 @@ namespace HeavenStudio.Games
|
||||
sweatAnimator.Play("Sweating", 0, 0);
|
||||
SummonFrog();
|
||||
ScoreMiss();
|
||||
if (!intervalStarted)
|
||||
if (!IntervalIsGoingOn())
|
||||
{
|
||||
sadFace.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (passedTurns.Count > 0)
|
||||
{
|
||||
foreach (var pass in passedTurns)
|
||||
{
|
||||
PassTurnStandalone(pass);
|
||||
}
|
||||
passedTurns.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartInterval(double beat, float interval)
|
||||
private bool IntervalIsGoingOn()
|
||||
{
|
||||
intervalStartBeat = beat;
|
||||
beatInterval = interval;
|
||||
if (!intervalStarted)
|
||||
double beat = Conductor.instance.songPositionInBeats;
|
||||
return EventCaller.GetAllInGameManagerList("tambourine", new string[] { "beat intervals" }).Find(x => beat >= x.beat && beat < x.beat + x.length) != null;
|
||||
}
|
||||
|
||||
private List<RiqEntity> GetAllInputsBetweenBeat(double beat, double endBeat)
|
||||
{
|
||||
return EventCaller.GetAllInGameManagerList("tambourine", new string[] { "shake", "hit" }).FindAll(x => x.beat >= beat && x.beat < endBeat);
|
||||
}
|
||||
|
||||
public static void PreInterval(double beat, float interval, bool autoPassTurn)
|
||||
{
|
||||
if (GameManager.instance.currentGame == "tambourine")
|
||||
{
|
||||
DesummonFrog();
|
||||
sadFace.SetActive(false);
|
||||
//queuedInputs.Clear();
|
||||
misses = 0;
|
||||
intervalStarted = true;
|
||||
instance.StartInterval(beat, interval, beat, autoPassTurn);
|
||||
}
|
||||
else
|
||||
{
|
||||
queuedIntervals.Add(new QueuedInterval()
|
||||
{
|
||||
beat = beat,
|
||||
interval = interval,
|
||||
autoPassTurn = autoPassTurn
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGameSwitch(double beat)
|
||||
{
|
||||
if (queuedIntervals.Count > 0)
|
||||
{
|
||||
foreach (var interval in queuedIntervals)
|
||||
{
|
||||
StartInterval(interval.beat, interval.interval, beat, interval.autoPassTurn);
|
||||
}
|
||||
queuedIntervals.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private struct QueuedInterval
|
||||
{
|
||||
public double beat;
|
||||
public float interval;
|
||||
public bool autoPassTurn;
|
||||
}
|
||||
|
||||
private static List<QueuedInterval> queuedIntervals = new();
|
||||
|
||||
private void StartInterval(double beat, float interval, double gameSwitchBeat, bool autoPassTurn)
|
||||
{
|
||||
List<BeatAction.Action> actions = new()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate
|
||||
{
|
||||
DesummonFrog();
|
||||
sadFace.SetActive(false);
|
||||
})
|
||||
};
|
||||
|
||||
var relevantInputs = GetAllInputsBetweenBeat(beat, beat + interval);
|
||||
relevantInputs.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
|
||||
for (int i = 0; i < relevantInputs.Count; i++)
|
||||
{
|
||||
bool isHit = relevantInputs[i].datamodel == "tambourine/hit";
|
||||
double inputBeat = relevantInputs[i].beat;
|
||||
if (inputBeat >= gameSwitchBeat)
|
||||
{
|
||||
actions.Add(new BeatAction.Action(inputBeat, delegate
|
||||
{
|
||||
MonkeyInput(inputBeat, isHit);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
BeatAction.New(gameObject, actions);
|
||||
|
||||
if (autoPassTurn)
|
||||
{
|
||||
PassTurn(beat + interval, beat, interval);
|
||||
}
|
||||
}
|
||||
|
||||
public void MonkeyInput(double beat, bool hit)
|
||||
{
|
||||
if (!intervalStarted)
|
||||
{
|
||||
StartInterval(beat, beatInterval);
|
||||
}
|
||||
if (hit)
|
||||
{
|
||||
monkeyAnimator.Play("MonkeySmack", 0, 0);
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeySmack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
monkeyAnimator.Play("MonkeyShake", 0, 0);
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeyShake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
queuedInputs.Add(new QueuedTambourineInput()
|
||||
{
|
||||
hit = hit,
|
||||
beatAwayFromStart = beat - intervalStartBeat,
|
||||
});
|
||||
}
|
||||
|
||||
public void PassTurn(double beat, float length)
|
||||
private RiqEntity GetLastIntervalBeforeBeat(double beat)
|
||||
{
|
||||
if (queuedInputs.Count == 0) return;
|
||||
monkeyAnimator.Play("MonkeyPassTurn", 0, 0);
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/turnPass/{UnityEngine.Random.Range(1, 6)}");
|
||||
happyFace.SetActive(true);
|
||||
intervalStarted = false;
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
return EventCaller.GetAllInGameManagerList("tambourine", new string[] { "beat intervals" }).FindLast(x => x.beat <= beat);
|
||||
}
|
||||
|
||||
public static void PrePassTurn(double beat)
|
||||
{
|
||||
if (GameManager.instance.currentGame == "tambourine")
|
||||
{
|
||||
new BeatAction.Action(beat + 0.3f, delegate { happyFace.SetActive(false); })
|
||||
});
|
||||
foreach (var input in queuedInputs)
|
||||
{
|
||||
if (input.hit)
|
||||
{
|
||||
ScheduleInput(beat, length + input.beatAwayFromStart, InputType.STANDARD_ALT_DOWN , JustHit, Miss , Nothing);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScheduleInput(beat, length + input.beatAwayFromStart, InputType.STANDARD_DOWN, JustShake, Miss, Nothing);
|
||||
}
|
||||
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + length + input.beatAwayFromStart, delegate { Bop(beat + length + input.beatAwayFromStart, 1, (int)WhoBops.Monkey, (int)WhoBops.None); })
|
||||
});
|
||||
instance.PassTurnStandalone(beat);
|
||||
}
|
||||
queuedInputs.Clear();
|
||||
else
|
||||
{
|
||||
passedTurns.Add(beat);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<double> passedTurns = new();
|
||||
|
||||
private void PassTurnStandalone(double beat)
|
||||
{
|
||||
var lastInterval = GetLastIntervalBeforeBeat(beat);
|
||||
if (lastInterval != null) PassTurn(beat, lastInterval.beat, lastInterval.length);
|
||||
}
|
||||
|
||||
private void PassTurn(double beat, double intervalBeat, float intervalLength)
|
||||
{
|
||||
SoundByte.PlayOneShotGame($"tambourine/monkey/turnPass/{UnityEngine.Random.Range(1, 6)}", beat);
|
||||
List<BeatAction.Action> actions = new()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate
|
||||
{
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeyPassTurn", 0.5f);
|
||||
happyFace.SetActive(true);
|
||||
}),
|
||||
new BeatAction.Action(beat + 0.3f, delegate { happyFace.SetActive(false); })
|
||||
};
|
||||
var relevantInputs = GetAllInputsBetweenBeat(intervalBeat, intervalBeat + intervalLength);
|
||||
relevantInputs.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||
for (int i = 0; i < relevantInputs.Count; i++)
|
||||
{
|
||||
bool isHit = relevantInputs[i].datamodel == "tambourine/hit";
|
||||
double inputBeat = relevantInputs[i].beat - intervalBeat;
|
||||
actions.Add(new BeatAction.Action(inputBeat, delegate
|
||||
{
|
||||
if (isHit) ScheduleInput(beat + 1, inputBeat, InputType.STANDARD_ALT_DOWN, JustHit, Miss, Nothing);
|
||||
else ScheduleInput(beat + 1, inputBeat, InputType.STANDARD_DOWN, JustShake, Miss, Nothing);
|
||||
Bop(beat + 1 + inputBeat, 1, (int)WhoBops.Monkey, (int)WhoBops.None);
|
||||
}));
|
||||
}
|
||||
BeatAction.New(gameObject, actions);
|
||||
}
|
||||
|
||||
public void Bop(double beat, float length, int whoBops, int whoBopsAuto)
|
||||
@ -288,14 +354,14 @@ namespace HeavenStudio.Games
|
||||
switch (whoBops)
|
||||
{
|
||||
case (int) WhoBops.Monkey:
|
||||
monkeyAnimator.Play("MonkeyBop", 0, 0);
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeyBop", 0.5f);
|
||||
break;
|
||||
case (int) WhoBops.Player:
|
||||
handsAnimator.Play("Bop", 0, 0);
|
||||
handsAnimator.DoScaledAnimationAsync("Bop", 0.5f);
|
||||
break;
|
||||
case (int) WhoBops.Both:
|
||||
monkeyAnimator.Play("MonkeyBop", 0, 0);
|
||||
handsAnimator.Play("Bop", 0, 0);
|
||||
monkeyAnimator.DoScaledAnimationAsync("MonkeyBop", 0.5f);
|
||||
handsAnimator.DoScaledAnimationAsync("Bop", 0.5f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -330,12 +396,12 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
handsAnimator.Play("Smack", 0, 0);
|
||||
handsAnimator.DoScaledAnimationAsync("Smack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame("tambourine/miss");
|
||||
sweatAnimator.Play("Sweating", 0, 0);
|
||||
sweatAnimator.DoScaledAnimationAsync("Sweating", 0.5f);
|
||||
misses++;
|
||||
if (!intervalStarted)
|
||||
if (!IntervalIsGoingOn())
|
||||
{
|
||||
sadFace.SetActive(true);
|
||||
}
|
||||
@ -348,12 +414,12 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
if (state >= 1f || state <= -1f)
|
||||
{
|
||||
handsAnimator.Play("Shake", 0, 0);
|
||||
handsAnimator.DoScaledAnimationAsync("Shake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
SoundByte.PlayOneShotGame("tambourine/miss");
|
||||
sweatAnimator.Play("Sweating", 0, 0);
|
||||
sweatAnimator.DoScaledAnimationAsync("Sweating", 0.5f);
|
||||
misses++;
|
||||
if (!intervalStarted)
|
||||
if (!IntervalIsGoingOn())
|
||||
{
|
||||
sadFace.SetActive(true);
|
||||
}
|
||||
@ -367,12 +433,12 @@ namespace HeavenStudio.Games
|
||||
sadFace.SetActive(false);
|
||||
if (hit)
|
||||
{
|
||||
handsAnimator.Play("Smack", 0, 0);
|
||||
handsAnimator.DoScaledAnimationAsync("Smack", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/hit/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
handsAnimator.Play("Shake", 0, 0);
|
||||
handsAnimator.DoScaledAnimationAsync("Shake", 0.5f);
|
||||
SoundByte.PlayOneShotGame($"tambourine/player/shake/{UnityEngine.Random.Range(1, 6)}");
|
||||
}
|
||||
}
|
||||
@ -380,9 +446,9 @@ namespace HeavenStudio.Games
|
||||
public void Miss(PlayerActionEvent caller)
|
||||
{
|
||||
SummonFrog();
|
||||
sweatAnimator.Play("Sweating", 0, 0);
|
||||
sweatAnimator.DoScaledAnimationAsync("Sweating", 0.5f);
|
||||
misses++;
|
||||
if (!intervalStarted)
|
||||
if (!IntervalIsGoingOn())
|
||||
{
|
||||
sadFace.SetActive(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user