diff --git a/Assets/Resources/Games/coinToss.prefab b/Assets/Resources/Games/coinToss.prefab index 41047b7d..cbdab33a 100644 --- a/Assets/Resources/Games/coinToss.prefab +++ b/Assets/Resources/Games/coinToss.prefab @@ -82,6 +82,62 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &2284767481152605812 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5807365695538841574} + - component: {fileID: 5502145621422939277} + m_Layer: 0 + m_Name: Coin_Cue + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &5807365695538841574 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2284767481152605812} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.80453336, y: -2.6470656, z: -1.8526075} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 8906338938816874952} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5502145621422939277 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2284767481152605812} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: df09de01a35532c42b315b9b076cf88b, 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 &4255918877615705356 GameObject: m_ObjectHideFlags: 0 @@ -524,6 +580,7 @@ Transform: m_Children: - {fileID: 5417053695332528972} - {fileID: 3170172331476655201} + - {fileID: 5807365695538841574} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -542,6 +599,7 @@ MonoBehaviour: EligibleHits: [] firstEnable: 0 isThrowing: 0 + coin_cue: {fileID: 2284767481152605812} handAnimator: {fileID: 6887173419118620922} --- !u!1 &9176706498249536598 GameObject: @@ -553,7 +611,6 @@ GameObject: m_Component: - component: {fileID: 3170172331476655201} - component: {fileID: 6887173419118620922} - - component: {fileID: 4532207818172471810} m_Layer: 0 m_Name: Arm m_TagString: Untagged @@ -597,27 +654,3 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 ---- !u!114 &4532207818172471810 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 9176706498249536598} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 064f8eb876b68ff448e085a8c3df2db7, 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 diff --git a/Assets/Resources/Sfx/applause.ogg.meta b/Assets/Resources/Sfx/applause.ogg.meta index 3c087a76..3000b50a 100644 --- a/Assets/Resources/Sfx/applause.ogg.meta +++ b/Assets/Resources/Sfx/applause.ogg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c86bb199b366fb345b66a429c88e7bbf +guid: 9f31c51f546a40e4a929a3a7c4820258 AudioImporter: externalObjects: {} serializedVersion: 6 diff --git a/Assets/Resources/Sfx/games/coinToss/applause.ogg.meta b/Assets/Resources/Sfx/games/coinToss/applause.ogg.meta new file mode 100644 index 00000000..3c087a76 --- /dev/null +++ b/Assets/Resources/Sfx/games/coinToss/applause.ogg.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: c86bb199b366fb345b66a429c88e7bbf +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sfx/games/coinToss/miss.wav.meta b/Assets/Resources/Sfx/games/coinToss/miss.wav.meta new file mode 100644 index 00000000..6c5ce934 --- /dev/null +++ b/Assets/Resources/Sfx/games/coinToss/miss.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 96d6d69630594804388f5b71a11e2b6e +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Sfx/miss.wav.meta b/Assets/Resources/Sfx/miss.wav.meta index 6c5ce934..c0a7dda6 100644 --- a/Assets/Resources/Sfx/miss.wav.meta +++ b/Assets/Resources/Sfx/miss.wav.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 96d6d69630594804388f5b71a11e2b6e +guid: b49816b082c733548aa2ee48154e114b AudioImporter: externalObjects: {} serializedVersion: 6 diff --git a/Assets/Scripts/Games/CoinToss/Arm.cs b/Assets/Scripts/Games/CoinToss/Arm.cs deleted file mode 100644 index 12b0ac83..00000000 --- a/Assets/Scripts/Games/CoinToss/Arm.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System; -using UnityEngine; -using NaughtyBezierCurves; - -using HeavenStudio.Util; - -namespace HeavenStudio.Games.Scripts_CoinToss -{ - public class Arm : PlayerActionObject - { - - private Boolean isThrowing; - private Animator handAnimator; - - private CoinToss game; - - // Start is called before the first frame update - private void Awake() - { - isThrowing = false; - game = CoinToss.instance; - handAnimator = game.handAnimator; - } - - // Update is called once per frame - private void Update() - { - if (PlayerInput.Pressed() && state.perfect) - { - if (isThrowing) - { - Catch_Success(); - isThrowing = false; - } - } - } - - public override void OnAce() - { - if(isThrowing) - { - Catch_Success(); - isThrowing = false; - } - } - - public void Catch_Success() - { - Jukebox.PlayOneShotGame("coinToss/catch"); - handAnimator.Play("Catch_success", 0, 0); - } - } - -} \ No newline at end of file diff --git a/Assets/Scripts/Games/CoinToss/Coin.cs b/Assets/Scripts/Games/CoinToss/Coin.cs new file mode 100644 index 00000000..f61c2bef --- /dev/null +++ b/Assets/Scripts/Games/CoinToss/Coin.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using HeavenStudio.Util; + +namespace HeavenStudio.Games.Scripts_CoinToss +{ + public class Coin : PlayerActionObject + { + public float startBeat; + + void Awake() + { + PlayerActionInit(this.gameObject, startBeat); + } + + public override void OnAce() + { + Hit(); + } + + void Update() + { + if (Conductor.instance.GetPositionFromBeat(startBeat, 1f) >= 6.3f) + MissCoin(); + + float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 6f); + StateCheck(normalizedBeat); + + if (PlayerInput.Pressed()) + { + if (state.perfect) + { + Hit(); + } + } + + public void Hit() + { + CoinToss.instance.Catch_Success(); + Destroy(this.gameObject); + } + + public void MissCoin() + { + CoinToss.instance.Catch_Miss(); + Destroy(this.gameObject); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Games/CoinToss/Arm.cs.meta b/Assets/Scripts/Games/CoinToss/Coin.cs.meta similarity index 83% rename from Assets/Scripts/Games/CoinToss/Arm.cs.meta rename to Assets/Scripts/Games/CoinToss/Coin.cs.meta index 5a1d6312..3f220b01 100644 --- a/Assets/Scripts/Games/CoinToss/Arm.cs.meta +++ b/Assets/Scripts/Games/CoinToss/Coin.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 064f8eb876b68ff448e085a8c3df2db7 +guid: df09de01a35532c42b315b9b076cf88b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Games/CoinToss/CoinToss.cs b/Assets/Scripts/Games/CoinToss/CoinToss.cs index 18b9d480..7f37e4d9 100644 --- a/Assets/Scripts/Games/CoinToss/CoinToss.cs +++ b/Assets/Scripts/Games/CoinToss/CoinToss.cs @@ -27,16 +27,16 @@ namespace HeavenStudio.Games { public static CoinToss instance { get; set; } - public Boolean isThrowing; + public GameObject coin_cue; + [Header("Animators")] public Animator handAnimator; private void Awake() { instance = this; - isThrowing = false; } private void Update() @@ -55,7 +55,24 @@ namespace HeavenStudio.Games handAnimator.Play("Throw", 0, 0); isThrowing = true; + + GameObject coin = Instantiate(coin_cue); + coin.SetActive(true); + Coin c = coin.GetComponent(); + c.startBeat = beat; } + public void Catch_Success() + { + Jukebox.PlayOneShotGame("coinToss/catch"); + handAnimator.Play("Catch_success", 0, 0); + + isThrowing = false; + } + + public void Catch_Miss() + { + Jukebox.PlayOneShotGame("coinToss/miss"); + } } }