Games fixes/reworks patch (#501)

* ghosts are scaled now

* Lockstep fully reworked

* mr. bach has been implemented

* Space dance fixes

* oops

* Tap trial rework part 1

* tap trial rework part 2

* oopsie

* Gramps Talk Update

* Space Dance Voice Offsets

* Giraffe done! (Except miss anim)

* bg is not showing up for some reason

* bg not rendering fixed + giraffe fixed

* scrolling done

* fixed space dance and space soccer bg scrolls

* fixed rockers bugs

* adjustment

* fixed el inaccuracies

* particle fix

* changed pitch and volume of monkey tap

* miss anim

* megamix face for girl

* Proper miss anim implementation

* Added force stepping event

* miss anim fix

---------

Co-authored-by: saladplainzone <chocolate2890mail@gmail.com>
Co-authored-by: ev <85412919+evdial@users.noreply.github.com>
This commit is contained in:
Rapandrasmus
2023-07-13 02:35:47 +02:00
committed by GitHub
parent 8a968b0a38
commit dfe144cf4b
94 changed files with 11089 additions and 2864 deletions

View File

@ -21,7 +21,7 @@ namespace HeavenStudio.Common
{
foreach (var img in _imgs)
{
img.uvRect = new Rect(new Vector2(NormalizedX, NormalizedY) * Tile, img.uvRect.size);
img.uvRect = new Rect(Normalized * Tile, img.uvRect.size);
}
}
}

View File

