diff --git a/Assets/Resources/Sprites/Games/DJSchool/Animations/Student/Student.controller b/Assets/Resources/Sprites/Games/DJSchool/Animations/Student/Student.controller index 0c5a5195..24405366 100644 --- a/Assets/Resources/Sprites/Games/DJSchool/Animations/Student/Student.controller +++ b/Assets/Resources/Sprites/Games/DJSchool/Animations/Student/Student.controller @@ -52,6 +52,33 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1102 &-1143804635325942891 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Unhold + m_Speed: -1 + m_CycleOffset: 0 + m_Transitions: + - {fileID: 5013820772242190312} + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 3958816d51b511b4a9c0505c45de204a, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1101 &-295531023391595954 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -148,6 +175,28 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1101 &5013820772242190312 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: [] + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: -4698968861401447970} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0 + m_HasExitTime: 1 + m_HasFixedDuration: 0 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1107 &6962450605454016305 AnimatorStateMachine: serializedVersion: 6 @@ -159,7 +208,7 @@ AnimatorStateMachine: m_ChildStates: - serializedVersion: 1 m_State: {fileID: -7055007684483605004} - m_Position: {x: 430, y: -30, z: 0} + m_Position: {x: 490, y: -90, z: 0} - serializedVersion: 1 m_State: {fileID: 1884598382658345919} m_Position: {x: 580, y: -160, z: 0} @@ -172,6 +221,9 @@ AnimatorStateMachine: - serializedVersion: 1 m_State: {fileID: 7914765862687888288} m_Position: {x: 330, y: -170, z: 0} + - serializedVersion: 1 + m_State: {fileID: -1143804635325942891} + m_Position: {x: 490, y: -30, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 7177ac81..95a4e584 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -124,8 +124,8 @@ namespace RhythmHeavenMania } } - // LateUpdate works a bit better but causes a bit of bugs, so remind me to fix those eventually - private void LateUpdate() + // LateUpdate works a bit better(?) but causes some bugs (like issues with bop animations). + private void Update() { if (Beatmap.entities.Count < 1) return; diff --git a/Assets/Scripts/Games/DJSchool/DJSchool.cs b/Assets/Scripts/Games/DJSchool/DJSchool.cs index a5f2f3fb..86c6d14f 100644 --- a/Assets/Scripts/Games/DJSchool/DJSchool.cs +++ b/Assets/Scripts/Games/DJSchool/DJSchool.cs @@ -7,6 +7,13 @@ namespace RhythmHeavenMania.Games.DJSchool { public class DJSchool : Minigame { + public enum DJVoice + { + Standard, + Cool, + Hyped + } + [Header("Components")] [SerializeField] private Student student; [SerializeField] private GameObject djYellow; @@ -32,9 +39,11 @@ namespace RhythmHeavenMania.Games.DJSchool private void Update() { - if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1)) + var cond = Conductor.instance; + + if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1)) { - if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length) + if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length) { if (student.anim.IsAnimationNotPlaying()) { @@ -49,6 +58,12 @@ namespace RhythmHeavenMania.Games.DJSchool } if (djYellowAnim.IsAnimationNotPlaying()) { + var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0); + if (yellowState.IsName("Hey")) + { + PostScratchoFace(); + } + if (djYellowHolding) { djYellowAnim.Play("HoldBop", 0, 0); @@ -75,20 +90,18 @@ namespace RhythmHeavenMania.Games.DJSchool string[] sounds = new string[] { }; - if (type == 0) + switch (type) { - sounds = new string[] { "djSchool/breakCmon1", "djSchool/breakCmon2", "djSchool/ooh" }; + case 0: + sounds = new string[] { "djSchool/breakCmon1", "djSchool/breakCmon2", "djSchool/ooh" }; + break; + case 1: + sounds = new string[] { "djSchool/breakCmonAlt1", "djSchool/breakCmonAlt2", "djSchool/oohAlt" }; + break; + case 2: + sounds = new string[] { "djSchool/breakCmonLoud1", "djSchool/breakCmonLoud2", "djSchool/oohLoud" }; + break; } - else if (type == 1) - { - sounds = new string[] { "djSchool/breakCmonAlt1", "djSchool/breakCmonAlt2", "djSchool/oohAlt" }; - } - else if (type == 2) - { - SetDJYellowHead(2); - sounds = new string[] { "djSchool/breakCmonLoud1", "djSchool/breakCmonLoud2", "djSchool/oohLoud" }; - } - MultiSound.Play(new MultiSound.Sound[] { @@ -105,11 +118,11 @@ namespace RhythmHeavenMania.Games.DJSchool { djYellow.GetComponent().Play("Hold", 0, 0); djYellowHolding = true; - SetDJYellowHead(1); }), }); student.holdBeat = beat; + student.eligible = true; student.ResetState(); } @@ -131,11 +144,11 @@ namespace RhythmHeavenMania.Games.DJSchool { djYellow.GetComponent().Play("Hold", 0, 0); djYellowHolding = true; - SetDJYellowHead(1); }), }); student.holdBeat = beat - 0.5f; + student.eligible = true; student.ResetState(); } @@ -177,12 +190,44 @@ namespace RhythmHeavenMania.Games.DJSchool }); student.swipeBeat = beat; + student.eligible = true; student.ResetState(); } - private void SetDJYellowHead(int type) + public void SetDJYellowHead(int type, bool resetAfterBeats = false) { headSprite.sprite = headSprites[type]; + + if (resetAfterBeats) + { + BeatAction.New(djYellow, new List() + { + new BeatAction.Action(Mathf.Floor(Conductor.instance.songPositionInBeats) + 2f, delegate + { + var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0); + if (yellowState.IsName("Idle") + || yellowState.IsName("IdleBop") + || yellowState.IsName("IdleBop2") + || yellowState.IsName("BreakCmon")) + { + SetDJYellowHead(0); + } + }) + }); + } + } + + public void PostScratchoFace() + { + if (student.missed) + { + student.missed = false; + SetDJYellowHead(3, true); + } + else + { + SetDJYellowHead(2, true); + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/DJSchool/Student.cs b/Assets/Scripts/Games/DJSchool/Student.cs index 8fe7b805..79d925fc 100644 --- a/Assets/Scripts/Games/DJSchool/Student.cs +++ b/Assets/Scripts/Games/DJSchool/Student.cs @@ -16,6 +16,9 @@ namespace RhythmHeavenMania.Games.DJSchool public float holdBeat; public float swipeBeat; public bool isHolding; + public bool shouldBeHolding; + public bool eligible; + public bool missed; [Header("Components")] [SerializeField] private SpriteRenderer flash; @@ -24,49 +27,88 @@ namespace RhythmHeavenMania.Games.DJSchool [SerializeField] private GameObject TurnTable; [SerializeField] private GameObject slamFX; + private Animator tableAnim; + + private DJSchool game; + private void Start() { + game = DJSchool.instance; anim = GetComponent(); - TurnTable.GetComponent().speed = 0; + tableAnim = TurnTable.GetComponent(); + tableAnim.speed = 0; } private void Update() { - if (!isHolding) + float beatToUse = shouldBeHolding ? swipeBeat : holdBeat; + float normalizedBeat = Conductor.instance.GetPositionFromMargin(beatToUse + 2, 1); + + if (eligible) { - float normalizedBeatHold = Conductor.instance.GetPositionFromBeat(holdBeat, 2); + StateCheck(normalizedBeat); - StateCheck(normalizedBeatHold); - - if (PlayerInput.Pressed()) + if (normalizedBeat > Minigame.LateTime()) { - if (state.perfect) + eligible = false; + missed = true; + + if (shouldBeHolding) { - Hold(true); + shouldBeHolding = false; } else { - Hold(false); + shouldBeHolding = true; + game.SetDJYellowHead(3); } } } - else if (isHolding) + + if (!isHolding) { - float normalizedBeatSwipe = Conductor.instance.GetPositionFromBeat(swipeBeat, 2); - - StateCheck(normalizedBeatSwipe); - - print(normalizedBeatSwipe); ; - - if (PlayerInput.PressedUp()) + if (PlayerInput.Pressed()) { - if (state.perfect) + if (!shouldBeHolding && state.perfect && eligible) { - Swipe(); + Hold(true); + eligible = false; } else { - UnHold(); + if (!shouldBeHolding) + eligible = false; + + Hold(false); + + missed = true; + game.SetDJYellowHead(3, true); + } + } + } + else + { + if (PlayerInput.PressedUp()) + { + if (shouldBeHolding && state.perfect && eligible) + { + Swipe(true); + eligible = false; + } + else + { + if (shouldBeHolding) + { + Swipe(false); + eligible = false; + } + else + { + UnHold(); + } + + missed = true; + game.SetDJYellowHead(3); } } } @@ -75,6 +117,13 @@ namespace RhythmHeavenMania.Games.DJSchool public void Hold(bool ace) { isHolding = true; + + if (ace) + { + missed = false; + shouldBeHolding = true; + game.SetDJYellowHead(1); + } Jukebox.PlayOneShotGame("djSchool/recordStop"); anim.Play("Hold", 0, 0); @@ -91,29 +140,51 @@ namespace RhythmHeavenMania.Games.DJSchool { isHolding = false; - anim.speed = -1; - anim.Play("Hold", 0, 0); + anim.Play("Unhold", 0, 0); // Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f); } - public void Swipe() + public void Swipe(bool ace) { isHolding = false; + + if (ace) + { + missed = false; + shouldBeHolding = false; + Jukebox.PlayOneShotGame("djSchool/recordSwipe"); + FlashFX(false); + } + else + { + // Missed record swipe sound should play here. + } - Jukebox.PlayOneShotGame("djSchool/recordSwipe"); anim.Play("Swipe", 0, 0); - FlashFX(false); - - TurnTable.GetComponent().speed = 1; - TurnTable.GetComponent().Play("Student_Turntable_Swipe", 0, 0); + tableAnim.speed = 1; + tableAnim.Play("Student_Turntable_Swipe", 0, 0); Instantiate(slamFX).SetActive(true); // Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f); } + public override void OnAce() + { + if (!shouldBeHolding) + { + Hold(true); + } + else + { + Swipe(true); + } + + eligible = false; + } + private void FlashFX(bool inverse) { GameObject prefab = flashFX; diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 2bb316da..bcaf01af 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -191,11 +191,11 @@ namespace RhythmHeavenMania new GameAction("and stop ooh", delegate { DJSchool.instance.AndStop(eventCaller.currentEntity.beat); }, 2.5f), new GameAction("break c'mon ooh", delegate { DJSchool.instance.BreakCmon(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 3f, false, new List() { - new Param("type", new EntityTypes.Integer(0, 2, 0), "Type"), + new Param("type", DJSchool.DJVoice.Standard, "Voice"), }), new GameAction("scratch-o hey", delegate { DJSchool.instance.ScratchoHey(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 3f, false, new List() { - new Param("type", new EntityTypes.Integer(0, 2, 0), "Type"), + new Param("type", DJSchool.DJVoice.Standard, "Voice"), }), }), new Minigame("rhythmTweezers", "Rhythm Tweezers", "98b389", false, false, new List()