From 7db74c03c7b3db35e2c735e1dd55fc613035440c Mon Sep 17 00:00:00 2001 From: AstrlJelly Date: Tue, 19 Dec 2023 18:30:19 -0500 Subject: [PATCH] cart guy is awesome. and tack reaction. :cat: :cat: :cat: :cat: :cat: --- .../Cart Guy/CartGuyParent.controller | 33 +- .../Animations/Cart Guy/CartguyMoveLeft.anim | 285 ++++++++++++++++++ .../Cart Guy/CartguyMoveLeft.anim.meta | 8 + ...CartguyMove.anim => CartguyMoveRight.anim} | 136 ++++++++- ...e.anim.meta => CartguyMoveRight.anim.meta} | 0 .../Animations/Tack/Tack.controller | 29 ++ Assets/Scripts/Games/MeatGrinder/Meat.cs | 30 +- .../Scripts/Games/MeatGrinder/MeatGrinder.cs | 82 +++-- 8 files changed, 553 insertions(+), 50 deletions(-) create mode 100644 Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim create mode 100644 Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim.meta rename Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/{CartguyMove.anim => CartguyMoveRight.anim} (55%) rename Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/{CartguyMove.anim.meta => CartguyMoveRight.anim.meta} (100%) diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartGuyParent.controller b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartGuyParent.controller index de7ae2687..91371e99d 100644 --- a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartGuyParent.controller +++ b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartGuyParent.controller @@ -1,5 +1,31 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1102 &-9008917868659873937 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: MoveLeft + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + 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: 77aa89fd26040bc44851871d6dc2e147, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1107 &-4704827389909949502 AnimatorStateMachine: serializedVersion: 6 @@ -14,7 +40,10 @@ AnimatorStateMachine: m_Position: {x: 270, y: 50, z: 0} - serializedVersion: 1 m_State: {fileID: -920925156090114162} - m_Position: {x: 270, y: 110, z: 0} + m_Position: {x: 160, y: 110, z: 0} + - serializedVersion: 1 + m_State: {fileID: -9008917868659873937} + m_Position: {x: 380, y: 110, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -58,7 +87,7 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Move + m_Name: MoveRight m_Speed: 1 m_CycleOffset: 0 m_Transitions: [] diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim new file mode 100644 index 000000000..0aa41f36a --- /dev/null +++ b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim @@ -0,0 +1,285 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CartguyMoveLeft + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: {x: 15, y: -4.5, z: 0.07427993} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: -31.5, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 1 + value: {x: -16.5, y: -4.5, z: 0.07427993} + inSlope: {x: -31.5, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: CartGuy + m_ScaleCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: {x: -1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 1 + value: {x: -1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: CartGuy + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 1110194031 + attribute: 1 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + - serializedVersion: 2 + path: 1110194031 + attribute: 3 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 15 + inSlope: 0 + outSlope: -31.5 + tangentMode: 69 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: -16.5 + inSlope: -31.5 + outSlope: 0 + tangentMode: 69 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.x + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: -4.5 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: -4.5 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.y + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0.07427993 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0.07427993 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.z + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: -1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: -1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.x + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.y + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z + path: CartGuy + classID: 4 + script: {fileID: 0} + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim.meta b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim.meta new file mode 100644 index 000000000..983d2780c --- /dev/null +++ b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveLeft.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77aa89fd26040bc44851871d6dc2e147 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMove.anim b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveRight.anim similarity index 55% rename from Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMove.anim rename to Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveRight.anim index 519f0da75..fc87e6248 100644 --- a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMove.anim +++ b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveRight.anim @@ -6,7 +6,7 @@ AnimationClip: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: CartguyMove + m_Name: CartguyMoveRight serializedVersion: 6 m_Legacy: 0 m_Compressed: 0 @@ -20,17 +20,43 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: {x: -15.5, y: -4.5, z: 0.07427993} + value: {x: -15, y: -4.5, z: 0.07427993} inSlope: {x: 0, y: 0, z: 0} - outSlope: {x: 32.5, y: 0, z: 0} + outSlope: {x: 31.5, y: 0, z: 0} tangentMode: 0 weightedMode: 0 inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 time: 1 - value: {x: 17, y: -4.5, z: 0.07427993} - inSlope: {x: 32.5, y: 0, z: 0} + value: {x: 16.5, y: -4.5, z: 0.07427993} + inSlope: {x: 31.5, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: CartGuy + m_ScaleCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 1 + value: {x: 1, y: 1, z: 1} + inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 weightedMode: 0 @@ -40,7 +66,6 @@ AnimationClip: m_PostInfinity: 2 m_RotationOrder: 4 path: CartGuy - m_ScaleCurves: [] m_FloatCurves: [] m_PPtrCurves: [] m_SampleRate: 60 @@ -57,6 +82,13 @@ AnimationClip: typeID: 4 customType: 0 isPPtrCurve: 0 + - serializedVersion: 2 + path: 1110194031 + attribute: 3 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 pptrCurveMapping: [] m_AnimationClipSettings: serializedVersion: 2 @@ -84,17 +116,17 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: -15.5 + value: -15 inSlope: 0 - outSlope: 32.5 + outSlope: 31.5 tangentMode: 69 weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 time: 1 - value: 17 - inSlope: 32.5 + value: 16.5 + inSlope: 31.5 outSlope: 0 tangentMode: 69 weightedMode: 0 @@ -163,6 +195,90 @@ AnimationClip: path: CartGuy classID: 4 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.x + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.y + path: CartGuy + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalScale.z + path: CartGuy + classID: 4 + script: {fileID: 0} m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMove.anim.meta b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveRight.anim.meta similarity index 100% rename from Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMove.anim.meta rename to Assets/Resources/Sprites/Games/MeatGrinder/Animations/Cart Guy/CartguyMoveRight.anim.meta diff --git a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Tack/Tack.controller b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Tack/Tack.controller index 0c797987e..5f2fbeddd 100644 --- a/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Tack/Tack.controller +++ b/Assets/Resources/Sprites/Games/MeatGrinder/Animations/Tack/Tack.controller @@ -177,6 +177,32 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1102 &-2709756463524822852 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: TackMissBacon + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + 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: 2a5c3a654d086a1499f41d1b1e6526b2, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1101 &-2460084252410259005 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -610,6 +636,9 @@ AnimatorStateMachine: - serializedVersion: 1 m_State: {fileID: 5934958711024326403} m_Position: {x: -55, y: 435, z: 0} + - serializedVersion: 1 + m_State: {fileID: -2709756463524822852} + m_Position: {x: -410, y: -10, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] diff --git a/Assets/Scripts/Games/MeatGrinder/Meat.cs b/Assets/Scripts/Games/MeatGrinder/Meat.cs index a84f4a9f0..3755b5be9 100644 --- a/Assets/Scripts/Games/MeatGrinder/Meat.cs +++ b/Assets/Scripts/Games/MeatGrinder/Meat.cs @@ -19,8 +19,9 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder [NonSerialized] public double startBeat; [NonSerialized] public MeatType meatType; + [NonSerialized] public double reactionBeats = -1; + [NonSerialized] public int reaction; - private string meatTypeStr; private bool isHit = false; // const float meatStart = 0; @@ -50,10 +51,9 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder private void Start() { - meatTypeStr = meatType.ToString(); sr.sprite = meats[(int)meatType]; - Debug.Log(meats[(int)meatType]); - Debug.Log(sr.sprite.name); + Debug.Log(startBeat); + Debug.Log(reactionBeats); game.ScheduleInput(startBeat, 1, MeatGrinder.InputAction_Press, Hit, Miss, Nothing); } @@ -61,22 +61,18 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder private void Update() { Conductor cond = Conductor.instance; - // if (Input.GetKey(KeyCode.G)) { // Insane. - // anim.enabled = true; - // } - Debug.Log(sr.sprite.name); if (!isHit) { double startTime = cond.GetSongPosFromBeat(startBeat); double hitTime = cond.GetSongPosFromBeat(startBeat + 1); - double missTime = cond.GetSongPosFromBeat(startBeat + 1) + MeatGrinder.ngLateTime; + double missTime = hitTime + MeatGrinder.ngLateTime; double currentTime = cond.songPositionAsDouble; Vector3 lastPos = transform.position; Vector3 startPos = meatType == MeatType.LightMeat ? startPositionAlt.position : startPosition.position; float hitAlongMissRatio = Vector3.Dot((startPos - missPosition.position), (startPos - hitPosition.position)); hitAlongMissRatio /= Vector3.Dot((startPos - missPosition.position), (startPos - missPosition.position)); - Vector3 hitOnMissPos = startPos + (missPosition.position - startPos) * hitAlongMissRatio; + Vector3 hitOnMissPos = startPos + ((missPosition.position - startPos) * hitAlongMissRatio); float totalProg = (float)((currentTime - startTime) / (missTime - startTime)); @@ -90,9 +86,9 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder float prog = (float)((currentTime - startTime) / (hitTime - startTime)); transform.position = Vector3.Lerp(startPos, hitOnMissPos, prog); } - float yMul = totalProg * 2f - 1f; + float yMul = (totalProg * 2f) - 1f; float yWeight = -(yMul * yMul) + 1f; - transform.position += Vector3.up * (meatType == MeatType.LightMeat ? meatFlyHeightAlt : meatFlyHeight) * yWeight; + transform.position += (meatType == MeatType.LightMeat ? meatFlyHeightAlt : meatFlyHeight) * yWeight * Vector3.up; // point towards the next position transform.right = transform.position - lastPos; @@ -105,13 +101,19 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder anim.enabled = true; isHit = true; game.TackAnim.SetBool("tackMeated", false); - anim.DoScaledAnimationAsync(meatTypeStr + "Hit", 0.5f); + anim.DoScaledAnimationAsync(meatType.ToString() + "Hit", 0.5f); bool isBarely = state is >= 1f or <= -1f; game.bossAnnoyed = isBarely; SoundByte.PlayOneShotGame("meatGrinder/" + (isBarely ? "tink" : "meatHit")); game.TackAnim.DoScaledAnimationAsync("TackHit" + (isBarely ? "Barely" : "Success"), 0.5f); + + if (reactionBeats > 0) { + BeatAction.New(game, new List() { + new(startBeat + reactionBeats + 1, delegate { game.TackExpression(reaction); }) + }); + } } private void Miss(PlayerActionEvent caller) @@ -120,7 +122,7 @@ namespace HeavenStudio.Games.Scripts_MeatGrinder game.bossAnnoyed = true; SoundByte.PlayOneShotGame("meatGrinder/miss"); - game.TackAnim.DoScaledAnimationAsync("TackMiss" + meatTypeStr, 0.5f); + game.TackAnim.DoScaledAnimationAsync("TackMiss" + meatType.ToString(), 0.5f); game.TackAnim.SetBool("tackMeated", true); game.BossAnim.DoScaledAnimationAsync("BossMiss", 0.5f); diff --git a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs index bc2df3792..cee9724d6 100644 --- a/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs +++ b/Assets/Scripts/Games/MeatGrinder/MeatGrinder.cs @@ -31,7 +31,7 @@ namespace HeavenStudio.Games.Loaders { function = delegate { var e = eventCaller.currentEntity; - MeatGrinder.instance.MeatToss(e.beat, e["bacon"]); + MeatGrinder.instance.MeatToss(e.beat, e["bacon"], e["reaction"], e["reactionBeats"]); }, inactiveFunction = delegate { MeatGrinder.QueueMeatToss(eventCaller.currentEntity); @@ -41,6 +41,10 @@ namespace HeavenStudio.Games.Loaders parameters = new List() { new Param("bacon", false, "Bacon Ball", "Throw a bacon ball instead of the typical meat"), + new Param("reaction", MeatGrinder.TackExpressions.None, "Tack Reaction", "If this is hit, what expression should tack do?", new List() { + new((x, y) => (int)x != (int)MeatGrinder.TackExpressions.None, new string[] { "reactionBeats" }), + }), + new Param("reactionBeats", new EntityTypes.Float(0.5f, 10, 1), "React After", "The amount of beats to wait until reacting"), }, }, new GameAction("StartInterval", "Start Interval") @@ -63,6 +67,13 @@ namespace HeavenStudio.Games.Loaders defaultLength = 0.5f, priority = 2, preFunctionLength = 1f, + parameters = new List() + { + new Param("reaction", MeatGrinder.TackExpressions.None, "Tack Reaction", "If this is hit, what expression should tack do?", new List() { + new((x, y) => (int)x != (int)MeatGrinder.TackExpressions.None, new string[] { "reactionBeats" }), + }), + new Param("reactionBeats", new EntityTypes.Float(0.5f, 10, 1), "React After", "The amount of beats to wait until reacting"), + }, }, new GameAction("passTurn", "Pass Turn") { @@ -80,12 +91,14 @@ namespace HeavenStudio.Games.Loaders { function = delegate { var e = eventCaller.currentEntity; - MeatGrinder.instance.CartGuy(e.beat, e.length, e["spider"]); + MeatGrinder.instance.CartGuy(e.beat, e.length, e["spider"], e["direction"], e["ease"]); }, resizable = true, defaultLength = 16, parameters = new List() { new Param("spider", false, "On Phone", "Put a spider in the box?"), + new Param("direction", MeatGrinder.CartGuyDirection.Right, "Direction", "The direction the cart will be carted to."), + new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "What ease will"), } }, } @@ -105,15 +118,16 @@ namespace HeavenStudio.Games public class MeatGrinder : Minigame { - static List queuedIntervals = new(); - struct QueuedInterval + private static List queuedIntervals = new(); + + private struct QueuedInterval { public double beat; public float length; public bool autoPassTurn; } - static List queuedMeats = new(); + private static List queuedMeats = new(); [Header("Objects")] public GameObject MeatBase; @@ -127,20 +141,29 @@ namespace HeavenStudio.Games [Header("Variables")] private bool bossBop = true; public bool bossAnnoyed = false; + public Util.EasingFunction.Ease cartEase = Util.EasingFunction.Ease.Linear; public double cartBeat = double.MaxValue; public float cartLength = 0; public bool cartSpider = false; - const string sfxName = "meatGrinder/"; + public string cartDir = "Left"; + private const string sfxName = "meatGrinder/"; public static MeatGrinder instance; public enum TackExpressions { + None, Content, // Smug, Wonder, } + public enum CartGuyDirection + { + Right, + Left, + } + protected static bool IA_PadAny(out double dt) { return PlayerInput.GetPadDown(InputController.ActionsPad.East, out dt) @@ -175,7 +198,7 @@ namespace HeavenStudio.Games if (passedTurns.Count > 0) { - foreach (var pass in passedTurns) + foreach (double pass in passedTurns) { PassTurnStandalone(pass); } @@ -186,8 +209,11 @@ namespace HeavenStudio.Games { // CartGuyParentAnim.gameObject.SetActive(true); if (cartSpider) CartGuyAnim.Play("Phone", 0, 0); - float beatPos = Conductor.instance.GetPositionFromBeat(cartBeat, cartLength); - CartGuyParentAnim.DoNormalizedAnimation("Move", beatPos); + float normalizedBeat = Conductor.instance.GetPositionFromBeat(cartBeat, cartLength); + Util.EasingFunction.Function func = Util.EasingFunction.GetEasingFunction(cartEase); + float newPos = func(0f, 1f, normalizedBeat); + CartGuyParentAnim.DoNormalizedAnimation($"Move{cartDir}", newPos); + if (normalizedBeat >= 1) cartLength = 0; } } @@ -212,7 +238,7 @@ namespace HeavenStudio.Games } if (queuedMeats.Count > 0) { - foreach (var meat in queuedMeats) MeatToss(meat.beat, meat["bacon"]); + foreach (var meat in queuedMeats) MeatToss(meat.beat, meat["bacon"], meat["reaction"], meat["reactionBeats"]); queuedMeats.Clear(); } OnPlay(beat); @@ -223,7 +249,7 @@ namespace HeavenStudio.Games RiqEntity cg = GameManager.instance.Beatmap.Entities.Find(c => c.datamodel == "meatGrinder/cartGuy"); if (cg != null) { - CartGuy(cg.beat, cg.length, cg["spider"]); + CartGuy(cg.beat, cg.length, cg["spider"], cg["direction"], cg["ease"]); } } @@ -237,16 +263,16 @@ namespace HeavenStudio.Games bossBop = autoBop; if (doesBop) { + var actions = new List(); for (int i = 0; i < length; i++) { - BeatAction.New(instance, new List() { - new BeatAction.Action(beat + i, delegate { - if (!BossAnim.IsPlayingAnimationNames("BossCall") && !BossAnim.IsPlayingAnimationNames("BossSignal")) { - BossAnim.DoScaledAnimationAsync(bossAnnoyed ? "BossMiss" : "Bop", 0.5f); - } - }) - }); + actions.Add( new BeatAction.Action(beat + i, delegate { + if (!BossAnim.IsPlayingAnimationNames("BossCall", "BossSignal")) { + BossAnim.DoScaledAnimationAsync(bossAnnoyed ? "BossMiss" : "Bop", 0.5f); + } + })); } + BeatAction.New(instance, actions); } } @@ -257,11 +283,13 @@ namespace HeavenStudio.Games Debug.Log(anim); } - public void CartGuy(double beat, float length, bool spider) + public void CartGuy(double beat, float length, bool spider, int direction, int ease) { cartBeat = beat; cartLength = length; cartSpider = spider; + cartDir = direction == 0 ? "Right" : "Left"; + cartEase = (Util.EasingFunction.Ease)ease; } public static void PreInterval(double beat, float length, bool autoPassTurn) @@ -318,7 +346,7 @@ namespace HeavenStudio.Games queuedMeats.Add(entity); } - public void MeatToss(double beat, bool bacon) + public void MeatToss(double beat, bool bacon, int reaction, float reactionBeat) { SoundByte.PlayOneShotGame(sfxName + "toss"); @@ -326,6 +354,8 @@ namespace HeavenStudio.Games meat.gameObject.SetActive(true); meat.startBeat = beat; meat.meatType = bacon ? Meat.MeatType.BaconBall : Meat.MeatType.DarkMeat; + meat.reactionBeats = reactionBeat; + meat.reaction = reaction; } public static void PrePassTurn(double beat) @@ -356,12 +386,16 @@ namespace HeavenStudio.Games for (int i = 0; i < allCallEvents.Count; i++) { double relativeBeat = allCallEvents[i].beat - intervalBeat; + float reactionBeats = allCallEvents[i]["reactionBeats"]; + int reaction = allCallEvents[i]["reaction"]; meatCalls.Add(new BeatAction.Action(beat + relativeBeat - 1, delegate { - Meat Meat = Instantiate(MeatBase, transform).GetComponent(); - Meat.gameObject.SetActive(true); - Meat.startBeat = beat + relativeBeat - 1; - Meat.meatType = Meat.MeatType.LightMeat; + Meat meat = Instantiate(MeatBase, transform).GetComponent(); + meat.gameObject.SetActive(true); + meat.startBeat = beat + relativeBeat - 1; + meat.meatType = Meat.MeatType.LightMeat; + meat.reactionBeats = reactionBeats; + meat.reaction = reaction; })); } BeatAction.New(this, meatCalls);