@ -4,8 +4,10 @@ borrowed from other games */
//Don't worry Raffy everyone starts somewhere - Rasmus
using HeavenStudio.Util;
using Jukebox;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace HeavenStudio.Games.Loaders
@ -15,7 +17,7 @@ namespace HeavenStudio.Games.Loaders
{
public static Minigame AddGame(EventCaller eventCaller)
{
return new Minigame("lockstep", "Lockstep \n<color=#eb5454>[WIP]</color>", "f0338d", false, false, new List<GameAction>()
return new Minigame("lockstep", "Lockstep", "f0338d", false, false, new List<GameAction>()
{
new GameAction("bop", "Bop")
{
@ -27,33 +29,38 @@ namespace HeavenStudio.Games.Loaders
new Param("toggle2", false, "Bop (Auto)", "Should the stepswitchers auto bop?"),
},
},
new GameAction("marching", "Stepping")
new GameAction("stepping", "Stepping")
{
preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e.length);},
defaultLength = 4f,
resizable = true
preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e["sound"], e["amount"], e["visual"]);},
parameters = new List<Param>()
{
new Param("sound", false, "Sound", "Hai if onbeat, ho if offbeat."),
new Param("amount", new EntityTypes.Integer(1, 50, 1), "Sound Amount", "How many sounds will play consecutively?"),
new Param("visual", true, "Background Visual")
},
preFunctionLength = 1
},
new GameAction("offbeatSwitch", "Switch to Offbeat")
{
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OffbeatSwitch(e.beat); },
defaultLength = 3.5f
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OffbeatSwitchSound(e.beat, e["ho"], e["sound"]); },
defaultLength = 4.5f,
parameters = new List<Param>()
{
new Param("sound", true, "Sound Cue"),
new Param("ho", true, "Ho Sounds", "Will the <ho, ho, ho, ho> sound be present?"),
new Param("visual", true, "Background Visual")
}
},
new GameAction("onbeatSwitch", "Switch to Onbeat")
{
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OnbeatSwitch(e.beat); },
defaultLength = 2f
},
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);}
},
new GameAction("ho", "Ho!")
{
function = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Ho(e.beat); },
defaultLength = 1f,
inactiveFunction = delegate { var e = eventCaller.currentEntity; Lockstep.instance.Ho(e.beat);}
preFunction = delegate { var e = eventCaller.currentEntity; Lockstep.OnbeatSwitchSound(e.beat, e["hai"], e["sound"]); },
defaultLength = 3f,
parameters = new List<Param>()
{
new Param("sound", true, "Sound Cue"),
new Param("hai", new EntityTypes.Integer(0, 100, 1), "Hai Amount"),
new Param("visual", true, "Background Visual")
}
},
new GameAction("set colours", "Set Colours")
{
@ -67,6 +74,32 @@ namespace HeavenStudio.Games.Loaders
new Param("objColC", Lockstep.stepperLight, "Stepper Light", "Select the color that appears for the light side of the stepwitchers."),
},
defaultLength = 0.5f,
},
new GameAction("zoom", "Preset Zooms")
{
function = delegate { Lockstep.instance.SetZoom(eventCaller.currentEntity["zoom"]); },
parameters = new List<Param>()
{
new Param("zoom", Lockstep.ZoomPresets.Regular, "Zoom Level")
}
},
new GameAction("bach", "Show Bach")
{
defaultLength = 4,
resizable = true,
},
new GameAction("marching", "Force Stepping")
{
preFunction = delegate {var e = eventCaller.currentEntity; Lockstep.Marching(e.beat, e["sound"], e["amount"], e["visual"], true, e.length);},
parameters = new List<Param>()
{
new Param("sound", false, "Sound", "Hai if onbeat, ho if offbeat."),
new Param("amount", new EntityTypes.Integer(1, 50, 1), "Sound Amount", "How many sounds will play consecutively?"),
new Param("visual", true, "Background Visual")
},
preFunctionLength = 1,
resizable = true,
defaultLength = 4
}
},
new List<string>() {"ntr", "keep"},
@ -140,7 +173,8 @@ namespace HeavenStudio.Games
[SerializeField] Animator stepswitcherPlayer;
[SerializeField] Animator stepswitcherLeft;
[SerializeField] Animator stepswitcherRight;
[SerializeField] Animator bach;
// master stepper dictates what sprite the slave steppers use
[SerializeField] Animator masterStepperAnim;
[SerializeField] SpriteRenderer masterStepperSprite;
@ -155,7 +189,7 @@ namespace HeavenStudio.Games
[SerializeField] Material stepperMaterial;
[Header("Properties")]
static List<double> queuedInputs = new();
static List<QueuedMarch> queuedInputs = new();
Sprite masterSprite;
HowMissed currentMissStage;
bool lessSteppers = false;
@ -168,14 +202,71 @@ namespace HeavenStudio.Games
bool offColorActive;
bool goBop;
public GameEvent bop = new GameEvent();
List<double> switches = new();
private List<RiqEntity> bachEvents = new();
public static Lockstep instance;
public enum ZoomPresets
{
Regular,
NotThatFar,
Far,
VeryFar,
ExtremelyFar
}
void Awake()
{
instance = this;
currentBGOnColor = defaultBGColorOn;
currentBGOffColor = defaultBGColorOff;
var switchEvents = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "onbeatSwitch", "offbeatSwitch" });
foreach (var switchEvent in switchEvents)
{
switches.Add(switchEvent.beat + switchEvent.length - 1);
}
bachEvents = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "bach" });
}
private bool BachOnBeat(double beat)
{
return bachEvents.Find(x => beat >= x.beat && beat < x.beat + x.length) != null;
}
public override void OnGameSwitch(double beat)
{
QueueSwitchBGs(beat);
}
public override void OnPlay(double beat)
{
QueueSwitchBGs(beat);
}
private void QueueSwitchBGs(double beat)
{
double nextGameSwitchBeat = double.MaxValue;
List<RiqEntity> allEnds = EventCaller.GetAllInGameManagerList("gameManager", new string[] { "switchGame", "end" }).FindAll(x => x.beat > beat);
if (allEnds.Count > 0)
{
nextGameSwitchBeat = allEnds[0].beat;
}
var switchEventsOn = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "onbeatSwitch" });
foreach (var on in switchEventsOn)
{
if (on.beat >= nextGameSwitchBeat || !on["visual"]) return;
OnbeatSwitch(on.beat, beat);
}
var switchEventsOff = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "offbeatSwitch" });
foreach (var off in switchEventsOff)
{
if (off.beat >= nextGameSwitchBeat || !off["visual"]) return;
OffbeatSwitch(off.beat, beat);
}
}
void Start() {
@ -191,15 +282,6 @@ namespace HeavenStudio.Games
UpdateAndRenderSlaves();
}
void OnDestroy()
{
if (queuedInputs.Count > 0) queuedInputs.Clear();
foreach (var evt in scheduledInputs)
{
evt.Disable();
}
}
void UpdateAndRenderSlaves()
{
foreach (var stepper in slaveSteppers)
@ -222,7 +304,7 @@ namespace HeavenStudio.Games
}
}
public void Update()
private void Update()
{
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
@ -238,11 +320,14 @@ namespace HeavenStudio.Games
{
foreach (var input in queuedInputs)
{
ScheduleInput(cond.songPositionInBeatsAsDouble, input - cond.songPositionInBeats, InputType.STANDARD_DOWN, Just, Miss, Nothing);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
if (input.force)
{
new BeatAction.Action(input, delegate { EvaluateMarch(); }),
});
ForceMarching(input.beat, input.length, input.sound, input.amount, input.visual);
}
else
{
StartMarching(input.beat, input.sound, input.amount, input.visual);
}
}
queuedInputs.Clear();
}
@ -258,10 +343,14 @@ namespace HeavenStudio.Games
{
stepswitcherPlayer.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
}
SoundByte.PlayOneShotGame("lockstep/miss");
SoundByte.PlayOneShot("miss");
ScoreMiss();
}
}
}
private void LateUpdate()
{
if (masterSprite != masterStepperSprite.sprite)
{
masterSprite = masterStepperSprite.sprite;
@ -269,6 +358,19 @@ namespace HeavenStudio.Games
}
}
public void SetZoom(int zoom)
{
GameCamera.additionalPosition = new Vector3(0, 0, (ZoomPresets)zoom switch
{
ZoomPresets.Regular => 0,
ZoomPresets.NotThatFar => -4.5f,
ZoomPresets.Far => -11,
ZoomPresets.VeryFar => -26,
ZoomPresets.ExtremelyFar => -63,
_ => throw new System.NotImplementedException()
});
}
public void Bop(double beat, float length, bool shouldBop, bool autoBop)
{
goBop = autoBop;
@ -287,83 +389,255 @@ namespace HeavenStudio.Games
}
}
public void Hai(double beat)
public static void OnbeatSwitchSound(double beat, int hais, bool sound)
{
SoundByte.PlayOneShotGame("lockstep/switch1", beat);
if (sound)
{
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("lockstep/nha1", beat, 1, 1, false, 0.03086419753),
new MultiSound.Sound("lockstep/nha2", beat + 0.5f, 1, 1, false, 0.04629629629),
new MultiSound.Sound("lockstep/nha1", beat + 1f, 1, 1, false, 0.03086419753),
new MultiSound.Sound("lockstep/nha2", beat + 1.5f, 1, 1, false, 0.04629629629)
}, forcePlay: true);
}
if (hais > 0)
{
List<MultiSound.Sound> haisList = new();
for (int i = 0; i < hais; i++)
{
haisList.Add(new MultiSound.Sound("lockstep/hai", beat + 2 + i, 1, 1, false, 0.02314814814));
}
double nextOffBeat = double.MaxValue;
var switchEventsOn = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "offbeatSwitch" });
switchEventsOn.Sort((x, y) => x.beat.CompareTo(y.beat));
for (int i = 0; i < switchEventsOn.Count; i++)
{
if (switchEventsOn[i].beat > beat)
{
nextOffBeat = switchEventsOn[i].beat;
break;
}
}
var haisActual = haisList.FindAll(x => x.beat < nextOffBeat);
MultiSound.Play(haisActual.ToArray(), true, true);
}
}
public void Ho(double beat)
private void OnbeatSwitch(double beat, double gameswitchBeat)
{
SoundByte.PlayOneShotGame("lockstep/switch4", beat);
List<BeatAction.Action> allActions = new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { ChangeBeatBackGroundColour(false); }),
new BeatAction.Action(beat + 0.5f, delegate { ChangeBeatBackGroundColour(true); }),
new BeatAction.Action(beat + 1f, delegate
{
ChangeBeatBackGroundColour(false);
}),
new BeatAction.Action(beat + 1.5f, delegate
{
ChangeBeatBackGroundColour(true);
}),
new BeatAction.Action(beat + 1.75f, delegate { if (!marchRecursing) MarchRecursive(beat + 2f); }),
new BeatAction.Action(beat + 2f, delegate { ChangeBeatBackGroundColour(false); }),
};
List<BeatAction.Action> actions = new();
foreach (var action in allActions)
{
if (action.beat >= gameswitchBeat) actions.Add(action);
}
if (actions.Count > 0) BeatAction.New(instance.gameObject, actions);
}
public static void OnbeatSwitch(double beat)
public static void OffbeatSwitchSound(double beat, bool hoSound, bool sound)
{
MultiSound.Play(new MultiSound.Sound[]
if (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);
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("lockstep/hai", beat, 1, 1, false, 0.02314814814),
new MultiSound.Sound("lockstep/hai", beat + 1f, 1, 1, false, 0.02314814814),
new MultiSound.Sound("lockstep/hai", beat + 2f, 1, 1, false, 0.02314814814),
new MultiSound.Sound("lockstep/hahai1", beat + 3f, 1, 1, false, 0.03086419753),
new MultiSound.Sound("lockstep/hahai2", beat + 3.5f, 1, 1, false, 0.03086419753),
}, forcePlay: true);
}
if (hoSound)
{
List<MultiSound.Sound> hos = new List<MultiSound.Sound>
{
new MultiSound.Sound("lockstep/ho", beat + 4.5f, 1, 1, false, 0.03086419753),
new MultiSound.Sound("lockstep/ho", beat + 5.5f, 1, 0.6835514f, false, 0.03086419753),
new MultiSound.Sound("lockstep/ho", beat + 6.5f, 1, 0.3395127f, false, 0.03086419753),
new MultiSound.Sound("lockstep/ho", beat + 7.5f, 1, 0.1200322f, false, 0.03086419753),
};
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); }),
});
double nextOnBeat = double.MaxValue;
var switchEventsOn = EventCaller.GetAllInGameManagerList("lockstep", new string[] { "onbeatSwitch" });
switchEventsOn.Sort((x, y) => x.beat.CompareTo(y.beat));
for (int i = 0; i < switchEventsOn.Count; i++)
{
if (switchEventsOn[i].beat > beat)
{
nextOnBeat = switchEventsOn[i].beat;
break;
}
}
var hosActual = hos.FindAll(x => x.beat < nextOnBeat);
MultiSound.Play(hosActual.ToArray(), true, true);
}
}
public static void OffbeatSwitch(double beat)
private void OffbeatSwitch(double beat, double gameswitchBeat)
{
MultiSound.Play(new MultiSound.Sound[]
List<BeatAction.Action> allActions = new List<BeatAction.Action>()
{
new MultiSound.Sound("lockstep/switch1", beat),
new MultiSound.Sound("lockstep/switch1", beat + 1f),
new MultiSound.Sound("lockstep/switch1", beat + 2f),
new MultiSound.Sound("lockstep/switch2", beat + 3f),
new MultiSound.Sound("lockstep/switch3", beat + 3.5f),
}, forcePlay: true);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
new BeatAction.Action(beat, delegate { ChangeBeatBackGroundColour(true); }),
new BeatAction.Action(beat + 1f, delegate { ChangeBeatBackGroundColour(false); }),
new BeatAction.Action(beat + 2f, delegate { ChangeBeatBackGroundColour(true); }),
new BeatAction.Action(beat + 3f, delegate
{
ChangeBeatBackGroundColour(false);
}),
new BeatAction.Action(beat + 3.25f, delegate { if (!marchRecursing) MarchRecursive(beat + 3.5f); }),
new BeatAction.Action(beat + 3.5f, delegate { ChangeBeatBackGroundColour(true); }),
};
List<BeatAction.Action> actions = new();
foreach (var action in allActions)
{
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); }),
});
if (action.beat >= gameswitchBeat) actions.Add(action);
}
if (actions.Count > 0) BeatAction.New(instance.gameObject, actions);
}
public static void Marching(double beat, float length)
private struct QueuedMarch
{
public double beat;
public float length;
public bool sound;
public int amount;
public bool visual;
public bool force;
}
public static void Marching(double beat, bool sound, int amount, bool visual, bool force = false, float length = 0)
{
if (GameManager.instance.currentGame == "lockstep")
{
List<BeatAction.Action> actions = new List<BeatAction.Action>();
for (int i = 0; i < length; i++)
if (force)
{
Lockstep.instance.ScheduleInput(beat - 1, 1 + i, InputType.STANDARD_DOWN, Lockstep.instance.Just, Lockstep.instance.Miss, Lockstep.instance.Nothing);
actions.Add(new BeatAction.Action(beat + i, delegate { Lockstep.instance.EvaluateMarch(); }));
instance.ForceMarching(beat, length, sound, amount, visual);
}
else
{
instance.StartMarching(beat, sound, amount, visual);
}
BeatAction.New(instance.gameObject, actions);
}
else
{
for (int i = 0; i < length; i++)
queuedInputs.Add(new QueuedMarch
{
queuedInputs.Add(beat + i);
}
amount = amount,
beat = beat,
sound = sound,
visual = visual,
length = length,
force = force
});
}
}
public void EvaluateMarch()
private void ForceMarching(double beat, float length, bool sound, int amount, bool visual)
{
var cond = Conductor.instance;
var beatAnimCheck = Math.Round(cond.songPositionInBeatsAsDouble * 2);
if (beatAnimCheck % 2 != 0)
bool offBeat = beat % 1 != 0;
if (sound)
{
MultiSound.Sound[] sounds = new MultiSound.Sound[amount];
for (int i = 0; i < amount; i++)
{
sounds[i] = new MultiSound.Sound($"lockstep/" + (offBeat ? "ho" : "hai"), beat + i, 1, 1, false, offBeat ? 0.03086419753 : 0.02314814814);
}
MultiSound.Play(sounds, true, true);
}
List<BeatAction.Action> steps = new()
{
new BeatAction.Action(beat, delegate
{
if (visual) ChangeBeatBackGroundColour(offBeat);
if (BachOnBeat(beat)) bach.DoScaledAnimationAsync(offBeat ? "BachOff" : "BachOn", 0.5f);
EvaluateMarch(offBeat);
})
};
ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, offBeat ? JustOff : JustOn, offBeat ? MissOff : MissOn, Nothing);
for (int i = 1; i < length; i++)
{
double stepBeat = beat + i;
steps.Add(new BeatAction.Action(stepBeat, delegate
{
if (BachOnBeat(stepBeat)) bach.DoScaledAnimationAsync(offBeat ? "BachOff" : "BachOn", 0.5f);
EvaluateMarch(offBeat);
}));
ScheduleInput(stepBeat - 1, 1, InputType.STANDARD_DOWN, offBeat ? JustOff : JustOn, offBeat ? MissOff : MissOn, Nothing);
}
BeatAction.New(gameObject, steps);
}
private void StartMarching(double beat, bool sound, int amount, bool visual)
{
if (marchRecursing) return;
bool offBeat = beat % 1 != 0;
if (visual)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { ChangeBeatBackGroundColour(offBeat); })
});
}
if (sound)
{
MultiSound.Sound[] sounds = new MultiSound.Sound[amount];
for (int i = 0; i < amount; i++)
{
sounds[i] = new MultiSound.Sound($"lockstep/" + (offBeat ? "ho" : "hai"), beat + i, 1, 1, false, offBeat ? 0.03086419753 : 0.02314814814);
}
MultiSound.Play(sounds, true, true);
}
MarchRecursive(beat);
}
private bool marchRecursing;
private void MarchRecursive(double beat)
{
marchRecursing = true;
if (NextStepIsSwitch(beat)) beat -= 0.5;
bool offBeat = beat % 1 != 0;
bool bachOnBeat = BachOnBeat(beat);
ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, offBeat ? JustOff : JustOn, offBeat ? MissOff : MissOn, Nothing);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
EvaluateMarch(offBeat);
MarchRecursive(beat + 1);
if (bachOnBeat) bach.DoScaledAnimationAsync(offBeat ? "BachOff" : "BachOn", 0.5f);
}),
});
}
private bool NextStepIsSwitch(double beat)
{
return switches.Contains(beat - 0.5);
}
public void EvaluateMarch(bool offBeat)
{
if (offBeat)
{
PlayStepperAnim("OffbeatMarch", false, 0.5f);
}
@ -373,59 +647,46 @@ namespace HeavenStudio.Games
}
}
public void Just(PlayerActionEvent caller, float state)
private void JustOn(PlayerActionEvent caller, float state)
{
currentMissStage = HowMissed.NotMissed;
var cond = Conductor.instance;
stepswitcherPlayer.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
if (state >= 1f || state <= -1f)
{
double beatAnimCheck = cond.songPositionInBeatsAsDouble - 0.25;
if (beatAnimCheck % 1.0 >= 0.5)
{
SoundByte.PlayOneShotGame("lockstep/tink");
stepswitcherPlayer.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
}
else
{
SoundByte.PlayOneShotGame("lockstep/tink");
stepswitcherPlayer.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
}
SoundByte.PlayOneShot("nearMiss");
return;
}
Success(cond.songPositionInBeatsAsDouble);
SoundByte.PlayOneShotGame($"lockstep/foot{UnityEngine.Random.Range(1, 3)}");
SoundByte.PlayOneShotGame("lockstep/drumOn");
}
public void Success(double beat)
private void JustOff(PlayerActionEvent caller, float state)
{
double beatAnimCheck = beat - 0.25;
if (beatAnimCheck % 1.0 >= 0.5)
currentMissStage = HowMissed.NotMissed;
stepswitcherPlayer.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
if (state >= 1f || state <= -1f)
{
SoundByte.PlayOneShotGame($"lockstep/marchOnbeat{UnityEngine.Random.Range(1, 3)}");
stepswitcherPlayer.DoScaledAnimationAsync("OnbeatMarch", 0.5f);
}
else
{
SoundByte.PlayOneShotGame($"lockstep/marchOffbeat{UnityEngine.Random.Range(1, 3)}");
stepswitcherPlayer.DoScaledAnimationAsync("OffbeatMarch", 0.5f);
SoundByte.PlayOneShot("nearMiss");
return;
}
SoundByte.PlayOneShotGame($"lockstep/foot{UnityEngine.Random.Range(1, 3)}");
SoundByte.PlayOneShotGame("lockstep/drumOff");
}
public void Miss(PlayerActionEvent caller)
private void MissOn(PlayerActionEvent caller)
{
var beatAnimCheck = Math.Round(caller.startBeat * 2);
if (beatAnimCheck % 2 != 0 && currentMissStage != HowMissed.MissedOff)
{
stepswitcherPlayer.Play("OffbeatMiss", 0, 0);
SoundByte.PlayOneShotGame("lockstep/wayOff");
currentMissStage = HowMissed.MissedOff;
}
else if (beatAnimCheck % 2 == 0 && currentMissStage != HowMissed.MissedOn)
{
stepswitcherPlayer.Play("OnbeatMiss", 0, 0);
SoundByte.PlayOneShotGame("lockstep/wayOff");
currentMissStage = HowMissed.MissedOn;
}
if (currentMissStage == HowMissed.MissedOn) return;
stepswitcherPlayer.Play("OnbeatMiss", 0, 0);
SoundByte.PlayOneShotGame("lockstep/wayOff");
currentMissStage = HowMissed.MissedOn;
}
private void MissOff(PlayerActionEvent caller)
{
if (currentMissStage == HowMissed.MissedOff) return;
stepswitcherPlayer.Play("OffbeatMiss", 0, 0);
SoundByte.PlayOneShotGame("lockstep/wayOff");
currentMissStage = HowMissed.MissedOff;
}
public void ChangeBeatBackGroundColour(bool off)

