From dee467edb815ca06c1864d1f6a729498823d3c3f Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Sun, 6 Aug 2023 23:11:16 +0200 Subject: [PATCH] gettin ready to spawn el monkeys --- Assets/Resources/Games/monkeyWatch.prefab | 21 +++++- .../Games/MonkeyWatch/PinkMonkey.prefab | 4 ++ .../Games/MonkeyWatch/YellowMonkey.prefab | 14 ++++ .../Games/MonkeyWatch/watchHole.prefab | 14 +++- .../Animations/YellowMonkey.controller | 10 +-- .../Games/MonkeyWatch/MonkeyClockArrow.cs | 44 ++++++++++++ .../Scripts/Games/MonkeyWatch/MonkeyWatch.cs | 21 ++++-- .../Scripts/Games/MonkeyWatch/WatchMonkey.cs | 69 +++++++++++++++++++ .../Games/MonkeyWatch/WatchMonkey.cs.meta | 11 +++ .../Games/MonkeyWatch/WatchMonkeyHandler.cs | 31 +++++++++ .../MonkeyWatch/WatchMonkeyHandler.cs.meta | 11 +++ 11 files changed, 238 insertions(+), 12 deletions(-) create mode 100644 Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs create mode 100644 Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs.meta create mode 100644 Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs create mode 100644 Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs.meta diff --git a/Assets/Resources/Games/monkeyWatch.prefab b/Assets/Resources/Games/monkeyWatch.prefab index 9a6f5c8ae..d24aec20c 100644 --- a/Assets/Resources/Games/monkeyWatch.prefab +++ b/Assets/Resources/Games/monkeyWatch.prefab @@ -7058,8 +7058,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3735448262030941676} + - component: {fileID: 8572779002997729184} m_Layer: 0 - m_Name: WatchHoles + m_Name: MonkeyHandler m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -7140,6 +7141,20 @@ Transform: m_Father: {fileID: 7676047881968251921} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &8572779002997729184 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1093165643910593156} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e0769f835f6039b41b98b9487eb743d9, type: 3} + m_Name: + m_EditorClassIdentifier: + yellowMonkeyRef: {fileID: -9193613041847046406, guid: 224742d4a2c74034997943856f560054, type: 3} + pinkMonkeyRef: {fileID: 8621594802119604348, guid: 277f8b23f1f26f64290a2461c18d4b80, type: 3} --- !u!1 &1093770155466988112 GameObject: m_ObjectHideFlags: 0 @@ -20240,6 +20255,7 @@ MonoBehaviour: cameraTransform: {fileID: 16600283237656001} cameraMoveable: {fileID: 7676047881968251921} monkeyClockArrow: {fileID: 8220690735241008560} + monkeyHandler: {fileID: 8572779002997729184} maxMonkeys: 30 --- !u!1 &6181011653585253546 GameObject: @@ -22881,6 +22897,9 @@ MonoBehaviour: m_EditorClassIdentifier: anim: {fileID: 910339928251400446} anchorRotateTransform: {fileID: 609139906039373078} + playerMonkeyAnim: {fileID: 4873567491568184609} + yellowClap: {fileID: 8899231323861109608} + pinkClap: {fileID: 5162462144302245337} --- !u!1 &7446072329631304920 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/MonkeyWatch/PinkMonkey.prefab b/Assets/Resources/Prefabs/Games/MonkeyWatch/PinkMonkey.prefab index e850982e0..7e7d28d36 100644 --- a/Assets/Resources/Prefabs/Games/MonkeyWatch/PinkMonkey.prefab +++ b/Assets/Resources/Prefabs/Games/MonkeyWatch/PinkMonkey.prefab @@ -7,6 +7,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: -9193613041847046406, guid: 224742d4a2c74034997943856f560054, type: 3} + propertyPath: isPink + value: 1 + objectReference: {fileID: 0} - target: {fileID: 454223507615240516, guid: 224742d4a2c74034997943856f560054, type: 3} propertyPath: m_Size.x value: 0.7666345 diff --git a/Assets/Resources/Prefabs/Games/MonkeyWatch/YellowMonkey.prefab b/Assets/Resources/Prefabs/Games/MonkeyWatch/YellowMonkey.prefab index 5278f18e8..3ae89e97b 100644 --- a/Assets/Resources/Prefabs/Games/MonkeyWatch/YellowMonkey.prefab +++ b/Assets/Resources/Prefabs/Games/MonkeyWatch/YellowMonkey.prefab @@ -178,6 +178,7 @@ GameObject: m_Component: - component: {fileID: 7591110402097765485} - component: {fileID: 7211266264008123551} + - component: {fileID: -9193613041847046406} m_Layer: 0 m_Name: YellowMonkey m_TagString: Untagged @@ -230,6 +231,19 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 +--- !u!114 &-9193613041847046406 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3151069026564347634} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 23217e6c428ce954e8fd08940b856233, type: 3} + m_Name: + m_EditorClassIdentifier: + isPink: 0 --- !u!1 &4343136497418508153 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/MonkeyWatch/watchHole.prefab b/Assets/Resources/Prefabs/Games/MonkeyWatch/watchHole.prefab index a3e5ff151..391c49604 100644 --- a/Assets/Resources/Prefabs/Games/MonkeyWatch/watchHole.prefab +++ b/Assets/Resources/Prefabs/Games/MonkeyWatch/watchHole.prefab @@ -178,8 +178,9 @@ GameObject: m_Component: - component: {fileID: 2594505700513810575} - component: {fileID: 4157700164771259173} + - component: {fileID: 6295735035881919980} m_Layer: 0 - m_Name: WatchHole + m_Name: watchHole m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -223,3 +224,14 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 +--- !u!210 &6295735035881919980 +SortingGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8325540476350084961} + m_Enabled: 1 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 diff --git a/Assets/Resources/Sprites/Games/MonkeyWatch/Animations/YellowMonkey.controller b/Assets/Resources/Sprites/Games/MonkeyWatch/Animations/YellowMonkey.controller index fd09d0ab5..93c9859f2 100644 --- a/Assets/Resources/Sprites/Games/MonkeyWatch/Animations/YellowMonkey.controller +++ b/Assets/Resources/Sprites/Games/MonkeyWatch/Animations/YellowMonkey.controller @@ -234,13 +234,13 @@ AnimatorStateMachine: m_Position: {x: 490, y: 170, z: 0} - serializedVersion: 1 m_State: {fileID: 9034752867166180580} - m_Position: {x: -350, y: 250, z: 0} + m_Position: {x: -480, y: 140, z: 0} - serializedVersion: 1 m_State: {fileID: 2281978419273917628} - m_Position: {x: -200, y: 270, z: 0} + m_Position: {x: -350, y: 200, z: 0} - serializedVersion: 1 m_State: {fileID: -823361394144095262} - m_Position: {x: -50, y: 250, z: 0} + m_Position: {x: -210, y: 150, z: 0} - serializedVersion: 1 m_State: {fileID: -2720091023925718476} m_Position: {x: 260, y: 230, z: 0} @@ -285,7 +285,7 @@ AnimatorStateMachine: m_Position: {x: 490, y: 590, z: 0} - serializedVersion: 1 m_State: {fileID: -8633427497819712545} - m_Position: {x: -200, y: 190, z: 0} + m_Position: {x: -350, y: 40, z: 0} - serializedVersion: 1 m_State: {fileID: 7801861347107792603} m_Position: {x: -165, y: 255, z: 0} @@ -939,7 +939,7 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Yellow + m_Name: Prepare4 m_Speed: 1 m_CycleOffset: 0 m_Transitions: [] diff --git a/Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs b/Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs index 4aacaa639..0dfe89906 100644 --- a/Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs +++ b/Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs @@ -10,6 +10,24 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch [Header("Components")] [SerializeField] private Animator anim; [SerializeField] private Transform anchorRotateTransform; + [SerializeField] private Animator playerMonkeyAnim; + [SerializeField] private ParticleSystem yellowClap; + [SerializeField] private ParticleSystem pinkClap; + + private MonkeyWatch game; + + private void Awake() + { + game = MonkeyWatch.instance; + } + + private void Update() + { + if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN)) + { + PlayerClap(false, false, true); + } + } public void Move() { @@ -21,6 +39,32 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch { anchorRotateTransform.localEulerAngles = new Vector3(0, 0, -angle); } + + public void PlayerClap(bool big, bool barely, bool whiff) + { + if (!playerMonkeyAnim.IsAnimationNotPlaying() && whiff) return; + + if (barely || whiff) + { + playerMonkeyAnim.DoScaledAnimationAsync("PlayerClapBarely", 0.5f); + } + else + { + playerMonkeyAnim.DoScaledAnimationAsync(big ? "PlayerClapBig" : "PlayerClap", 0.5f); + if (big) + { + pinkClap.transform.eulerAngles = Vector3.zero; + pinkClap.transform.GetChild(0).GetComponent().SetAsyncScaling(0.5f); + pinkClap.PlayScaledAsync(0.5f); + } + else + { + yellowClap.transform.eulerAngles = Vector3.zero; + yellowClap.transform.GetChild(0).GetComponent().SetAsyncScaling(0.5f); + yellowClap.PlayScaledAsync(0.5f); + } + } + } } } diff --git a/Assets/Scripts/Games/MonkeyWatch/MonkeyWatch.cs b/Assets/Scripts/Games/MonkeyWatch/MonkeyWatch.cs index b5b03907b..dbd21db70 100644 --- a/Assets/Scripts/Games/MonkeyWatch/MonkeyWatch.cs +++ b/Assets/Scripts/Games/MonkeyWatch/MonkeyWatch.cs @@ -13,6 +13,15 @@ namespace HeavenStudio.Games.Loaders { return new Minigame("monkeyWatch", "Monkey Watch", "f0338d", false, false, new List() { + new GameAction("appear", "Monkeys Appear") + { + defaultLength = 2f, + resizable = true, + parameters = new List() + { + new Param("value", new EntityTypes.Integer(1, 30, 4), "Repeat Amount") + } + }, new GameAction("clap", "Clapping") { preFunction = delegate @@ -85,11 +94,7 @@ namespace HeavenStudio.Games public class MonkeyWatch : Minigame { private const float degreePerMonkey = 6f; - public enum WatchPoint - { - PersistGameSwitch, - SetTime - } + public static MonkeyWatch instance; [Header("Components")] @@ -97,6 +102,7 @@ namespace HeavenStudio.Games [SerializeField] private Transform cameraTransform; [SerializeField] private Transform cameraMoveable; [SerializeField] private MonkeyClockArrow monkeyClockArrow; + [SerializeField] private WatchMonkeyHandler monkeyHandler; [Header("Properties")] [SerializeField] private int maxMonkeys = 30; @@ -124,6 +130,11 @@ namespace HeavenStudio.Games CameraUpdate(); } + public void PlayerMonkeyClap(bool big, bool barely) + { + monkeyClockArrow.PlayerClap(big, barely, false); + } + public override void OnGameSwitch(double beat) { GetCameraMovements(beat, false); diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs new file mode 100644 index 000000000..4759d794f --- /dev/null +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs @@ -0,0 +1,69 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using HeavenStudio.Util; + + +namespace HeavenStudio.Games.Scripts_MonkeyWatch +{ + public class WatchMonkey : MonoBehaviour + { + private Animator anim; + private Animator holeAnim; + [Header("Properties")] + [SerializeField] private bool isPink; + + private MonkeyWatch game; + + private int direction = 0; + + private PlayerActionEvent inputEvent; + + private void Awake() + { + game = MonkeyWatch.instance; + anim = GetComponent(); + } + + public void Appear(bool instant, Animator hole) + { + holeAnim = hole; + holeAnim.DoScaledAnimationAsync("HoleOpen", 0.5f); + anim.DoScaledAnimationAsync(isPink ? "Pink" : "" + "Appear", 0.5f, instant ? 1 : 0); + } + + public void Prepare(double prepareBeat, double inputBeat, int dir) + { + direction = dir; + anim.DoScaledAnimationAsync(isPink ? "Pink" : "" + "Prepare" + dir, 0); + inputEvent = game.ScheduleInput(prepareBeat, inputBeat - prepareBeat, InputType.STANDARD_DOWN, Just, Miss, Empty); + BeatAction.New(gameObject, new List() + { + new BeatAction.Action(prepareBeat, delegate + { + anim.DoScaledAnimationAsync(isPink ? "Pink" : "" + "Prepare" + dir, 0.5f); + }) + }); + } + + private void Just(PlayerActionEvent caller, float state) + { + game.PlayerMonkeyClap(isPink, state >= 1f || state <= -1f); + if (state >= 1f || state <= -1f) + { + SoundByte.PlayOneShot("miss"); + return; + } + SoundByte.PlayOneShotGame(isPink ? "monkeyWatch/clapOffbeat" : $"monkeyWatch/clapOnbeat{UnityEngine.Random.Range(1, 6)}"); + anim.DoScaledAnimationAsync(isPink ? "Pink" : "" + "Clap" + direction, 0.5f); + } + + private void Miss(PlayerActionEvent caller) + { + + } + + private void Empty(PlayerActionEvent caller) { } + } +} + diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs.meta b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs.meta new file mode 100644 index 000000000..037e98923 --- /dev/null +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23217e6c428ce954e8fd08940b856233 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs new file mode 100644 index 000000000..c81e5fceb --- /dev/null +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using HeavenStudio.Util; + +namespace HeavenStudio.Games.Scripts_MonkeyWatch +{ + public class WatchMonkeyHandler : MonoBehaviour + { + [Header("Components")] + [SerializeField] private WatchMonkey yellowMonkeyRef; + [SerializeField] private WatchMonkey pinkMonkeyRef; + + private MonkeyWatch game; + + private int startMinute = 0; + private double startBeat = 0; + + private void Awake() + { + game = MonkeyWatch.instance; + } + + public void Init(double beat, int minute) + { + startBeat = beat; + startMinute = minute; + } + } +} + diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs.meta b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs.meta new file mode 100644 index 000000000..937d6a217 --- /dev/null +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0769f835f6039b41b98b9487eb743d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: