using System; using System.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; using HeavenStudio.Util; using HeavenStudio.InputSystem; using Jukebox; namespace HeavenStudio.Games.Loaders { using static Minigames; public static class NtrFrogHopLoader { public static Minigame AddGame(EventCaller eventCaller) { return new Minigame("frogHop", "Frog Hop", "ffffff", false, false, new List() { new GameAction("bop", "Bop") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Bop(e.beat, e.length, e["bop"]); } }, resizable = true, parameters = new List() { new Param("bop", FrogHop.WhoBops.All, "Bop", "Set the character(s) to bop for the duration of this event."), } }, new GameAction("count", "Count In") { preFunction = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Count(e.beat, e["start"]); } }, parameters = new List() { new Param("start", true, "Start Shaking", "Start shaking after the count in."), }, defaultLength = 4.0f, }, new GameAction("hop", "Start Shaking") { preFunction = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Hop(e.beat); } }, }, new GameAction("twoshake", "Ya-hoo!") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.TwoHop(e.beat, e["spotlights"]); } }, parameters = new List() { new Param("spotlights", true, "Automatic Spotlights", "Handles spotlight switching automatically."), }, defaultLength = 4.0f, }, new GameAction("threeshake", "Yeah yeah yeah!") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.ThreeHop(e.beat, e["spotlights"]); } }, parameters = new List() { new Param("spotlights", true, "Automatic Spotlights", "Handles spotlight switching automatically."), }, defaultLength = 4.0f, }, new GameAction("spin", "Spin it Boys!") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.SpinItBoys(e.beat, e["spotlights"]); } }, parameters = new List() { new Param("spotlights", true, "Automatic Spotlights", "Handles spotlight switching automatically."), }, defaultLength = 4.0f, }, new GameAction("spotlights", "Spotlights") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Spotlights(e["front"], e["back"], e["dark"]); } }, parameters = new List() { new Param("front", true, "Front Lights", "Enables the spotlights on the front frogs."), new Param("back", false, "Back Lights", "Enables the spotlights on the back frogs."), new Param("dark", true, "Darken Stage", "Darkens the stage, allowing the spotlights to be seen."), }, defaultLength = 0.5f, }, new GameAction("mouthwide", "Open Mouth (Wide)") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Sing("Wide", e.beat + e.length - 0.5, e["blue"], e["orange"], e["greens"]); } }, parameters = new List() { new Param("blue", true, "Blue Sings", "Make Blue Frog sing during this event."), new Param("orange", false, "Orange Sings", "Make Orange Frog sing during this event."), new Param("greens", false, "Group Sings", "Make the frogs in the back sing during this event."), }, defaultLength = 0.5f, resizable = true, }, new GameAction("mouthnarrow", "Open Mouth (Narrow)") { function = delegate { var e = eventCaller.currentEntity; if (eventCaller.gameManager.minigameObj.TryGetComponent(out FrogHop instance)) { instance.Sing("Narrow", e.beat + e.length - 0.5, e["blue"], e["orange"], e["greens"]); } }, parameters = new List() { new Param("blue", true, "Blue Sings", "Make Blue Frog sing during this event."), new Param("orange", false, "Orange Sings", "Make Orange Frog sing during this event."), new Param("greens", false, "Group Sings", "Make the frogs in the back sing during this event."), }, defaultLength = 0.5f, resizable = true, }, } ); } } } namespace HeavenStudio.Games { using HeavenStudio.Games.Loaders; using Scripts_FrogHop; public class FrogHop : Minigame { //definitions #region Definitions [SerializeField] public ntrFrog PlayerFrog; [SerializeField] public List OtherFrogs = new List(); [SerializeField] public ntrFrog LeaderFrog; [SerializeField] public ntrFrog SingerFrog; [SerializeField] public GameObject Darkness; [SerializeField] public GameObject SpotlightFront; [SerializeField] public GameObject SpotlightBack; List AllFrogs = new(); List FrontFrogs = new(); List BackFrogs = new(); List whoToInputKTB = new(); int globalAnimSide = -1; double wantHop = double.MinValue; List queuedHops = new(); bool keepHopping; double startBackHop = double.MinValue; double startNoHop = double.MinValue; double startRegularHop = double.MinValue; public enum WhoBops { Front, Back, All, None, } const int IAAltDownCat = IAMAXCAT; const int IAAltUpCat = IAMAXCAT + 1; protected static bool IA_PadAltPress(out double dt) { return PlayerInput.GetPadDown(InputController.ActionsPad.South, out dt); } protected static bool IA_BatonAltPress(out double dt) { return PlayerInput.GetSqueezeDown(out dt); } protected static bool IA_PadAltRelease(out double dt) { return PlayerInput.GetPadUp(InputController.ActionsPad.South, out dt); } protected static bool IA_BatonAltRelease(out double dt) { return PlayerInput.GetSqueezeUp(out dt); } public static PlayerInput.InputAction InputAction_AltPress = new("NtrFrogHopAltPress", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat }, IA_PadAltPress, IA_TouchBasicPress, IA_BatonAltPress); public static PlayerInput.InputAction InputAction_AltRelease = new("NtrFrogHopAltRelease", new int[] { IAAltUpCat, IAFlickCat, IAAltUpCat }, IA_PadAltRelease, IA_TouchFlick, IA_BatonAltRelease); public static PlayerInput.InputAction InputAction_TouchRelease = new("NtrFrogHopTouchRelease", new int[] { IAEmptyCat, IAReleaseCat, IAEmptyCat }, IA_Empty, IA_TouchBasicRelease, IA_Empty); #endregion //global methods #region Global Methods public void Awake() { AllFrogs.Add(PlayerFrog); AllFrogs.AddRange(OtherFrogs); AllFrogs.Add(LeaderFrog); AllFrogs.Add(SingerFrog); FrontFrogs.Add(LeaderFrog); FrontFrogs.Add(SingerFrog); BackFrogs.Add(PlayerFrog); BackFrogs.AddRange(OtherFrogs); whoToInputKTB = AllFrogs; } public void LateUpdate() { //whiff stuff below //if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress)) //{ // PlayerFrog.Hop(); //} // //if (PlayerInput.GetIsAction(InputAction_AltPress) && !IsExpectingInputNow(InputAction_AltPress)) //{ // PlayerFrog.Charge(); //} // //if (PlayerInput.GetIsAction(InputAction_AltRelease) && !IsExpectingInputNow(InputAction_AltRelease)) //{ // PlayerFrog.Spin(); //} //ktb stuff below if (wantHop != double.MinValue) { queuedHops.Add(wantHop); keepHopping = true; wantHop = double.MinValue; } if (Conductor.instance.isPlaying && !Conductor.instance.isPaused) { if (queuedHops.Count > 0) { foreach (var hop in queuedHops) { var actions = new List(); bool betweenHopValues = hop + 1 < startRegularHop && hop + 1 >= startNoHop; if (!betweenHopValues) ScheduleInput(hop, 1, InputAction_BasicPress, PlayerHopNormal, PlayerMiss, Nothing); betweenHopValues = hop + 1 < startRegularHop && hop + 1 >= startNoHop; if (!betweenHopValues) actions.Add(new BeatAction.Action(hop + 1, delegate { NPCHop(BackFrogs); })); betweenHopValues = hop + 1 < startRegularHop && hop + 1 >= startBackHop; if (!betweenHopValues) actions.Add(new BeatAction.Action(hop + 1, delegate { betweenHopValues = hop + 1 < startRegularHop && hop + 1 >= startBackHop; if (!betweenHopValues) { NPCHop(FrontFrogs); SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_E_BEAT"); } })); if (keepHopping) actions.Add(new BeatAction.Action(hop, delegate { queuedHops.Add(hop + 1); })); BeatAction.New(this, actions); } queuedHops.Clear(); } } } #endregion //frog hop methods #region Frog Hop Methods public void Bop(double beat, float length, int bop) { var bopInterp = new List(); switch (bop) { case 0: bopInterp = FrontFrogs; break; case 1: bopInterp = BackFrogs; break; case 2: bopInterp = AllFrogs; break; default: break; } var actions = new List(); for (int i = 0; i < length; i++) { actions.Add(new(beat + i, delegate { BopAnimation(bopInterp); })); } BeatAction.New(this, actions); } public void BopAnimation(List FrogsToBop) { foreach (var a in FrogsToBop) { a.Bop(); } } public void Count(double beat, bool start) { var actions = new List(); var sounds = new List(); actions.Add(new(beat + 0.0, delegate { Talk(new List() { LeaderFrog }, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_COUNT1", beat + 0.0)); actions.Add(new(beat + 1.0, delegate { Talk(new List() { LeaderFrog }, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_COUNT2", beat + 1.0)); actions.Add(new(beat + 2.0, delegate { Talk(new List() { LeaderFrog }, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_COUNT3", beat + 2.0)); actions.Add(new(beat + 3.0, delegate { Talk(new List() { LeaderFrog }, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_COUNT4", beat + 3.0)); BeatAction.New(this, actions); MultiSound.Play(sounds); if (start) Hop(beat + 4.0); } public void Hop (double beat) { wantHop = beat - 1; } public void TwoHop (double beat, bool spotlights) { CueCommon(beat, spotlights); var actions = new List(); var sounds = new List(); //call actions.Add(new(beat + 0.0, delegate { NPCHop(FrontFrogs); Talk(new List() { LeaderFrog }, "Wide", beat); })); actions.Add(new(beat + 0.5, delegate { NPCHop(FrontFrogs, true); Talk(new List() { LeaderFrog }, "Narrow", beat + 1.5); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_HA", beat)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_POP_DEFAULT", beat)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_HAAI", beat + 0.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_POP_HAAI", beat + 0.5)); //response actions.Add(new(beat + 2.0, delegate { NPCHop(BackFrogs); Talk(BackFrogs, "Wide", beat); })); actions.Add(new(beat + 2.5, delegate { NPCHop(BackFrogs, true); Talk(BackFrogs, "Narrow", beat + 3.5); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_HA", beat + 2.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_HAAI", beat + 2.5)); //inputs ScheduleInput(beat, 2.0, InputAction_BasicPress, PlayerHopYa, PlayerMiss, Nothing); ScheduleInput(beat, 2.5, InputAction_BasicPress, PlayerHopHoo, PlayerMiss, Nothing); BeatAction.New(this, actions); MultiSound.Play(sounds); } public void ThreeHop (double beat, bool spotlights) { CueCommon(beat, spotlights); var actions = new List(); var sounds = new List(); //call actions.Add(new(beat + 0.0, delegate { NPCHop(FrontFrogs); Talk(new List() { LeaderFrog }, "Narrow", beat); })); actions.Add(new(beat + 0.5, delegate { NPCHop(FrontFrogs); Talk(new List() { LeaderFrog }, "Narrow", beat); })); actions.Add(new(beat + 1.0, delegate { NPCHop(FrontFrogs, true); Talk(new List() { LeaderFrog }, "Narrow", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_HAI", beat)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_POP_DEFAULT", beat)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_HAI", beat + 0.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_POP_DEFAULT", beat + 0.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_HAI", beat + 1.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_POP_DEFAULT", beat + 1.0)); //response actions.Add(new(beat + 2.0, delegate { NPCHop(BackFrogs); Talk(BackFrogs, "Narrow", beat); })); actions.Add(new(beat + 2.5, delegate { NPCHop(BackFrogs); Talk(BackFrogs, "Narrow", beat); })); actions.Add(new(beat + 3.0, delegate { NPCHop(BackFrogs, true); Talk(BackFrogs, "Narrow", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_HAI", beat + 2.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_HAI", beat + 2.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_HAI", beat + 3.0)); //inputs ScheduleInput(beat, 2.0, InputAction_BasicPress, PlayerHopYeah, PlayerMiss, Nothing); ScheduleInput(beat, 2.5, InputAction_BasicPress, PlayerHopYeah, PlayerMiss, Nothing); ScheduleInput(beat, 3.0, InputAction_BasicPress, PlayerHopYeahAccent, PlayerMiss, Nothing); BeatAction.New(this, actions); MultiSound.Play(sounds); } public void SpinItBoys (double beat, bool spotlights) { CueCommon(beat, spotlights); var actions = new List(); var sounds = new List(); //call actions.Add(new(beat + 0.0, delegate { NPCCharge(FrontFrogs); Talk(new List() { LeaderFrog }, "Narrow", beat); })); actions.Add(new(beat + 1.0, delegate { NPCSpin(FrontFrogs); Talk(new List() { LeaderFrog }, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_KURU_1", beat)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_KURU_2", beat + 0.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_LIN", beat + 1.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_T_SPIN", beat + 1.0)); //response actions.Add(new(beat + 2.0, delegate { NPCCharge(BackFrogs); Talk(BackFrogs, "Narrow", beat); })); actions.Add(new(beat + 3.0, delegate { NPCSpin(BackFrogs); Talk(BackFrogs, "Wide", beat); })); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_KURU_1", beat + 2.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_KURU_2", beat + 2.5)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_LIN", beat + 3.0)); sounds.Add(new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_E_SPIN", beat + 3.0)); //inputs ScheduleInput(beat, 2.0, InputAction_AltPress, PlayerHopCharge, PlayerMiss, Nothing); ScheduleInput(beat, 3.0, InputAction_AltRelease, PlayerSpin, PlayerMiss, Nothing); BeatAction.New(this, actions); MultiSound.Play(sounds); } public void CueCommon(double beat, bool spotlights = true) { startBackHop = beat; startNoHop = beat + 2; startRegularHop = beat + 4; if (!spotlights) return; var actions = new List(); actions.Add(new(beat + 1.5, delegate { Spotlights(false, true); })); actions.Add(new(beat + 3.5, delegate { Spotlights(true, false); })); BeatAction.New(this, actions); } public void Spotlights(bool front, bool back, bool dark = true) { foreach (var a in FrontFrogs) { a.Darken(front || !dark); } Darkness.SetActive(dark); SpotlightFront.SetActive(front); SpotlightBack.SetActive(back); } public void NPCHop(List FrogsToHop, bool isThisLong = false) { foreach (var a in FrogsToHop) { if (a != PlayerFrog) a.Hop(isLong: isThisLong); } } public void NPCCharge(List FrogsToHop) { foreach (var a in FrogsToHop) { if (a != PlayerFrog) a.Charge(); } } public void NPCSpin(List FrogsToHop) { foreach (var a in FrogsToHop) { if (a != PlayerFrog) a.Spin(); } } public void PlayerHopNormal(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_BEAT"); PlayerHop(); } public void PlayerHopYa(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_HA"); SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_POP_DEFAULT"); PlayerHop(); } public void PlayerHopHoo(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_HAAI"); SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_POP_HAAI"); PlayerHop(true); } public void PlayerHopYeah(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_HAI"); SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_POP_DEFAULT"); PlayerHop(); } public void PlayerHopYeahAccent(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_HAI"); SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_POP_DEFAULT"); PlayerHop(true); } public void PlayerHop(bool isLong = false) { globalAnimSide *= -1; PlayerFrog.Hop(globalAnimSide, isLong); } public void PlayerHopCharge(PlayerActionEvent caller, float state) { double beat = caller.startBeat + caller.timer; MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_P_KURU_1", beat), new MultiSound.Sound("frogHop/SE_NTR_FROG_EN_P_KURU_2", beat + 0.5) }); globalAnimSide *= -1; PlayerFrog.Charge(globalAnimSide); } public void PlayerSpin(PlayerActionEvent caller, float state) { SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_P_LIN"); PlayerFrog.Spin(); } public void PlayerMiss(PlayerActionEvent caller) { globalAnimSide *= -1; } public void Nothing(PlayerActionEvent caller) { } public void Talk(List FrogsToTalk, string syllable, double animEnd) { foreach (var a in FrogsToTalk) { a.Talk(syllable, animEnd); } } public void Sing(string syllable, double animEnd, bool blue, bool orange, bool greens) { var FrogsToTalk = new List(); if (blue) FrogsToTalk.Add(SingerFrog); if (orange) FrogsToTalk.Add(LeaderFrog); if (greens) FrogsToTalk.AddRange(BackFrogs); Talk(FrogsToTalk, syllable, animEnd); } #endregion } }