View File

@ -18,10 +18,11 @@ namespace HeavenStudio.Games.Scripts_SneakySpirits
public void Init(double spawnBeat, float length)
{
if (length == 0) length = 1;
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(spawnBeat + 0.001f, delegate { anim.DoScaledAnimationAsync("Move", 1f); }),
new BeatAction.Action(spawnBeat + length - 0.5f, delegate { anim.DoScaledAnimationAsync("MoveDown", 1f); }),
new BeatAction.Action(spawnBeat, delegate { anim.DoScaledAnimationAsync("Move", (1 / length) * Conductor.instance.SongPitch); }),
new BeatAction.Action(spawnBeat + (length * 0.5f), delegate { anim.DoScaledAnimationAsync("MoveDown", (1 / length) * Conductor.instance.SongPitch); }),
new BeatAction.Action(spawnBeat + length, delegate { Destroy(gameObject); }),
});
}

View File

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using static HeavenStudio.Games.SpaceDance;
using HeavenStudio.Common;
namespace HeavenStudio.Games.Loaders
@ -16,7 +15,8 @@ namespace HeavenStudio.Games.Loaders
{
new GameAction("turn right", "Turn Right")
{
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoTurnRight(e.beat, e["whoSpeaks"], e["gramps"]); },
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoTurnRight(e.beat, e["gramps"]); },
preFunction = delegate { var e = eventCaller.currentEntity; SpaceDance.TurnRightSfx(e.beat, e["whoSpeaks"]); },
defaultLength = 2.0f,
parameters = new List<Param>()
{
@ -26,7 +26,8 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("sit down", "Sit Down")
{
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoSitDown(e.beat, e["whoSpeaks"], e["gramps"]); },
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoSitDown(e.beat, e["gramps"]); },
preFunction = delegate { var e = eventCaller.currentEntity; SpaceDance.SitDownSfx(e.beat, e["whoSpeaks"]); },
defaultLength = 2.0f,
parameters = new List<Param>()
{
@ -36,7 +37,8 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("punch", "Punch")
{
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoPunch(e.beat, e["whoSpeaks"], e["gramps"]); },
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.DoPunch(e.beat, e["gramps"]); },
preFunction = delegate { var e = eventCaller.currentEntity; SpaceDance.PunchSfx(e.beat, e["whoSpeaks"]); },
defaultLength = 2.0f,
parameters = new List<Param>()
{
@ -46,7 +48,7 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("shootingStar", "Shooting Star")
{
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.UpdateShootingStar(e.beat, e.length, e["ease"]); },
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.UpdateShootingStar(e.beat, e.length, (EasingFunction.Ease)e["ease"]); },
defaultLength = 2f,
resizable = true,
parameters = new List<Param>()
@ -94,8 +96,8 @@ namespace HeavenStudio.Games.Loaders
function = delegate { var e = eventCaller.currentEntity; SpaceDance.instance.UpdateScrollSpeed(e["x"], e["y"]); },
defaultLength = 1f,
parameters = new List<Param>() {
new Param("x", new EntityTypes.Float(-5f, 5f, 0), "Horizontal", "How fast does the background move horizontally?"),
new Param("y", new EntityTypes.Float(-5f, 5f, 0), "Vertical", "How fast does the background move vertically?"),
new Param("x", new EntityTypes.Float(-10f, 10f, 0), "Horizontal", "How fast does the background move horizontally?"),
new Param("y", new EntityTypes.Float(-10f, 10f, 0), "Vertical", "How fast does the background move vertically?"),
}
},
},
@ -155,11 +157,10 @@ namespace HeavenStudio.Games
bool grampsSniffing;
[SerializeField] CanvasScroll scroll;
float scrollBeat;
float scrollOffsetX;
float scrollOffsetY;
float currentScrollLengthX;
float currentScrollLengthY;
float xScrollMultiplier = 0;
float yScrollMultiplier = 0;
[SerializeField] private float xBaseSpeed = 1;
[SerializeField] private float yBaseSpeed = 1;
public GameEvent bop = new GameEvent();
@ -177,10 +178,8 @@ namespace HeavenStudio.Games
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
float normalizedX = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthX;
float normalizedY = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthY;
scroll.NormalizedX = -scrollOffsetX - normalizedX;
scroll.NormalizedY = -scrollOffsetY - normalizedY;
scroll.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
scroll.NormalizedY -= yBaseSpeed * yScrollMultiplier * Time.deltaTime;
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (shouldBop)
@ -216,7 +215,6 @@ namespace HeavenStudio.Games
SoundByte.PlayOneShotGame("spaceDance/inputBad");
DancerP.DoScaledAnimationAsync("PunchDo", 0.5f);
Gramps.Play("GrampsOhFuck", 0, 0);
// Look at this later, sound effect has some weird clipping on it sometimes?? popping. like. fucking popopop idk why its doing that its fine theres no sample weirdness ughh
}
if (PlayerInput.GetSpecificDirectionDown(1) && !IsExpectingInputNow(InputType.DIRECTION_RIGHT_DOWN))
{
@ -236,11 +234,8 @@ namespace HeavenStudio.Games
public void UpdateScrollSpeed(float scrollSpeedX, float scrollSpeedY)
{
scrollOffsetX = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthX;
scrollOffsetY = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthY;
currentScrollLengthX = scrollSpeedX;
currentScrollLengthY = scrollSpeedY;
scrollBeat = Time.realtimeSinceStartup;
xScrollMultiplier = scrollSpeedX;
yScrollMultiplier = scrollSpeedY;
}
public void GrampsAnimations(double beat, int type, bool looping)
@ -373,12 +368,8 @@ namespace HeavenStudio.Games
isShootingStar = true;
}
public void DoTurnRight(double beat, int whoSpeaks, bool grampsTurns)
public static void TurnRightSfx(double beat, int whoSpeaks)
{
canBop = false;
if (grampsTurns) grampsCanBop = false;
ScheduleInput(beat, 1f, InputType.DIRECTION_RIGHT_DOWN, JustRight, RightMiss, Empty);
List<MultiSound.Sound> soundsToPlay = new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/voicelessTurn", beat),
@ -390,43 +381,50 @@ namespace HeavenStudio.Games
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/dancerTurn", beat),
new MultiSound.Sound("spaceDance/dancerRight", beat + 1.0f, 1, 1, false, 0.007f),
new MultiSound.Sound("spaceDance/dancerRight", beat + 1.0f, 1, 1, false, 0.012f),
});
break;
case (int)WhoSpeaks.Gramps:
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/otherTurn", beat),
new MultiSound.Sound("spaceDance/otherRight", beat + 1.0f, 1, 1, false, 0.007f),
new MultiSound.Sound("spaceDance/otherRight", beat + 1.0f, 1, 1, false, 0.005f),
});
break;
case (int)WhoSpeaks.Both:
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/dancerTurn", beat),
new MultiSound.Sound("spaceDance/dancerRight", beat + 1.0f, 1, 1, false, 0.007f),
new MultiSound.Sound("spaceDance/dancerRight", beat + 1.0f, 1, 1, false, 0.012f),
new MultiSound.Sound("spaceDance/otherTurn", beat),
new MultiSound.Sound("spaceDance/otherRight", beat + 1.0f, 1, 1, false, 0.007f),
new MultiSound.Sound("spaceDance/otherRight", beat + 1.0f, 1, 1, false, 0.005f),
});
break;
}
MultiSound.Play(soundsToPlay.ToArray());
}
public void DoTurnRight(double beat, bool grampsTurns)
{
canBop = false;
if (grampsTurns) grampsCanBop = false;
ScheduleInput(beat, 1f, InputType.DIRECTION_RIGHT_DOWN, JustRight, RightMiss, Empty);
BeatAction.New(Player, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { DancerP.DoScaledAnimationAsync("TurnRightStart", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer1.DoScaledAnimationAsync("TurnRightStart", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer2.DoScaledAnimationAsync("TurnRightStart", 0.5f);}),
new BeatAction.Action(beat, delegate
{
{
DancerP.DoScaledAnimationAsync("TurnRightStart", 0.5f);
Dancer1.DoScaledAnimationAsync("TurnRightStart", 0.5f);
Dancer2.DoScaledAnimationAsync("TurnRightStart", 0.5f);
Dancer3.DoScaledAnimationAsync("TurnRightStart", 0.5f);
if (grampsTurns) Gramps.DoScaledAnimationAsync("GrampsTurnRightStart", 0.5f);
}),
new BeatAction.Action(beat + 1f, delegate { Dancer1.DoScaledAnimationAsync("TurnRightDo", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate { Dancer2.DoScaledAnimationAsync("TurnRightDo", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate
{
Dancer1.DoScaledAnimationAsync("TurnRightDo", 0.5f);
Dancer2.DoScaledAnimationAsync("TurnRightDo", 0.5f);
Dancer3.DoScaledAnimationAsync("TurnRightDo", 0.5f);
if (grampsTurns) Gramps.DoScaledAnimationAsync("GrampsTurnRightDo", 0.5f);
}),
@ -435,11 +433,8 @@ namespace HeavenStudio.Games
}
public void DoSitDown(double beat, int whoSpeaks, bool grampsSits)
public static void SitDownSfx(double beat, int whoSpeaks)
{
canBop = false;
if (grampsSits) grampsCanBop = false;
ScheduleInput(beat, 1f, InputType.DIRECTION_DOWN_DOWN, JustSit, SitMiss, Empty);
List<MultiSound.Sound> soundsToPlay = new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/voicelessSit", beat),
@ -450,48 +445,55 @@ namespace HeavenStudio.Games
case (int)WhoSpeaks.Dancers:
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/dancerLets", beat, 1, 1, false, 0.07f),
new MultiSound.Sound("spaceDance/dancerSit", beat + 0.5f, 1, 1, false, 0.02f),
new MultiSound.Sound("spaceDance/dancerDown", beat + 1f, 1, 1, false, 0.006f),
new MultiSound.Sound("spaceDance/dancerLets", beat, 1, 1, false, 0.055f),
new MultiSound.Sound("spaceDance/dancerSit", beat + 0.5f, 1, 1, false, 0.05f),
new MultiSound.Sound("spaceDance/dancerDown", beat + 1f, 1, 1, false, 0.004f),
});
break;
case (int)WhoSpeaks.Gramps:
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/otherLets", beat, 1, 1, false, 0.024f),
new MultiSound.Sound("spaceDance/otherSit", beat + 0.5f, 1, 1, false, 0.04f),
new MultiSound.Sound("spaceDance/otherLets", beat, 1, 1, false, 0.02f),
new MultiSound.Sound("spaceDance/otherSit", beat + 0.5f, 1, 1, false, 0.064f),
new MultiSound.Sound("spaceDance/otherDown", beat + 1f, 1, 1, false, 0.01f),
});
break;
case (int)WhoSpeaks.Both:
soundsToPlay.AddRange(new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/dancerLets", beat, 1, 1, false, 0.07f),
new MultiSound.Sound("spaceDance/dancerSit", beat + 0.5f, 1, 1, false, 0.02f),
new MultiSound.Sound("spaceDance/dancerDown", beat + 1f, 1, 1, false, 0.006f),
new MultiSound.Sound("spaceDance/otherLets", beat, 1, 1, false, 0.024f),
new MultiSound.Sound("spaceDance/otherSit", beat + 0.5f, 1, 1, false, 0.04f),
new MultiSound.Sound("spaceDance/dancerLets", beat, 1, 1, false, 0.055f),
new MultiSound.Sound("spaceDance/dancerSit", beat + 0.5f, 1, 1, false, 0.05f),
new MultiSound.Sound("spaceDance/dancerDown", beat + 1f, 1, 1, false, 0.004f),
new MultiSound.Sound("spaceDance/otherLets", beat, 1, 1, false, 0.02f),
new MultiSound.Sound("spaceDance/otherSit", beat + 0.5f, 1, 1, false, 0.064f),
new MultiSound.Sound("spaceDance/otherDown", beat + 1f, 1, 1, false, 0.01f),
});
break;
}
MultiSound.Play(soundsToPlay.ToArray());
}
public void DoSitDown(double beat, bool grampsSits)
{
canBop = false;
if (grampsSits) grampsCanBop = false;
ScheduleInput(beat, 1f, InputType.DIRECTION_DOWN_DOWN, JustSit, SitMiss, Empty);
BeatAction.New(Player, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { DancerP.DoScaledAnimationAsync("SitDownStart", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer1.DoScaledAnimationAsync("SitDownStart", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer2.DoScaledAnimationAsync("SitDownStart", 0.5f);}),
new BeatAction.Action(beat, delegate
{
{
DancerP.DoScaledAnimationAsync("SitDownStart", 0.5f);
Dancer1.DoScaledAnimationAsync("SitDownStart", 0.5f);
Dancer2.DoScaledAnimationAsync("SitDownStart", 0.5f);
Dancer3.DoScaledAnimationAsync("SitDownStart", 0.5f);
if (grampsSits) Gramps.DoScaledAnimationAsync("GrampsSitDownStart", 0.5f);
}),
new BeatAction.Action(beat + 1f, delegate { Dancer1.DoScaledAnimationAsync("SitDownDo", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate { Dancer2.DoScaledAnimationAsync("SitDownDo", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate
{
{
Dancer1.DoScaledAnimationAsync("SitDownDo", 0.5f);
Dancer2.DoScaledAnimationAsync("SitDownDo", 0.5f);
Dancer3.DoScaledAnimationAsync("SitDownDo", 0.5f);
if (grampsSits) Gramps.DoScaledAnimationAsync("GrampsSitDownDo", 0.5f);
}),
@ -500,11 +502,8 @@ namespace HeavenStudio.Games
}
public void DoPunch(double beat, int whoSpeaks, bool grampsPunches)
public static void PunchSfx(double beat, int whoSpeaks)
{
canBop = false;
if (grampsPunches) grampsCanBop = false;
ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, JustPunch, PunchMiss, Empty);
List<MultiSound.Sound> soundsToPlay = new List<MultiSound.Sound>()
{
new MultiSound.Sound("spaceDance/voicelessPunch", beat),
@ -548,40 +547,51 @@ namespace HeavenStudio.Games
}
MultiSound.Play(soundsToPlay.ToArray());
}
public void DoPunch(double beat, bool grampsPunches)
{
canBop = false;
if (grampsPunches) grampsCanBop = false;
ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, JustPunch, PunchMiss, Empty);
BeatAction.New(Player, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { DancerP.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer1.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat, delegate { Dancer2.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat, delegate
{
new BeatAction.Action(beat, delegate
{
DancerP.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer1.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer2.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer3.DoScaledAnimationAsync("PunchStartInner", 0.5f);
if (grampsPunches) Gramps.DoScaledAnimationAsync("GrampsPunchStartOdd", 0.5f);
}),
new BeatAction.Action(beat + 0.5f, delegate { DancerP.DoScaledAnimationAsync("PunchStartOuter", 0.5f);}),
new BeatAction.Action(beat + 0.5f, delegate { Dancer1.DoScaledAnimationAsync("PunchStartOuter", 0.5f);}),
new BeatAction.Action(beat + 0.5f, delegate { Dancer2.DoScaledAnimationAsync("PunchStartOuter", 0.5f);}),
new BeatAction.Action(beat + 0.5f, delegate
{
new BeatAction.Action(beat + 0.5f, delegate
{
DancerP.DoScaledAnimationAsync("PunchStartOuter", 0.5f);
Dancer1.DoScaledAnimationAsync("PunchStartOuter", 0.5f);
Dancer2.DoScaledAnimationAsync("PunchStartOuter", 0.5f);
Dancer3.DoScaledAnimationAsync("PunchStartOuter", 0.5f);
if (grampsPunches) Gramps.DoScaledAnimationAsync("GrampsPunchStartEven", 0.5f);
}),
new BeatAction.Action(beat + 1f, delegate { DancerP.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate { Dancer1.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate { Dancer2.DoScaledAnimationAsync("PunchStartInner", 0.5f);}),
new BeatAction.Action(beat + 1f, delegate
{
new BeatAction.Action(beat + 1f, delegate
{
DancerP.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer1.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer2.DoScaledAnimationAsync("PunchStartInner", 0.5f);
Dancer3.DoScaledAnimationAsync("PunchStartInner", 0.5f);
if (grampsPunches) Gramps.DoScaledAnimationAsync("GrampsPunchStartOdd", 0.5f);
}),
new BeatAction.Action(beat + 1.5f, delegate { Dancer1.DoScaledAnimationAsync("PunchDo", 0.5f);}),
new BeatAction.Action(beat + 1.5f, delegate { Dancer2.DoScaledAnimationAsync("PunchDo", 0.5f);}),
new BeatAction.Action(beat + 1.5f, delegate
{
new BeatAction.Action(beat + 1.5f, delegate
{
Dancer1.DoScaledAnimationAsync("PunchDo", 0.5f);
Dancer2.DoScaledAnimationAsync("PunchDo", 0.5f);
Dancer3.DoScaledAnimationAsync("PunchDo", 0.5f);
if (grampsPunches) Gramps.DoScaledAnimationAsync("GrampsPunchDo", 0.5f);
}),
new BeatAction.Action(beat + 2.5, delegate
{
canBop = true; grampsCanBop = true;
})
});
}

View File

@ -98,8 +98,8 @@ namespace HeavenStudio.Games.Loaders
function = delegate { var e = eventCaller.currentEntity; SpaceSoccer.instance.UpdateScrollSpeed(e["x"], e["y"]); },
defaultLength = 1f,
parameters = new List<Param>() {
new Param("x", new EntityTypes.Float(-5f, 5f, 0.09f), "Horizontal", "How fast does the background move horizontally?"),
new Param("y", new EntityTypes.Float(-5f, 5f, 0.32f), "Vertical", "How fast does the background move vertically?"),
new Param("x", new EntityTypes.Float(-10f, 10, 0.1f), "Horizontal", "How fast does the background move horizontally?"),
new Param("y", new EntityTypes.Float(-10, 10f, 0.3f), "Vertical", "How fast does the background move vertically?"),
}
},
new GameAction("stopBall", "Stop Ball")
@ -202,11 +202,10 @@ namespace HeavenStudio.Games
[SerializeField] SuperCurveObject.Path[] ballPaths;
public bool ballDispensed;
double lastDispensedBeat;
float scrollBeat;
float scrollOffsetX;
float scrollOffsetY;
float currentScrollLengthX = 0.09f;
float currentScrollLengthY = 0.32f;
float xScrollMultiplier = 0.1f;
float yScrollMultiplier = 0.3f;
[SerializeField] private float xBaseSpeed = 1;
[SerializeField] private float yBaseSpeed = 1;
Tween bgColorTween;
Tween dotColorTween;
#region Space Kicker Position Easing
@ -244,10 +243,8 @@ namespace HeavenStudio.Games
private void Update()
{
var cond = Conductor.instance;
float normalizedX = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthX;
float normalizedY = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthY;
backgroundSprite.NormalizedX = -scrollOffsetX - normalizedX;
backgroundSprite.NormalizedY = scrollOffsetY + normalizedY;
backgroundSprite.NormalizedX -= xBaseSpeed * xScrollMultiplier * Time.deltaTime;
backgroundSprite.NormalizedY += yBaseSpeed * yScrollMultiplier * Time.deltaTime;
float normalizedEaseBeat = cond.GetPositionFromBeat(easeBeat, easeLength);
if (normalizedEaseBeat <= 1 && normalizedEaseBeat > 0)
@ -341,11 +338,8 @@ namespace HeavenStudio.Games
public void UpdateScrollSpeed(float scrollSpeedX, float scrollSpeedY)
{
scrollOffsetX = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthX;
scrollOffsetY = (Time.realtimeSinceStartup - scrollBeat) * currentScrollLengthY;
currentScrollLengthX = scrollSpeedX;
currentScrollLengthY = scrollSpeedY;
scrollBeat = Time.realtimeSinceStartup;
xScrollMultiplier = scrollSpeedX;
yScrollMultiplier = scrollSpeedY;
}
public void EaseSpaceKickersPositions(double beat, float length, int ease, float xDistance, float yDistance, float zDistance)

View File

@ -1,31 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScrollForTap : MonoBehaviour
{
public float scrollSpeedX;
public float scrollSpeedY;
Vector3 startPos;
public float lengthX;
public float lengthY = 43.20976f;
private void Start()
{
startPos = transform.localPosition;
UpdatePos();
}
private void Update()
{
UpdatePos();
}
private void UpdatePos()
{
float newPosX = Mathf.Repeat(Time.time * scrollSpeedX, lengthX);
float newPosY = Mathf.Repeat(Time.time * scrollSpeedY, lengthY);
transform.localPosition = startPos + new Vector3(1 * newPosX, 1 * newPosY);
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d04c124402523b64abce470b1c6ced10
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,8 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Loaders
@ -26,61 +24,60 @@ namespace HeavenStudio.Games.Loaders
},
new GameAction("tap", "Tap")
{
function = delegate { TapTrial.instance.Tap(eventCaller.currentEntity.beat); },
defaultLength = 2.0f
},
new GameAction("double tap", "Double Tap")
{
function = delegate { TapTrial.instance.DoubleTap(eventCaller.currentEntity.beat); },
defaultLength = 2.0f
},
new GameAction("triple tap", "Triple Tap")
{
function = delegate { TapTrial.instance.TripleTap(eventCaller.currentEntity.beat); },
defaultLength = 4.0f
},
new GameAction("jump tap prep", "Prepare Stance")
{
function = delegate { TapTrial.instance.JumpTapPrep(eventCaller.currentEntity.beat); },
function = delegate { TapTrial.instance.JumpPrepare(); },
},
new GameAction("jump tap", "Jump Tap")
{
function = delegate { TapTrial.instance.JumpTap(eventCaller.currentEntity.beat); },
defaultLength = 2.0f
},
new GameAction("final jump tap", "Final Jump Tap")
{
function = delegate { TapTrial.instance.FinalJumpTap(eventCaller.currentEntity.beat); },
defaultLength = 2.0f
function = delegate { var e = eventCaller.currentEntity; TapTrial.instance.JumpTap(e.beat, e["final"]); },
defaultLength = 2.0f,
parameters = new List<Param>()
{
new Param("final", false, "Final")
}
},
new GameAction("scroll event", "Scroll Background")
{
function = delegate { TapTrial.instance.scrollEvent(eventCaller.currentEntity["toggle"], eventCaller.currentEntity["flash"]); },
defaultLength = .5f,
function = delegate { var e = eventCaller.currentEntity; TapTrial.instance.Scroll(e["toggle"], e["flash"], e["m"]); },
defaultLength = 1f,
parameters = new List<Param>()
{
new Param("toggle", true, "Scroll FX", "Will scroll"),
new Param("flash", false, "Flash FX", "Will flash to white"),
new Param("flash", true, "Flash FX", "Will flash to white"),
new Param("m", new EntityTypes.Float(0, 10, 1), "Speed Multiplier")
}
},
new GameAction("giraffe events", "Giraffe Animations")
{
function = delegate { TapTrial.instance.giraffeEvent(eventCaller.currentEntity["instant"]); },
defaultLength = .5f,
function = delegate { var e = eventCaller.currentEntity; TapTrial.instance.GiraffeAnims(e.beat, e.length, e["toggle"], e["instant"]); },
resizable = true,
parameters = new List<Param>()
{
new Param("toggle", true, "Enter?", "Giraffe will enter the scene"),
new Param("instant", false, "Instant", "Will the giraffe enter/exit instantly?")
new Param("toggle", TapTrial.GiraffeAnimation.Enter, "Animation", "Which animation?"),
new Param("instant", EasingFunction.Ease.Linear, "Ease", "Which ease will be used?")
}
}
},
// backwards-compatibility
new GameAction("final jump tap", "Final Jump Tap")
{
function = delegate { var e = eventCaller.currentEntity; TapTrial.instance.JumpTap(e.beat, true); },
defaultLength = 2.0f,
hidden = true
},
},
new List<string>() {"agb", "normal"},
"agbtap", "en",
@ -92,35 +89,30 @@ namespace HeavenStudio.Games.Loaders
namespace HeavenStudio.Games
{
using Scripts_TapTrial;
using HeavenStudio.Common;
using Scripts_TapTrial;
public class TapTrial : Minigame
{
[Header("References")]
public TapTrialPlayer player;
//public GameObject tap;
[SerializeField] List<Animator> monkeys;
[SerializeField] List<GameObject> monkey_roots;
[SerializeField] GameObject player_root;
//temporary
[SerializeField] List<GameObject> monkey_effects;
[SerializeField] List<GameObject> player_effects;
[SerializeField] Scroll scrollBG;
[SerializeField] SpriteRenderer flash;
[SerializeField] ScrollForTap scroll;
[SerializeField] GameObject giraffe;
bool goBop = true, isPrep;
bool hasJumped, isFinalJump;
public double jumpStartTime = double.MinValue;
float jumpPos;
public bool crIsRunning;
[SerializeField] GameObject bg;
bool giraffeIsIn;
[Header("Components")]
[SerializeField] private TapTrialPlayer player;
[SerializeField] private Animator monkeyL, monkeyR, giraffe;
[SerializeField] private ParticleSystem monkeyTapLL, monkeyTapLR, monkeyTapRL, monkeyTapRR;
[SerializeField] private Transform rootPlayer, rootMonkeyL, rootMonkeyR;
[SerializeField] private CanvasScroll bgScroll;
[SerializeField] private SpriteRenderer flash;
[Header("Values")]
[SerializeField] private float jumpHeight = 4f;
[SerializeField] private float monkeyJumpHeight = 3f;
[SerializeField] private float maxFlashOpacity = 0.8f;
public GameEvent bop = new GameEvent();
private GameEvent bop = new();
private bool canBop = true;
private bool shouldBop = true;
public static TapTrial instance { get; set; }
private double jumpStartBeat = double.MinValue;
public static TapTrial instance;
private void Awake()
{
@ -129,387 +121,365 @@ namespace HeavenStudio.Games
private void Update()
{
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
var cond = Conductor.instance;
if (cond.isPlaying && !cond.isPaused)
{
if (goBop) SingleBop();
}
jumpPos = Conductor.instance.GetPositionFromBeat(jumpStartTime, 1f);
if (Conductor.instance.songPositionInBeatsAsDouble >= jumpStartTime && Conductor.instance.songPositionInBeatsAsDouble < jumpStartTime + 1f)
{
float yMul = jumpPos * 2f - 1f;
float yWeight = -(yMul * yMul) + 1f;
monkey_roots[0].transform.localPosition = new Vector3(0, 1.5f * yWeight);
monkey_roots[1].transform.localPosition = new Vector3(0, 1.5f * yWeight);
if (!isFinalJump)
if (shouldBop && cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
player_root.transform.localPosition = new Vector3(0f, 2.5f * yWeight);
SingleBop();
}
GiraffeUpdate(cond);
JumpUpdate(cond);
ScrollUpdate(cond);
}
}
public void Scroll(bool scroll, bool flash, float multiplier)
{
scrolling = scroll;
flashing = flash;
scrollMultiplier = multiplier;
ResetScroll();
}
public void ResetScroll()
{
currentScrollSpeed = 0;
currentNormalizedY = 0;
flash.color = new Color(1, 1, 1, 0);
}
private bool scrolling;
private bool flashing;
[SerializeField] private float maxScrollSpeed = 0.25f;
[SerializeField] private float accelerationSpeed = 0.01f;
private float currentScrollSpeed = 0;
private float currentNormalizedY = 0;
private float scrollMultiplier = 1;
private void ScrollUpdate(Conductor cond)
{
if (!scrolling)
{
bgScroll.Normalized = Vector2.zero;
ResetScroll();
return;
}
currentNormalizedY += currentScrollSpeed * Time.deltaTime;
bgScroll.NormalizedY = currentNormalizedY * scrollMultiplier;
if (flashing) flash.color = new Color(1, 1, 1, Mathf.Lerp(0, maxFlashOpacity, currentNormalizedY));
currentScrollSpeed += accelerationSpeed * Time.deltaTime;
currentScrollSpeed = Mathf.Min(maxScrollSpeed, currentScrollSpeed);
}
private void GiraffeUpdate(Conductor cond)
{
float normalizedGiraffeBeat = cond.GetPositionFromBeat(animStartBeat, animLength);
EasingFunction.Function func = EasingFunction.GetEasingFunction(currentEase);
if (normalizedGiraffeBeat <= 1f && normalizedGiraffeBeat >= 0f)
{
switch (currentAnim)
{
case GiraffeAnimation.Enter:
giraffe.DoNormalizedAnimation("Enter", func(0, 1, normalizedGiraffeBeat));
break;
case GiraffeAnimation.Exit:
giraffe.DoNormalizedAnimation("Exit", func(0, 1, normalizedGiraffeBeat));
break;
default: break;
}
}
}
private void JumpUpdate(Conductor cond)
{
float normalizedJumpBeat = cond.GetPositionFromBeat(jumpStartBeat, 1);
if (normalizedJumpBeat >= 0 && normalizedJumpBeat <= 1)
{
if (normalizedJumpBeat >= 0.5f)
{
float normalizedUp = cond.GetPositionFromBeat(jumpStartBeat, 0.5);
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseOutQuad);
float newPlayerY = func(0, jumpHeight, normalizedUp);
float newMonkeyY = func(0, monkeyJumpHeight, normalizedUp);
rootPlayer.localPosition = new Vector3(0, newPlayerY);
rootMonkeyL.localPosition = new Vector3(0, newMonkeyY);
rootMonkeyR.localPosition = new Vector3(0, newMonkeyY);
}
else
{
player_root.transform.localPosition = new Vector3(0f, 3.5f * yWeight);
float normalizedDown = cond.GetPositionFromBeat(jumpStartBeat + 0.5, 0.5);
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInQuad);
float newPlayerY = func(jumpHeight, 0, normalizedDown);
float newMonkeyY = func(monkeyJumpHeight, 0, normalizedDown);
rootPlayer.localPosition = new Vector3(0, newPlayerY);
rootMonkeyL.localPosition = new Vector3(0, newMonkeyY);
rootMonkeyR.localPosition = new Vector3(0, newMonkeyY);
}
}
else
{
monkey_roots[0].transform.localPosition = new Vector3(0, 0);
monkey_roots[1].transform.localPosition = new Vector3(0, 0);
player_root.transform.localPosition = new Vector3(0, 0);
if (hasJumped)
{
//Jukebox.PlayOneShotGame("fanClub/landing_impact", pitch: UnityEngine.Random.Range(0.95f, 1f), volume: 1f / 4);
}
hasJumped = false;
if (PlayerInput.Pressed() && !IsExpectingInputNow())
{
player.anim.Play("Tap", 0, 0);
SoundByte.PlayOneShotGame("tapTrial/tonk");
}
rootPlayer.localPosition = Vector3.zero;
rootMonkeyL.localPosition = Vector3.zero;
rootMonkeyR.localPosition = Vector3.zero;
}
}
void SingleBop()
public enum GiraffeAnimation
{
if (!isPrep)
Enter,
Exit,
Blink
}
private GiraffeAnimation currentAnim = GiraffeAnimation.Enter;
private double animStartBeat = -1;
private float animLength = 0;
private EasingFunction.Ease currentEase = EasingFunction.Ease.Linear;
public void GiraffeAnims(double beat, float length, int type, int ease)
{
animStartBeat = beat;
animLength = length;
currentAnim = (GiraffeAnimation)type;
currentEase = (EasingFunction.Ease)ease;
if (currentAnim == GiraffeAnimation.Blink) giraffe.DoScaledAnimationAsync("Blink", 0.5f);
}
public void Bop(double beat, float length, bool bop, bool autoBop)
{
shouldBop = autoBop;
if (bop)
{
if (monkeys[0].GetCurrentAnimatorStateInfo(0).IsName("Idle")) monkeys[0].DoScaledAnimationAsync("Bop", 0.5f);
if (monkeys[1].GetCurrentAnimatorStateInfo(0).IsName("Idle")) monkeys[1].DoScaledAnimationAsync("Bop", 0.5f);
if (player.anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) player.anim.DoScaledAnimationAsync("Bop", 0.5f);
List<BeatAction.Action> actions = new();
for (int i = 0; i < length; i++)
{
actions.Add(new BeatAction.Action(beat + i, delegate { SingleBop(); }));
}
BeatAction.New(gameObject, actions);
}
}
public void Bop(double beat, float length, bool isBopping, bool autoBop)
private void SingleBop()
{
goBop = autoBop;
if (isBopping)
{
for (int i = 0; i < length; i++)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + i, delegate { SingleBop(); })
});
}
}
if (!canBop) return;
PlayMonkeyAnimationScaledAsync("Bop", 0.5f);
player.Bop();
}
public void Tap(double beat)
{
isPrep = true;
SoundByte.PlayOneShotGame("tapTrial/ook");
player.anim.DoScaledAnimationAsync("TapPrepare", 0.5f);
//Monkey Tap Prepare Anim
BeatAction.New(gameObject, new List<BeatAction.Action>()
canBop = false;
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { monkeys[0].DoScaledAnimationAsync("TapPrepare", 0.5f); }),
new BeatAction.Action(beat, delegate { monkeys[1].DoScaledAnimationAsync("TapPrepare", 0.5f); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[0].DoScaledAnimationAsync("Tap", 0.6f); particleEffectMonkeys(); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[1].DoScaledAnimationAsync("Tap", 0.6f); }),
new BeatAction.Action(beat, delegate
{
PlayMonkeyAnimationScaledAsync("TapPrepare", 0.5f);
player.PrepareTap();
}),
new BeatAction.Action(beat + 1, delegate
{
PlayMonkeyAnimationScaledAsync("Tap", 0.5f);
MonkeyParticles(true);
}),
new BeatAction.Action(beat + 1.5, delegate
{
canBop = true;
})
});
//CreateTap(beat);
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnTap, OnTapMiss, OnEmpty);
BeatAction.New(gameObject, new List<BeatAction.Action>()
MultiSound.Play(new MultiSound.Sound[]
{
new BeatAction.Action(beat + 1.5f, delegate { isPrep = false; })
new MultiSound.Sound("tapTrial/ook", beat),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 1, 1.4f, 0.5f),
});
ScheduleInput(beat, 1, InputType.STANDARD_DOWN, JustTap, Miss, Empty);
}
public void DoubleTap(double beat)
{
isPrep = true;
canBop = false;
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
PlayMonkeyAnimationScaledAsync("DoubleTapPrepare", 0.5f);
player.PrepareTap(true);
}),
new BeatAction.Action(beat + 0.5, delegate
{
PlayMonkeyAnimationScaledAsync("DoubleTapPrepare_2", 0.5f);
}),
new BeatAction.Action(beat + 1, delegate
{
PlayMonkeyAnimationScaledAsync("DoubleTap", 0.5f);
MonkeyParticles(false);
}),
new BeatAction.Action(beat + 1.5, delegate
{
PlayMonkeyAnimationScaledAsync("DoubleTap", 0.5f);
MonkeyParticles(false);
canBop = true;
}),
});
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("tapTrial/ookook", beat),
new MultiSound.Sound("tapTrial/ookook", beat + 0.5f)
new MultiSound.Sound("tapTrial/ookook", beat),
new MultiSound.Sound("tapTrial/ookook", beat + 0.5),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 1, 1.4f, 0.5f),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 1.5, 1.4f, 0.5f),
});
player.anim.DoScaledAnimationAsync("DoubleTapPrepare", 0.5f);
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { monkeys[0].DoScaledAnimationAsync("DoubleTapPrepare", 0.5f); }),
new BeatAction.Action(beat + .5f, delegate { monkeys[0].DoScaledAnimationAsync("DoubleTapPrepare_2", 0.5f); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[0].DoScaledAnimationAsync("DoubleTap", 0.6f); particleEffectMonkeys(); }),
new BeatAction.Action(beat + 1.5f, delegate { monkeys[0].DoScaledAnimationAsync("DoubleTap", 0.6f); particleEffectMonkeys(); }),
new BeatAction.Action(beat + 1.99f, delegate {monkeys[0].Play("Idle", 0, 0); }),
});
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { monkeys[1].DoScaledAnimationAsync("DoubleTapPrepare", 0.5f); }),
new BeatAction.Action(beat + .5f, delegate { monkeys[1].DoScaledAnimationAsync("DoubleTapPrepare_2", 0.5f); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[1].DoScaledAnimationAsync("DoubleTap", 0.6f); }),
new BeatAction.Action(beat + 1.5f, delegate { monkeys[1].DoScaledAnimationAsync("DoubleTap", 0.6f); }),
new BeatAction.Action(beat + 1.99f, delegate {monkeys[1].Play("Idle", 0, 0); }),
});
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 1.5f, delegate { isPrep = false; })
});
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnDoubleTap, OnTapMiss, OnEmpty);
ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, OnDoubleTap, OnTapMiss, OnEmpty);
ScheduleInput(beat, 1, InputType.STANDARD_DOWN, JustDoubleTap, Miss, Empty);
ScheduleInput(beat, 1.5, InputType.STANDARD_DOWN, JustDoubleTap, Miss, Empty);
}
public void TripleTap(double beat)
{
isPrep = true;
canBop = false;
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
player.PrepareTripleTap(beat);
PlayMonkeyAnimationScaledAsync("PostPrepare_1", 0.5f);
}),
new BeatAction.Action(beat + 0.5, delegate
{
PlayMonkeyAnimationScaledAsync("PostPrepare_2", 0.5f);
}),
new BeatAction.Action(beat + 2, delegate
{
PlayMonkeyAnimationScaledAsync("PostTap", 0.5f);
MonkeyParticles(true);
}),
new BeatAction.Action(beat + 2.5, delegate
{
PlayMonkeyAnimationScaledAsync("PostTap_2", 0.5f);
MonkeyParticles(false);
}),
new BeatAction.Action(beat + 3, delegate
{
PlayMonkeyAnimationScaledAsync("PostTap", 0.5f);
MonkeyParticles(true);
}),
});
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("tapTrial/ooki1", beat),
new MultiSound.Sound("tapTrial/ooki2", beat + 0.5f)
new MultiSound.Sound("tapTrial/ooki1", beat),
new MultiSound.Sound("tapTrial/ooki2", beat + 0.5),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 2, 1.4f, 0.5f),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 2.5, 1.4f, 0.5f),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 3, 1.4f, 0.5f),
});
player.tripleOffset = 0;
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { player.anim.Play("PosePrepare_1", 0, 0);}),
new BeatAction.Action(beat + .5f, delegate { player.anim.Play("PosePrepare_2", 0, 0);}),
});
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { monkeys[0].Play("PostPrepare_1", 0, 0); }),
new BeatAction.Action(beat + .5f, delegate { monkeys[0].Play("PostPrepare_2", 0, 0); }),
new BeatAction.Action(beat + 2f, delegate { monkeys[0].Play("PostTap", 0, 0); }),
new BeatAction.Action(beat + 2.5f, delegate { monkeys[0].Play("PostTap_2", 0, 0); }),
new BeatAction.Action(beat + 3f, delegate { monkeys[0].Play("PostTap", 0, 0);}),
});
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { monkeys[1].Play("PostPrepare_1", 0, 0); }),
new BeatAction.Action(beat + .5f, delegate { monkeys[1].Play("PostPrepare_2", 0, 0); }),
new BeatAction.Action(beat + 2f, delegate { monkeys[1].Play("PostTap", 0, 0); }),
new BeatAction.Action(beat + 2.5f, delegate { monkeys[1].Play("PostTap_2", 0, 0);}),
new BeatAction.Action(beat + 3f, delegate { monkeys[1].Play("PostTap", 0, 0);}),
});
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 2f, delegate { particleEffectMonkeys(); }),
new BeatAction.Action(beat + 2.5f, delegate { particleEffectMonkeys(); }),
new BeatAction.Action(beat + 3f, delegate { particleEffectMonkeys(); }),
});
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
ScheduleInput(beat, 2.5f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
ScheduleInput(beat, 3f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 4f, delegate { isPrep = false; })
});
ScheduleInput(beat, 2, InputType.STANDARD_DOWN, JustTripleTap, Miss, Empty);
ScheduleInput(beat, 2.5, InputType.STANDARD_DOWN, JustTripleTap, Miss, Empty);
ScheduleInput(beat, 3, InputType.STANDARD_DOWN, JustTripleTap, Miss, Empty);
}
public void JumpTap(double beat)
public void JumpPrepare()
{
isPrep = true;
hasJumped = true;
SoundByte.PlayOneShotGame("tapTrial/jumptap1");
player.anim.Play("JumpTap", 0, 0);
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate {jumpStartTime = Conductor.instance.songPositionInBeatsAsDouble;}),
new BeatAction.Action(beat, delegate {monkeys[0].Play("JumpTap", 0, 0); }),
new BeatAction.Action(beat, delegate {monkeys[1].Play("JumpTap", 0, 0); }),
new BeatAction.Action(beat + 1f, delegate { particleEffectMonkeys(); monkeys[0].Play("Jumpactualtap", 0, 0); monkeys[1].Play("Jumpactualtap", 0, 0); }),
new BeatAction.Action(beat + 1f, delegate { particleEffectMonkeys_2(); }),
});
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnJumpTap, OnJumpTapMiss, OnEmpty); //why would it be .95f? no idea, sounds fine w/ 1f
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 2f, delegate { isPrep = false; })
});
canBop = false;
player.PrepareJump();
PlayMonkeyAnimationScaledAsync("JumpPrepare", 0.5f);
}
public void JumpTapPrep(double beat)
public void JumpTap(double beat, bool final)
{
isPrep = true;
monkeys[0].Play("JumpPrepare", 0, 0);
monkeys[1].Play("JumpPrepare", 0, 0);
player.anim.Play("JumpPrepare", 0, 0);
}
public void FinalJumpTap(double beat)
{
isPrep = true;
hasJumped = true;
isFinalJump = true;
SoundByte.PlayOneShotGame("tapTrial/jumptap2");
player.anim.Play("FinalJump");
canBop = false;
jumpStartBeat = beat;
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate {jumpStartTime = Conductor.instance.songPositionInBeatsAsDouble;}),
new BeatAction.Action(beat, delegate {monkeys[0].Play("Jump", 0, 0); }),
new BeatAction.Action(beat, delegate {monkeys[1].Play("Jump", 0, 0); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("FinalJumpTap", 0, 0); particleEffectMonkeys(); particleEffectMonkeys_2(); }),
new BeatAction.Action(beat + 1f, delegate { monkeys[1].Play("FinalJumpTap", 0, 0); }),
});
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnJumpFinalTap, OnFinalJumpTapMiss, OnEmpty);
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 2f, delegate { isPrep = false; })
});
}
public void giraffeEvent(bool instant)
{
float animTime = 0;
if (instant) animTime = 1;
if (!giraffeIsIn)
{
giraffe.SetActive(true);
giraffe.GetComponent<Animator>().Play("Enter", 0, animTime);
giraffeIsIn = true;
}
else if (giraffeIsIn)
{
giraffe.GetComponent<Animator>().Play("Exit", 0, animTime);
giraffeIsIn = false;
}
}
public void scrollEvent(bool isScrolling, bool flashToWhite)
{
if (isScrolling)
{
if (!crIsRunning) // if coroutine is not running, play the following once
new BeatAction.Action(beat, delegate
{
if (flashToWhite)
{
Sequence sequence = DOTween.Sequence();
sequence.Append(flash.DOColor(new Color(flash.color.r, flash.color.g, flash.color.b, .8f), 2f));
//sequence.Kill();
}
StartCoroutine(timer());
}
}
else //should be the reverse of the code above
{
scrollBG.enabled = false;
scrollBG.scrollSpeedY = 0;
}
}
#region Player Action Scripts
public void OnTap(PlayerActionEvent caller, float beat)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
player.anim.DoScaledAnimationAsync("Tap", 0.6f);
player_effects[0].GetComponent<ParticleSystem>().Play();
}
public void OnDoubleTap(PlayerActionEvent caller, float beat)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
player.anim.DoScaledAnimationAsync("DoubleTap", 0.6f);
player_effects[1].GetComponent<ParticleSystem>().Play();
}
public void OnTapMiss(PlayerActionEvent caller)
{
SoundByte.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
}
public void OnJumpTapMiss(PlayerActionEvent caller)
{
SoundByte.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
player.anim.Play("JumpTap_Miss", 0, 0);
}
public void OnFinalJumpTapMiss(PlayerActionEvent caller)
{
SoundByte.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
player.anim.Play("FinalJump_Miss", 0, 0);
}
public void OnEmpty(PlayerActionEvent caller)
{
//empty
}
public void OnTripleTap(PlayerActionEvent caller, float beat)
{
if (player.tripleOffset % 2 == 0)
{
BeatAction.New(gameObject, new List<BeatAction.Action>()
player.Jump(final);
PlayMonkeyAnimationScaledAsync(final ? "Jump" : "JumpTap", 0.5f);
}),
new BeatAction.Action(beat + 1, delegate
{
new BeatAction.Action(beat, delegate { player.anim.Play("PoseTap_L", 0, 0); })
});
player.tripleOffset += 1;
}
else
{
BeatAction.New(gameObject, new List<BeatAction.Action>()
PlayMonkeyAnimationScaledAsync(final ? "FinalJumpTap" : "Jumpactualtap", 0.5f);
MonkeyParticles(true);
MonkeyParticles(false);
}),
new BeatAction.Action(beat + 1.5, delegate
{
new BeatAction.Action(beat, delegate { player.anim.Play("PoseTap_R", 0, 0); })
});
player.tripleOffset += 1;
}
player_effects[0].GetComponent<ParticleSystem>().Play();
SoundByte.PlayOneShotGame("tapTrial/tap");
}
public void OnJumpTap(PlayerActionEvent caller, float beat)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
player.anim.Play("JumpTap_Success", 0, 0);
player_effects[0].GetComponent<ParticleSystem>().Play();
player_effects[1].GetComponent<ParticleSystem>().Play();
}
public void OnJumpFinalTap(PlayerActionEvent caller, float beat)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
player.anim.Play("FinalJump_Tap");
player_effects[0].GetComponent<ParticleSystem>().Play();
player_effects[1].GetComponent<ParticleSystem>().Play();
isFinalJump = false;
}
#endregion
canBop = final;
})
});
#region Misc. Functions
public void particleEffectMonkeys()
{
monkey_effects[0].GetComponent<ParticleSystem>().Play();
monkey_effects[1].GetComponent<ParticleSystem>().Play();
}
public void particleEffectMonkeys_2()
{
monkey_effects[2].GetComponent<ParticleSystem>().Play();
monkey_effects[3].GetComponent<ParticleSystem>().Play();
}
IEnumerator timer()
{
crIsRunning = true;
while (scroll.scrollSpeedY < 20)
MultiSound.Play(new MultiSound.Sound[]
{
scroll.scrollSpeedY += 5f;
yield return new WaitForSecondsRealtime(.5f);
}
}
#endregion
new MultiSound.Sound(final ? "tapTrial/jumptap2" : "tapTrial/jumptap1", beat),
new MultiSound.Sound("tapTrial/tapMonkey", beat + 1, 1.4f, 0.5f),
});
//this is the orig way for input handling
//public void CreateTap(float beat, int type = 0)
//{
// GameObject _tap = Instantiate(tap);
// _tap.transform.parent = tap.transform.parent;
// _tap.SetActive(true);
// Tap t = _tap.GetComponent<Tap>();
// t.startBeat = beat;
// t.type = type;
//}
ScheduleInput(beat, 1, InputType.STANDARD_DOWN, final ? JustJumpTapFinal : JustJumpTap, final ? MissJumpFinal : MissJump, Empty);
}
private void JustJumpTap(PlayerActionEvent caller, float state)
{
player.JumpTap(state < 1f && state > -1f, false);
}
private void JustJumpTapFinal(PlayerActionEvent caller, float state)
{
player.JumpTap(state < 1f && state > -1f, true);
}
private void MissJump(PlayerActionEvent caller)
{
player.JumpTapMiss(false);
if (giraffe.IsAnimationNotPlaying()) giraffe.DoScaledAnimationAsync("Miss", 0.5f);
ResetScroll();
}
private void MissJumpFinal(PlayerActionEvent caller)
{
player.JumpTapMiss(true);
if (giraffe.IsAnimationNotPlaying()) giraffe.DoScaledAnimationAsync("Miss", 0.5f);
ResetScroll();
}
private void JustTap(PlayerActionEvent caller, float state)
{
player.Tap(state < 1f && state > -1f);
}
private void JustDoubleTap(PlayerActionEvent caller, float state)
{
player.Tap(state < 1f && state > -1f, true);
}
private void JustTripleTap(PlayerActionEvent caller, float state)
{
player.TripleTap(state < 1f && state > -1f);
}
private void Miss(PlayerActionEvent caller)
{
if (giraffe.IsAnimationNotPlaying() && currentAnim != GiraffeAnimation.Exit) giraffe.DoScaledAnimationAsync("Miss", 0.5f);
ResetScroll();
}
private void Empty(PlayerActionEvent caller) { }
private void PlayMonkeyAnimationScaledAsync(string name, float timeScale)
{
monkeyL.DoScaledAnimationAsync(name, timeScale);
monkeyR.DoScaledAnimationAsync(name, timeScale);
}
private void MonkeyParticles(bool left)
{
ParticleSystem spawnedEffectL = Instantiate(left ? monkeyTapLL : monkeyTapLR, transform);
spawnedEffectL.Play();
ParticleSystem spawnedEffectR = Instantiate(left ? monkeyTapRL : monkeyTapRR, transform);
spawnedEffectR.Play();
}
}
}

