From 3047ea74f101f143eb643f96b7bffc7835a0c18d Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:51:50 +0200 Subject: [PATCH] Dummy inputs --- .../Games/AnimalAcrobat/Elephant.prefab | 31 +++++- .../Games/AnimalAcrobat/Giraffe.prefab | 14 ++- .../Games/AnimalAcrobat/WhiteMonkey.prefab | 29 ++++- .../Games/AnimalAcrobat/WhiteMonkeys.prefab | 29 ++++- .../Games/AnimalAcrobat/AcrobatObstacle.cs | 7 +- .../Games/AnimalAcrobat/AnimalAcrobat.cs | 11 +- .../Games/AnimalAcrobat/GiraffeInput.cs | 102 ++++++++++++++++++ .../Games/AnimalAcrobat/GiraffeInput.cs.meta | 11 ++ .../Games/AnimalAcrobat/ObstacleInput.cs | 55 ++++++++++ .../Games/AnimalAcrobat/ObstacleInput.cs.meta | 11 ++ Assets/Scripts/Util/Sound.cs | 5 + 11 files changed, 297 insertions(+), 8 deletions(-) create mode 100644 Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs create mode 100644 Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs.meta create mode 100644 Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs create mode 100644 Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs.meta diff --git a/Assets/Resources/Prefabs/Games/AnimalAcrobat/Elephant.prefab b/Assets/Resources/Prefabs/Games/AnimalAcrobat/Elephant.prefab index 597762fd0..c49d442dd 100644 --- a/Assets/Resources/Prefabs/Games/AnimalAcrobat/Elephant.prefab +++ b/Assets/Resources/Prefabs/Games/AnimalAcrobat/Elephant.prefab @@ -499,6 +499,7 @@ GameObject: - component: {fileID: 6285390310926959546} - component: {fileID: 6198430257364661693} - component: {fileID: -5564384145903586768} + - component: {fileID: -4645702950898394595} m_Layer: 0 m_Name: Elephant m_TagString: Untagged @@ -558,13 +559,41 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2f9ee457016acdc4eb5dbfdc03be0d6f, type: 3} m_Name: m_EditorClassIdentifier: + _onInit: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: -4645702950898394595} + m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput, + Assembly-CSharp + m_MethodName: Init + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 _fullRotRange: 120 - _spawnDistance: 10.408 _spawnOffset: 0 _holdLength: 2 _ease: 4 _rotateRoot: {fileID: 2616646720197201304} _gripPoint: {fileID: 2131794628642567477} +--- !u!114 &-4645702950898394595 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7540716611123628191} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3} + m_Name: + m_EditorClassIdentifier: + _holdLength: 2 --- !u!1 &7805847212563886084 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/AnimalAcrobat/Giraffe.prefab b/Assets/Resources/Prefabs/Games/AnimalAcrobat/Giraffe.prefab index 2bcb2454b..0c04124cd 100644 --- a/Assets/Resources/Prefabs/Games/AnimalAcrobat/Giraffe.prefab +++ b/Assets/Resources/Prefabs/Games/AnimalAcrobat/Giraffe.prefab @@ -263,6 +263,7 @@ GameObject: m_Component: - component: {fileID: 1701002327333926128} - component: {fileID: 5248028064811562821} + - component: {fileID: 3253363150451868373} m_Layer: 0 m_Name: Giraffe m_TagString: Untagged @@ -301,12 +302,23 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: _fullRotRange: 160 - _spawnDistance: 20.816 _spawnOffset: 10.408 _holdLength: 4 _ease: 4 _rotateRoot: {fileID: 4208995891253938729} _gripPoint: {fileID: 8714220451416272075} +--- !u!114 &3253363150451868373 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2939598505969617365} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f87e00a2ffbd0af4baae18b3c11268db, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &3911272779464478738 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkey.prefab b/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkey.prefab index 422431740..a70625400 100644 --- a/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkey.prefab +++ b/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkey.prefab @@ -125,6 +125,7 @@ GameObject: m_Component: - component: {fileID: 532140475066366254} - component: {fileID: 7370747047491091311} + - component: {fileID: 3772265357728581139} m_Layer: 0 m_Name: WhiteMonkey m_TagString: Untagged @@ -162,13 +163,39 @@ MonoBehaviour: m_EditorClassIdentifier: _onInit: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 3772265357728581139} + m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput, + Assembly-CSharp + m_MethodName: Init + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 _fullRotRange: 160 _spawnOffset: 5.204 _holdLength: 1 _ease: 4 _rotateRoot: {fileID: 2068126119450832752} _gripPoint: {fileID: 8286548847234487440} +--- !u!114 &3772265357728581139 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1656536018348746482} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3} + m_Name: + m_EditorClassIdentifier: + _holdLength: 1 --- !u!1 &3823740494665398411 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkeys.prefab b/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkeys.prefab index 6fcf19f5c..d71c7355e 100644 --- a/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkeys.prefab +++ b/Assets/Resources/Prefabs/Games/AnimalAcrobat/WhiteMonkeys.prefab @@ -1892,6 +1892,7 @@ GameObject: m_Component: - component: {fileID: 3439047595127619699} - component: {fileID: -3114631264593203074} + - component: {fileID: 3068772248330600904} m_Layer: 0 m_Name: WhiteMonkeys m_TagString: Untagged @@ -1931,13 +1932,39 @@ MonoBehaviour: m_EditorClassIdentifier: _onInit: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 3068772248330600904} + m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput, + Assembly-CSharp + m_MethodName: Init + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 _fullRotRange: 160 _spawnOffset: 9.244 _holdLength: 3 _ease: 4 _rotateRoot: {fileID: 3903953954711634507} _gripPoint: {fileID: 3800820123473635694} +--- !u!114 &3068772248330600904 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7969179947406382610} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3} + m_Name: + m_EditorClassIdentifier: + _holdLength: 3 --- !u!1 &8302616130811808557 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs b/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs index 725f184a8..926981845 100644 --- a/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs +++ b/Assets/Scripts/Games/AnimalAcrobat/AcrobatObstacle.cs @@ -3,12 +3,13 @@ using System.Collections.Generic; using UnityEngine; using HeavenStudio.Util; using UnityEngine.Events; +using System; namespace HeavenStudio.Games.Scripts_AnimalAcrobat { public class AcrobatObstacle : MonoBehaviour { - [SerializeField] private UnityEvent _onInit; + public Action OnInit; [Header("Values")] [SerializeField] private float _fullRotRange; @@ -33,11 +34,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat _func = EasingFunction.GetEasingFunction(_ease); } - public void Init(double beat, double expirationBeat) + public void Init(double beat, double expirationBeat, bool behindGiraffe) { _startBeat = beat; _expirationBeat = expirationBeat; - _onInit.Invoke(_startBeat); + OnInit(beat, behindGiraffe); Update(); } diff --git a/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs b/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs index 0888c8cce..2db63007d 100644 --- a/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs +++ b/Assets/Scripts/Games/AnimalAcrobat/AnimalAcrobat.cs @@ -74,6 +74,14 @@ namespace HeavenStudio.Games private List _queuedAnimals = new(); private int _animalPoolIndex = 0; private float _animalSummatedDistance = 0; + private bool _lastAnimalWasGiraffe = false; + + public static AnimalAcrobat instance; + + private void Awake() + { + instance = this; + } private void Update() { @@ -124,10 +132,11 @@ namespace HeavenStudio.Games expBeat += seekedAnimal.length; } - animal.Init(currentAnimal.startBeat, expBeat); + animal.Init(currentAnimal.startBeat, expBeat, _lastAnimalWasGiraffe); animal.transform.localPosition = new Vector3(_animalSummatedDistance, 0, 0); _animalSummatedDistance += animal.GetRotationDistance() + _jumpDistance; + _lastAnimalWasGiraffe = currentAnimal.type == AnimalType.Giraffe; _animalPoolIndex++; } diff --git a/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs b/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs new file mode 100644 index 000000000..af969fd8a --- /dev/null +++ b/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs @@ -0,0 +1,102 @@ +using HeavenStudio.Util; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace HeavenStudio.Games.Scripts_AnimalAcrobat +{ + public class GiraffeInput : MonoBehaviour + { + private AcrobatObstacle _mainScript; + + private AnimalAcrobat _game; + + private Sound _drumRollSound; + + private void Awake() + { + _game = AnimalAcrobat.instance; + _mainScript = GetComponent(); + _mainScript.OnInit += Init; + } + + private void OnDestroy() + { + if (_drumRollSound != null) _drumRollSound.Stop(); + } + + public void Init(double beat, bool beforeGiraffe) + { + _game.ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, beforeGiraffe ? JustHoldGiraffe : JustHold, Empty, Empty); + _game.ScheduleInput(beat, 4, InputType.STANDARD_UP, JustRelease, Empty, Empty); + + MultiSound.Play(new MultiSound.Sound[] + { + new MultiSound.Sound("animalAcrobat/eek", beat + 2), + new MultiSound.Sound("animalAcrobat/eek", beat + 3) + }); + } + + private void JustHold(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/catch"); + } + + private void JustHoldGiraffe(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch"); + } + + private void JustRelease(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/giraffeJump"); + + double beat = caller.startBeat + caller.timer; + + _drumRollSound = SoundByte.PlayOneShotGame("animalAcrobat/giraffeDrumroll", beat, 1, 1, true); + StartCoroutine(GiraffeDrumRollLoop(beat)); + + MultiSound.Play(new MultiSound.Sound[] + { + new MultiSound.Sound("animalAcrobat/giraffeCymbal", beat + 2), + new MultiSound.Sound("animalAcrobat/applause", beat + 2.25), + new MultiSound.Sound("animalAcrobat/turn", beat + 3) + }); + } + + private IEnumerator GiraffeDrumRollLoop(double beat) + { + float fadeOutNormalized = 0; + var cond = Conductor.instance; + while (fadeOutNormalized <= 1) + { + fadeOutNormalized = cond.GetPositionFromBeat(beat, 1); + _drumRollSound.SetVolume(Mathf.Lerp(1, 0.125f, fadeOutNormalized)); + yield return null; + } + + float fadeInNormalized = 0; + + while (fadeInNormalized <= 1) + { + fadeInNormalized = cond.GetPositionFromBeat(beat + 1, 3); + _drumRollSound.SetVolume(Mathf.Lerp(0.125f, 1, fadeOutNormalized)); + yield return null; + } + + float fadeOutFinal = 0; + double fadeOutLength = cond.SecsToBeats(0.587, cond.GetBpmAtBeat(beat + 4)); + + while (fadeOutFinal <= 1) + { + fadeOutFinal = cond.GetPositionFromBeat(beat + 4, fadeOutLength); + _drumRollSound.SetVolume(Mathf.Lerp(1, 0, fadeOutNormalized)); + yield return null; + } + _drumRollSound.Stop(); + _drumRollSound = null; + } + + private void Empty(PlayerActionEvent caller) { } + } +} diff --git a/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs.meta b/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs.meta new file mode 100644 index 000000000..1876d68d9 --- /dev/null +++ b/Assets/Scripts/Games/AnimalAcrobat/GiraffeInput.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f87e00a2ffbd0af4baae18b3c11268db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs b/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs new file mode 100644 index 000000000..8bdf8ca75 --- /dev/null +++ b/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs @@ -0,0 +1,55 @@ +using HeavenStudio.Util; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace HeavenStudio.Games.Scripts_AnimalAcrobat +{ + public class ObstacleInput : MonoBehaviour + { + [SerializeField] private double _holdLength; + + private AcrobatObstacle _mainScript; + + private AnimalAcrobat _game; + + private void Awake() + { + _game = AnimalAcrobat.instance; + _mainScript = GetComponent(); + _mainScript.OnInit += Init; + } + + public void Init(double beat, bool beforeGiraffe) + { + _game.ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, beforeGiraffe ? JustHoldGiraffe : JustHold, Empty, Empty); + _game.ScheduleInput(beat, _holdLength, InputType.STANDARD_UP, JustRelease, Empty, Empty); + + MultiSound.Play(new MultiSound.Sound[] + { + new MultiSound.Sound("animalAcrobat/eek", beat + _holdLength - 2), + new MultiSound.Sound("animalAcrobat/eek", beat + _holdLength - 1) + }); + } + + private void JustHold(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/catch"); + } + + private void JustHoldGiraffe(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch"); + } + + private void JustRelease(PlayerActionEvent caller, float state) + { + SoundByte.PlayOneShotGame("animalAcrobat/release"); + + SoundByte.PlayOneShotGame("animalAcrobat/turn", caller.startBeat + caller.timer + 1); + } + + private void Empty(PlayerActionEvent caller) { } + } +} + diff --git a/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs.meta b/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs.meta new file mode 100644 index 000000000..cd5fdfe2e --- /dev/null +++ b/Assets/Scripts/Games/AnimalAcrobat/ObstacleInput.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9a934a7ab91ef694e94df3dce43f43ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Util/Sound.cs b/Assets/Scripts/Util/Sound.cs index 89b889324..0201f13e0 100644 --- a/Assets/Scripts/Util/Sound.cs +++ b/Assets/Scripts/Util/Sound.cs @@ -43,6 +43,11 @@ namespace HeavenStudio.Util { } + public void SetVolume(float volume) + { + audioSource.volume = volume; + } + public void Play() { if (!available)