From 3f2cc123cb86d1c90fe78e9d89cfe188c7d6d573 Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Sun, 6 Mar 2022 14:37:50 -0500 Subject: [PATCH] Fully functional and animated Mr. Upbeat --- Assets/Resources/Games/mrUpbeat.prefab | 184 ++++++++++++++++-- .../Games/MrUpbeat/Animations/Fall.anim | 49 ++++- .../Games/MrUpbeat/Animations/Idle.anim | 65 ++++++- .../Games/MrUpbeat/Animations/Step.anim | 63 ++++++ .../Games/MrUpbeat/mrupbeat_main.png.meta | 25 ++- Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs | 47 +++-- Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs | 71 +++---- Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs | 66 +++++++ .../Scripts/Games/MrUpbeat/UpbeatStep.cs.meta | 11 ++ Assets/Scripts/Minigames.cs | 2 +- 10 files changed, 504 insertions(+), 79 deletions(-) create mode 100644 Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs create mode 100644 Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta diff --git a/Assets/Resources/Games/mrUpbeat.prefab b/Assets/Resources/Games/mrUpbeat.prefab index a3867d42..15f17838 100644 --- a/Assets/Resources/Games/mrUpbeat.prefab +++ b/Assets/Resources/Games/mrUpbeat.prefab @@ -646,6 +646,62 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &5666021292044047195 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7622419266367956722} + - component: {fileID: 4157362534770189002} + m_Layer: 0 + m_Name: Beat + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &7622419266367956722 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5666021292044047195} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 8301537147055126447} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &4157362534770189002 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5666021292044047195} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 671722aab5d7ff34da139a076534caf4, type: 3} + m_Name: + m_EditorClassIdentifier: + inList: 0 + lastState: 0 + state: + gameObject: {fileID: 0} + early: 0 + perfect: 0 + late: 0 + createBeat: 0 + eligibleHitsList: [] + aceTimes: 0 + isEligible: 0 + triggersAutoplay: 1 + startBeat: 0 --- !u!1 &6060117916978306099 GameObject: m_ObjectHideFlags: 0 @@ -761,6 +817,7 @@ Transform: - {fileID: 3332517713256108722} - {fileID: 5608637247423934025} - {fileID: 8709428748473264351} + - {fileID: 2744998194819868968} m_Father: {fileID: 1584121333826078951} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -929,6 +986,7 @@ Transform: - {fileID: 8701843541313247389} - {fileID: 7821851253613277009} - {fileID: 862280508089709600} + - {fileID: 8301537147055126447} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -948,6 +1006,7 @@ MonoBehaviour: firstEnable: 0 metronome: {fileID: 3862020474253857803} man: {fileID: 8160414645038680372} + bt: {fileID: 5666021292044047195} canGo: 0 beatCount: 0 --- !u!1 &8412912829583803381 @@ -1078,18 +1137,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e4fa18aec69a2e949a7e2d4e33bdd2b9, type: 3} m_Name: m_EditorClassIdentifier: - inList: 0 - lastState: 0 - state: - gameObject: {fileID: 0} - early: 0 - perfect: 0 - late: 0 - createBeat: 0 - eligibleHitsList: [] - aceTimes: 0 - isEligible: 0 - triggersAutoplay: 1 game: {fileID: 8728962026160321644} animator: {fileID: 2256168985014220240} blipAnimator: {fileID: 1614535701461294964} @@ -1098,6 +1145,88 @@ MonoBehaviour: - {fileID: 2066794384027118212} targetBeat: 0.25 stepTimes: 0 +--- !u!1 &8959999179820051615 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2744998194819868968} + - component: {fileID: 4164580634482561143} + m_Layer: 0 + m_Name: ShadowFall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &2744998194819868968 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8959999179820051615} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.523, y: 0.016, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1584116570229233278} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &4164580634482561143 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8959999179820051615} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: -2 + m_Sprite: {fileID: -5599596391108488658, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1.9583334, y: 1.6041666} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 --- !u!1 &8963803634876878173 GameObject: m_ObjectHideFlags: 0 @@ -1180,3 +1309,34 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &9090607052953291167 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8301537147055126447} + m_Layer: 0 + m_Name: Beats + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8301537147055126447 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9090607052953291167} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7622419266367956722} + m_Father: {fileID: 7248900333300803150} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Fall.anim b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Fall.anim index 5321ce29..57c61b70 100644 --- a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Fall.anim +++ b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Fall.anim @@ -116,6 +116,25 @@ AnimationClip: path: Body/FallFX classID: 1 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_PPtrCurves: - curve: - time: 0 @@ -123,7 +142,7 @@ AnimationClip: - time: 0.016666668 value: {fileID: 7267509016467870925, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - time: 0.033333335 - value: {fileID: -5599596391108488658, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} + value: {fileID: 4385344229349358626, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - time: 0.05 value: {fileID: -3983884386284601651, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} attribute: m_Sprite @@ -167,6 +186,13 @@ AnimationClip: typeID: 1 customType: 0 isPPtrCurve: 0 + - serializedVersion: 2 + path: 326924850 + attribute: 2086281974 + script: {fileID: 0} + typeID: 1 + customType: 0 + isPPtrCurve: 0 - serializedVersion: 2 path: 2073732236 attribute: 0 @@ -184,7 +210,7 @@ AnimationClip: pptrCurveMapping: - {fileID: 910123527689434379, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - {fileID: 7267509016467870925, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - - {fileID: -5599596391108488658, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} + - {fileID: 4385344229349358626, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - {fileID: -3983884386284601651, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - {fileID: 442070513753258848, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} - {fileID: -1641719250182597347, guid: 2781bda31bd88924b9bc88f6c301b1d9, type: 3} @@ -367,6 +393,25 @@ AnimationClip: path: Body/FallFX classID: 1 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Idle.anim b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Idle.anim index 2e6e7c3e..fa78bcd2 100644 --- a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Idle.anim +++ b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Idle.anim @@ -41,7 +41,35 @@ AnimationClip: m_RotationOrder: 4 path: Head m_ScaleCurves: [] - m_FloatCurves: [] + m_FloatCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.016666668 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_PPtrCurves: - curve: - time: 0 @@ -57,6 +85,13 @@ AnimationClip: m_Extent: {x: 0, y: 0, z: 0} m_ClipBindingConstant: genericBindings: + - serializedVersion: 2 + path: 326924850 + attribute: 2086281974 + script: {fileID: 0} + typeID: 1 + customType: 0 + isPPtrCurve: 0 - serializedVersion: 2 path: 2073732236 attribute: 0 @@ -178,6 +213,34 @@ AnimationClip: path: Head classID: 4 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.016666668 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Step.anim b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Step.anim index e6cf676b..c9709d5e 100644 --- a/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Step.anim +++ b/Assets/Resources/Sprites/Games/MrUpbeat/Animations/Step.anim @@ -125,6 +125,34 @@ AnimationClip: path: Body/StepSmearFoot classID: 1 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.050000004 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_PPtrCurves: - curve: - time: 0 @@ -165,6 +193,13 @@ AnimationClip: typeID: 1 customType: 0 isPPtrCurve: 0 + - serializedVersion: 2 + path: 326924850 + attribute: 2086281974 + script: {fileID: 0} + typeID: 1 + customType: 0 + isPPtrCurve: 0 - serializedVersion: 2 path: 2073732236 attribute: 0 @@ -382,6 +417,34 @@ AnimationClip: path: Body/StepSmearFoot classID: 1 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 0.050000004 + value: 0 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_IsActive + path: Body/ShadowFall + classID: 1 + script: {fileID: 0} m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/Resources/Sprites/Games/MrUpbeat/mrupbeat_main.png.meta b/Assets/Resources/Sprites/Games/MrUpbeat/mrupbeat_main.png.meta index 20fa8bba..f92edb38 100644 --- a/Assets/Resources/Sprites/Games/MrUpbeat/mrupbeat_main.png.meta +++ b/Assets/Resources/Sprites/Games/MrUpbeat/mrupbeat_main.png.meta @@ -61,10 +61,10 @@ TextureImporter: second: mrupbeat_fall_1 - first: 213: -5599596391108488658 - second: mrupbeat_fall_2 + second: mrupbeat_shadow_fall - first: 213: -1109266650601169752 - second: mrupbeat_fall_2 + second: mrupbeat_shadow_fall - first: 213: -3983884386284601651 second: mrupbeat_fall_3 @@ -597,6 +597,27 @@ TextureImporter: indices: edges: [] weights: [] + - serializedVersion: 2 + name: mrupbeat_shadow_fall + rect: + serializedVersion: 2 + x: 353 + y: 209 + width: 102 + height: 37 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + outline: [] + physicsShape: [] + tessellationDetail: 0 + bones: [] + spriteID: e225b6e00cc3a42b0800000000000000 + internalID: -5599596391108488658 + vertices: [] + indices: + edges: [] + weights: [] outline: [] physicsShape: [] bones: [] diff --git a/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs b/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs index db3d939f..7dc05292 100644 --- a/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs +++ b/Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs @@ -13,9 +13,9 @@ namespace RhythmHeavenMania.Games.MrUpbeat [Header("References")] public GameObject metronome; public UpbeatMan man; + public GameObject bt; public GameEvent beat = new GameEvent(); - public GameEvent offbeat = new GameEvent(); public bool canGo = false; public int beatCount = 0; @@ -31,12 +31,14 @@ namespace RhythmHeavenMania.Games.MrUpbeat canGo = false; man.stepTimes = 0; SetInterval(0); + var pos = Conductor.instance.songPositionInBeats; + StartCoroutine(Upbeat(pos - Mathf.Round(pos))); } private void Update() { List gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go"); - for(int i=0; i Conductor.instance.songPositionInBeats) { @@ -53,27 +55,24 @@ namespace RhythmHeavenMania.Games.MrUpbeat metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * Conductor.instance.songPositionInBeats) * 75); } - if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat) && canGo) + if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat)) { - if(beatCount % 2 == 0) - Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight"); - else - Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft"); + StartCoroutine(Upbeat()); + if (canGo) + { + if (beatCount % 2 == 0) + Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight"); + else + Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft"); - beatCount++; - } - - if (Conductor.instance.ReportBeat(ref offbeat.lastReportedBeat, 0.25f, true)) - { - man.Blip(); - if(canGo) man.targetBeat = offbeat.lastReportedBeat + 1f; + Beat(Mathf.Round(Conductor.instance.songPositionInBeats)); + } } } public void SetInterval(float beat) { beatCount = 0; - offbeat.startBeat = beat; man.targetBeat = beat + 320f; man.Idle(); } @@ -82,7 +81,23 @@ namespace RhythmHeavenMania.Games.MrUpbeat { beatCount = 0; } - + + public void Beat(float beat) + { + beatCount++; + + GameObject _beat = Instantiate(bt); + _beat.transform.parent = bt.transform.parent; + _beat.SetActive(true); + UpbeatStep s = _beat.GetComponent(); + s.startBeat = beat; + } + + private IEnumerator Upbeat(float offset = 0) + { + yield return new WaitForSeconds(Conductor.instance.secPerBeat * 0.5f - offset); + man.Blip(); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs b/Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs index c1331f63..bc0b537a 100644 --- a/Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs +++ b/Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs @@ -8,7 +8,7 @@ using RhythmHeavenMania.Util; namespace RhythmHeavenMania.Games.MrUpbeat { - public class UpbeatMan : PlayerActionObject + public class UpbeatMan : MonoBehaviour { [Header("References")] public MrUpbeat game; @@ -19,48 +19,18 @@ namespace RhythmHeavenMania.Games.MrUpbeat public float targetBeat = 0.25f; public int stepTimes = 0; private bool stepped = false; + private bool onGround = false; public GameEvent blip = new GameEvent(); private void Update() { - float normalizedBeat = Conductor.instance.GetPositionFromMargin(targetBeat, 0.5f); - StateCheck(normalizedBeat); - - if(game.canGo && normalizedBeat > Minigame.LateTime()) - { - if ((game.beatCount % 2 == 0 && stepTimes % 2 == 0) || (game.beatCount % 2 == 1 && stepTimes % 2 == 1)) - { - Fall(); - } - targetBeat += 100f; - return; - } - if (PlayerInput.Pressed()) { - if (state.perfect) - { - Step(); - } - else if(state.notPerfect()) - { - Fall(); - } - else - { - Step(); - } + Step(); } } - public override void OnAce() - { - if (!game.canGo) return; - - Step(); - } - public void Idle() { stepTimes = 0; @@ -75,6 +45,29 @@ namespace RhythmHeavenMania.Games.MrUpbeat animator.Play("Step", 0, 0); Jukebox.PlayOneShotGame("mrUpbeat/step"); + onGround = false; + CheckShadows(); + } + + public void Fall() + { + animator.Play("Fall", 0, 0); + Jukebox.PlayOneShot("miss"); + shadows[0].SetActive(false); + shadows[1].SetActive(false); + onGround = true; + } + + public void Blip() + { + Jukebox.PlayOneShotGame("mrUpbeat/blip"); + blipAnimator.Play("Blip", 0, 0); + } + + private void CheckShadows() + { + if (onGround) return; + if (stepTimes % 2 == 1) { shadows[0].SetActive(false); @@ -87,18 +80,6 @@ namespace RhythmHeavenMania.Games.MrUpbeat transform.localScale = new Vector3(1, 1); } } - - public void Fall() - { - animator.Play("Fall", 0, 0); - Jukebox.PlayOneShot("miss"); - } - - public void Blip() - { - Jukebox.PlayOneShotGame("mrUpbeat/blip"); - blipAnimator.Play("Blip", 0, 0); - } } diff --git a/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs new file mode 100644 index 00000000..f0b1d1f0 --- /dev/null +++ b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs @@ -0,0 +1,66 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using System; +using Starpelly; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania.Games.MrUpbeat +{ + public class UpbeatStep : PlayerActionObject + { + public float startBeat; + private bool passedFirst = false; + + private void Start() + { + PlayerActionInit(gameObject, startBeat); + } + + public override void OnAce() + { + Hit(true, true); + } + + private void Update() + { + if (Conductor.instance.GetPositionFromBeat(startBeat, 0.35f) >= 1 && !passedFirst) + { + if(MrUpbeat.instance.man.stepTimes % 2 != startBeat % 2) + Hit(false); + passedFirst = true; + } + if (Conductor.instance.GetPositionFromBeat(startBeat, 0.65f) >= 1) + Hit(false); + + float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 0.5f); + StateCheck(normalizedBeat); + + if (PlayerInput.Pressed()) + { + if (state.perfect) + { + Hit(true); + } else if (state.notPerfect()) + { + Hit(false); + } + } + } + + public void Hit(bool hit, bool force = false) + { + if (force) MrUpbeat.instance.man.Step(); + else if (!hit) MrUpbeat.instance.man.Fall(); + + CleanUp(); + } + + public void CleanUp() + { + Destroy(this.gameObject); + } + + } +} \ No newline at end of file diff --git a/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta new file mode 100644 index 00000000..3363988b --- /dev/null +++ b/Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 671722aab5d7ff34da139a076534caf4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 4959dabb..4e261e6a 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -374,7 +374,7 @@ namespace RhythmHeavenMania new GameAction("start interval", delegate { WizardsWaltz.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true), new GameAction("plant", delegate { WizardsWaltz.instance.SpawnFlower(eventCaller.currentEntity.beat); }, 0.5f, false), }), - new Minigame("mrUpbeat", "Mr. Upbeat \n[WIP don't use]", "FFFFFF", false, false, new List() + new Minigame("mrUpbeat", "Mr. Upbeat", "FFFFFF", false, false, new List() { new GameAction("prepare", delegate { MrUpbeat.instance.SetInterval(eventCaller.currentEntity.beat); }, 0.5f, true), new GameAction("go", delegate { MrUpbeat.instance.Go(eventCaller.currentEntity.beat); }, 4f, true),