View File

@ -1,53 +1,163 @@
using UnityEngine;
using System;
using HeavenStudio.Util;
using System.Collections;
using System.Collections.Generic;
namespace HeavenStudio.Games.Scripts_TapTrial
{
public class TapTrialPlayer : MonoBehaviour
{
[Header("References")]
[System.NonSerialized] public Animator anim;
private enum TapState
{
Tap,
DoubleTap,
TripleTap,
Jumping
}
private TapState state = TapState.Tap;
private int tripleTaps = 0;
private Animator anim;
[SerializeField] private ParticleSystem tapEffectLeft;
[SerializeField] private ParticleSystem tapEffectRight;
public int tripleOffset = 0;
private TapTrial game;
private void Awake()
{
anim = GetComponent<Animator>();
game = TapTrial.instance;
}
private void Update()
{
if (PlayerInput.Pressed())
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
{
Tap(false, 0);
WhiffTap();
}
}
public void Tap(bool hit, int type)
public void Bop()
{
if (hit)
SoundByte.PlayOneShotGame("tapTrial/tap");
else
SoundByte.PlayOneShotGame("tapTrial/tonk");
anim.DoScaledAnimationAsync("Bop", 0.5f);
}
switch (type)
private void WhiffTap()
{
switch (state)
{
case 0:
anim.Play("Tap", 0, 0);
case TapState.Tap:
game.ScoreMiss();
game.ResetScroll();
Tap(false, false);
break;
case 1:
anim.Play("DoubleTap", 0, 0);
case TapState.DoubleTap:
game.ScoreMiss();
game.ResetScroll();
Tap(false, true);
break;
case 2:
if(tripleOffset % 2 == 0)
anim.Play("DoubleTap", 0, 0);
else
anim.Play("Tap", 0, 0);
tripleOffset++;
case TapState.TripleTap:
game.ScoreMiss();
game.ResetScroll();
break;
case TapState.Jumping:
break;
}
}
public void PrepareJump()
{
anim.DoScaledAnimationAsync("JumpPrepare", 0.5f);
state = TapState.Jumping;
}
public void Jump(bool final)
{
anim.DoScaledAnimationAsync(final ? "FinalJump" : "JumpTap", 0.5f);
state = TapState.Jumping;
}
public void JumpTap(bool ace, bool final)
{
if (ace)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
SpawnTapEffect(true);
SpawnTapEffect(false);
}
else
{
SoundByte.PlayOneShot("nearMiss");
game.ResetScroll();
}
anim.DoScaledAnimationAsync(final ? "FinalJump_Tap" : "JumpTap_Success", 0.5f);
}
public void JumpTapMiss(bool final)
{
anim.DoScaledAnimationAsync(final ? "FinalJump_Miss" : "JumpTap_Miss", 0.5f);
}
public void PrepareTap(bool doubleTap = false)
{
anim.DoScaledAnimationAsync(doubleTap ? "DoubleTapPrepare" : "TapPrepare", 0.5f);
state = doubleTap ? TapState.DoubleTap : TapState.Tap;
}
public void Tap(bool ace, bool doubleTap = false)
{
if (ace)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
SpawnTapEffect(!doubleTap);
}
else
{
SoundByte.PlayOneShot("nearMiss");
game.ResetScroll();
}
anim.DoScaledAnimationAsync(doubleTap ? "DoubleTap" : "Tap", 0.5f);
}
public void PrepareTripleTap(double beat)
{
anim.DoScaledAnimationAsync("PosePrepare_1", 0.5f);
state = TapState.TripleTap;
tripleTaps = 0;
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.5, delegate
{
anim.DoScaledAnimationAsync("PosePrepare_2", 0.5f);
})
});
}
public void TripleTap(bool ace)
{
bool tapLeft = tripleTaps % 2 == 0;
tripleTaps++;
if (ace)
{
SoundByte.PlayOneShotGame("tapTrial/tap");
SpawnTapEffect(tapLeft);
}
else
{
SoundByte.PlayOneShot("nearMiss");
game.ResetScroll();
}
anim.DoScaledAnimationAsync(tapLeft ? "PoseTap_L" : "PoseTap_R", 0.5f);
}
private void SpawnTapEffect(bool left)
{
ParticleSystem spawnedTap = Instantiate(left ? tapEffectLeft : tapEffectRight, game.transform);
spawnedTap.Play();
}
}
}