diff --git a/Assets/Resources/Fonts/rodin.meta b/Assets/Resources/Fonts/rodin.meta new file mode 100644 index 000000000..09d8f701d --- /dev/null +++ b/Assets/Resources/Fonts/rodin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96ed2f99a777c924f882e2f3c41b1881 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Fonts/rodin_merged.asset b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset similarity index 99% rename from Assets/Resources/Fonts/rodin_merged.asset rename to Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset index 6cea58991..778145569 100644 --- a/Assets/Resources/Fonts/rodin_merged.asset +++ b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset @@ -1,13 +1,13 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!21 &-1154359511425921776 +--- !u!21 &-1662932664650235619 Material: serializedVersion: 6 m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: rodin_merged Material + m_Name: rodin_lat_cy_ja_ko_spec Material m_Shader: {fileID: 4800000, guid: 128e987d567d4e2c824d754223b3f3b0, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 @@ -24,7 +24,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 1363669669053061815} + m_Texture: {fileID: 8801383763965547972} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: @@ -53,14 +53,14 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3} - m_Name: rodin_merged + m_Name: rodin_lat_cy_ja_ko_spec m_EditorClassIdentifier: hashCode: 0 - material: {fileID: -1154359511425921776} + material: {fileID: -1662932664650235619} materialHashCode: 0 m_Version: 1.1.0 - m_SourceFontFileGUID: d245bd2e354835547b32cf6c1a738d45 - m_SourceFontFile_EditorRef: {fileID: 12800000, guid: d245bd2e354835547b32cf6c1a738d45, type: 3} + m_SourceFontFileGUID: 6459e01c422d8fb469d08b74a81e6b81 + m_SourceFontFile_EditorRef: {fileID: 12800000, guid: 6459e01c422d8fb469d08b74a81e6b81, type: 3} m_SourceFontFile: {fileID: 0} m_AtlasPopulationMode: 0 m_FaceInfo: @@ -79,7 +79,7 @@ MonoBehaviour: m_SuperscriptSize: 0.5 m_SubscriptOffset: -39.989998 m_SubscriptSize: 0.5 - m_UnderlineOffset: -85.374 + m_UnderlineOffset: -104.346 m_UnderlineThickness: 18.972 m_StrikethroughOffset: 41.2 m_StrikethroughThickness: 18.972 @@ -2717,7 +2717,7 @@ MonoBehaviour: m_Height: 185 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 466 + - m_Index: 596 m_Metrics: m_Width: 93 m_Height: 14 @@ -2731,7 +2731,7 @@ MonoBehaviour: m_Height: 14 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 467 + - m_Index: 597 m_Metrics: m_Width: 186 m_Height: 13 @@ -2745,7 +2745,7 @@ MonoBehaviour: m_Height: 13 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 470 + - m_Index: 600 m_Metrics: m_Width: 25 m_Height: 54 @@ -2759,7 +2759,7 @@ MonoBehaviour: m_Height: 54 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 471 + - m_Index: 601 m_Metrics: m_Width: 25 m_Height: 55 @@ -2773,7 +2773,7 @@ MonoBehaviour: m_Height: 55 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 472 + - m_Index: 602 m_Metrics: m_Width: 25 m_Height: 55 @@ -2787,7 +2787,7 @@ MonoBehaviour: m_Height: 55 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 474 + - m_Index: 604 m_Metrics: m_Width: 59 m_Height: 54 @@ -2801,7 +2801,7 @@ MonoBehaviour: m_Height: 54 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 475 + - m_Index: 605 m_Metrics: m_Width: 58 m_Height: 55 @@ -2815,7 +2815,7 @@ MonoBehaviour: m_Height: 55 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 476 + - m_Index: 606 m_Metrics: m_Width: 58 m_Height: 55 @@ -2829,7 +2829,7 @@ MonoBehaviour: m_Height: 55 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 477 + - m_Index: 607 m_Metrics: m_Width: 90 m_Height: 168 @@ -2843,7 +2843,7 @@ MonoBehaviour: m_Height: 168 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 478 + - m_Index: 608 m_Metrics: m_Width: 90 m_Height: 168 @@ -2857,7 +2857,7 @@ MonoBehaviour: m_Height: 168 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 479 + - m_Index: 609 m_Metrics: m_Width: 43 m_Height: 42 @@ -2871,7 +2871,7 @@ MonoBehaviour: m_Height: 42 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 481 + - m_Index: 611 m_Metrics: m_Width: 152 m_Height: 28 @@ -2885,7 +2885,7 @@ MonoBehaviour: m_Height: 28 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 482 + - m_Index: 612 m_Metrics: m_Width: 169 m_Height: 153 @@ -2899,7 +2899,7 @@ MonoBehaviour: m_Height: 153 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 485 + - m_Index: 615 m_Metrics: m_Width: 69 m_Height: 105 @@ -2913,7 +2913,7 @@ MonoBehaviour: m_Height: 105 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 486 + - m_Index: 616 m_Metrics: m_Width: 69 m_Height: 105 @@ -2927,7 +2927,7 @@ MonoBehaviour: m_Height: 105 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 489 + - m_Index: 619 m_Metrics: m_Width: 100 m_Height: 155 @@ -2941,7 +2941,7 @@ MonoBehaviour: m_Height: 155 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 490 + - m_Index: 620 m_Metrics: m_Width: 124 m_Height: 153 @@ -2955,7 +2955,7 @@ MonoBehaviour: m_Height: 153 m_Scale: 1 m_AtlasIndex: 0 - - m_Index: 498 + - m_Index: 628 m_Metrics: m_Width: 135 m_Height: 78 @@ -3724,78 +3724,78 @@ MonoBehaviour: m_Scale: 1 - m_ElementType: 1 m_Unicode: 8211 - m_GlyphIndex: 466 + m_GlyphIndex: 596 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8212 - m_GlyphIndex: 467 + m_GlyphIndex: 597 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8216 - m_GlyphIndex: 470 + m_GlyphIndex: 600 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8217 - m_GlyphIndex: 471 + m_GlyphIndex: 601 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8218 - m_GlyphIndex: 472 + m_GlyphIndex: 602 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8220 - m_GlyphIndex: 474 + m_GlyphIndex: 604 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8221 - m_GlyphIndex: 475 + m_GlyphIndex: 605 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8222 - m_GlyphIndex: 476 + m_GlyphIndex: 606 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8224 - m_GlyphIndex: 477 + m_GlyphIndex: 607 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8225 - m_GlyphIndex: 478 + m_GlyphIndex: 608 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8226 - m_GlyphIndex: 479 + m_GlyphIndex: 609 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8230 - m_GlyphIndex: 481 + m_GlyphIndex: 611 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8240 - m_GlyphIndex: 482 + m_GlyphIndex: 612 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8249 - m_GlyphIndex: 485 + m_GlyphIndex: 615 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8250 - m_GlyphIndex: 486 + m_GlyphIndex: 616 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8260 - m_GlyphIndex: 489 + m_GlyphIndex: 619 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8364 - m_GlyphIndex: 490 + m_GlyphIndex: 620 m_Scale: 1 - m_ElementType: 1 m_Unicode: 8482 - m_GlyphIndex: 498 + m_GlyphIndex: 628 m_Scale: 1 m_AtlasTextures: - - {fileID: 1363669669053061815} + - {fileID: 8801383763965547972} m_AtlasTextureIndex: 0 m_IsMultiAtlasTexturesEnabled: 0 m_ClearDynamicDataOnBuild: 0 @@ -5341,7 +5341,7 @@ MonoBehaviour: m_FallbackFontAssetTable: [] m_CreationSettings: sourceFontFileName: - sourceFontFileGUID: d245bd2e354835547b32cf6c1a738d45 + sourceFontFileGUID: 6459e01c422d8fb469d08b74a81e6b81 pointSizeSamplingMode: 0 pointSize: 186 padding: 12 @@ -5384,13 +5384,13 @@ MonoBehaviour: boldSpacing: 7 italicStyle: 35 tabSize: 10 ---- !u!28 &1363669669053061815 +--- !u!28 &8801383763965547972 Texture2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: rodin_merged Atlas + m_Name: rodin_lat_cy_ja_ko_spec Atlas m_ImageContentsHash: serializedVersion: 2 Hash: 00000000000000000000000000000000 diff --git a/Assets/Resources/Fonts/rodin_merged.asset.meta b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset.meta similarity index 79% rename from Assets/Resources/Fonts/rodin_merged.asset.meta rename to Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset.meta index 928a2db6a..dc1ee700d 100644 --- a/Assets/Resources/Fonts/rodin_merged.asset.meta +++ b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 391dfd08cb8a3cf4dbae153523abce8b +guid: 795a65f16e097f44eb799cb2ec026fc1 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf new file mode 100644 index 000000000..81a3fed8b Binary files /dev/null and b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf differ diff --git a/Assets/Resources/Fonts/rodin_merged.ttf.meta b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf.meta similarity index 75% rename from Assets/Resources/Fonts/rodin_merged.ttf.meta rename to Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf.meta index 60a8a72ed..2be544bff 100644 --- a/Assets/Resources/Fonts/rodin_merged.ttf.meta +++ b/Assets/Resources/Fonts/rodin/rodin_lat_cy_ja_ko_spec.ttf.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d245bd2e354835547b32cf6c1a738d45 +guid: 6459e01c422d8fb469d08b74a81e6b81 TrueTypeFontImporter: externalObjects: {} serializedVersion: 4 @@ -10,7 +10,8 @@ TrueTypeFontImporter: includeFontData: 1 fontNames: - nintendo_NTLG-DB_001 - fallbackFontReferences: [] + fallbackFontReferences: + - {fileID: 12800000, guid: d245bd2e354835547b32cf6c1a738d45, type: 3} customCharacters: fontRenderingMode: 0 ascentCalculationMode: 1 diff --git a/Assets/Resources/Fonts/rodin_merged.ttf b/Assets/Resources/Fonts/rodin_merged.ttf deleted file mode 100644 index 1a8031478..000000000 Binary files a/Assets/Resources/Fonts/rodin_merged.ttf and /dev/null differ diff --git a/Assets/Scripts/CommonAnimEvents.cs b/Assets/Scripts/CommonAnimEvents.cs deleted file mode 100644 index 3fc7761e1..000000000 --- a/Assets/Scripts/CommonAnimEvents.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class CommonAnimEvents : MonoBehaviour -{ - public void Destroy() - { - Destroy(this.gameObject); - } -} diff --git a/Assets/Scripts/Conductor.cs b/Assets/Scripts/Conductor.cs index 49684b764..2862dd739 100644 --- a/Assets/Scripts/Conductor.cs +++ b/Assets/Scripts/Conductor.cs @@ -4,164 +4,167 @@ using UnityEngine; using Starpelly; -[RequireComponent(typeof(AudioSource))] -public class Conductor : MonoBehaviour +namespace RhythmHeavenMania { - //Song beats per minute - //This is determined by the song you're trying to sync up to - public float songBpm; - - //The number of seconds for each song beat - public float secPerBeat; - - //Current song position, in seconds - public float songPosition; - - //Current song position, in beats - public float songPositionInBeats; - - //How many seconds have passed since the song started - public float dspSongTime; - - //an AudioSource attached to this GameObject that will play the music. - public AudioSource musicSource; - - //The offset to the first beat of the song in seconds - public float firstBeatOffset; - - //the number of beats in each loop - public float beatsPerLoop; - - //the total number of loops completed since the looping clip first started - public int completedLoops = 0; - - //The current position of the song within the loop in beats. - public float loopPositionInBeats; - - //The current relative position of the song within the loop measured between 0 and 1. - public float loopPositionInAnalog; - - //Conductor instance - public static Conductor instance; - - //Pause times - private int pauseTime = 0; - - public float beatThreshold; - - void Awake() + [RequireComponent(typeof(AudioSource))] + public class Conductor : MonoBehaviour { - instance = this; - } + //Song beats per minute + //This is determined by the song you're trying to sync up to + public float songBpm; - void Start() - { - //Load the AudioSource attached to the Conductor GameObject - musicSource = GetComponent(); + //The number of seconds for each song beat + public float secPerBeat; - //Calculate the number of seconds in each beat - secPerBeat = 60f / songBpm; + //Current song position, in seconds + public float songPosition; - //Record the time when the music starts - dspSongTime = (float)musicSource.time; + //Current song position, in beats + public float songPositionInBeats; - //Start the music - // musicSource.Play(); - } + //How many seconds have passed since the song started + public float dspSongTime; - void Update() - { - Conductor.instance.musicSource.pitch = Time.timeScale; + //an AudioSource attached to this GameObject that will play the music. + public AudioSource musicSource; - /*if (Input.GetKeyDown(KeyCode.Space)) + //The offset to the first beat of the song in seconds + public float firstBeatOffset; + + //the number of beats in each loop + public float beatsPerLoop; + + //the total number of loops completed since the looping clip first started + public int completedLoops = 0; + + //The current position of the song within the loop in beats. + public float loopPositionInBeats; + + //The current relative position of the song within the loop measured between 0 and 1. + public float loopPositionInAnalog; + + //Conductor instance + public static Conductor instance; + + //Pause times + private int pauseTime = 0; + + public float beatThreshold; + + void Awake() { - pauseTime++; - if (pauseTime == 1) - musicSource.Pause(); - else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; } - }*/ + instance = this; + } - //determine how many seconds since the song started - songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset); - - //determine how many beats since the song started - songPositionInBeats = songPosition / secPerBeat; - - //calculate the loop position - if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop) - completedLoops++; - loopPositionInBeats = songPositionInBeats - completedLoops * beatsPerLoop; - - loopPositionInAnalog = loopPositionInBeats / beatsPerLoop; - } - - public float GetLoopPositionFromBeat(float startBeat, float length) - { - float final = Starpelly.Mathp.Normalize(songPositionInBeats, startBeat, startBeat + length); - - return final; - } - - public bool InThreshold(float beat) - { - //Check if the beat sent falls within beatThreshold - //Written to handle the looping - if (beat <= beatThreshold + 1) + void Start() { - //Debug.Log("Case 1, beat is close to 1"); - if (loopPositionInBeats > beat + beatThreshold) + //Load the AudioSource attached to the Conductor GameObject + musicSource = GetComponent(); + + //Calculate the number of seconds in each beat + secPerBeat = 60f / songBpm; + + //Record the time when the music starts + dspSongTime = (float)musicSource.time; + + //Start the music + // musicSource.Play(); + } + + void Update() + { + Conductor.instance.musicSource.pitch = Time.timeScale; + + /*if (Input.GetKeyDown(KeyCode.Space)) { - if (loopPositionInBeats >= (beat + songPositionInBeats - 1) + beatThreshold) + pauseTime++; + if (pauseTime == 1) + musicSource.Pause(); + else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; } + }*/ + + //determine how many seconds since the song started + songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset); + + //determine how many beats since the song started + songPositionInBeats = songPosition / secPerBeat; + + //calculate the loop position + if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop) + completedLoops++; + loopPositionInBeats = songPositionInBeats - completedLoops * beatsPerLoop; + + loopPositionInAnalog = loopPositionInBeats / beatsPerLoop; + } + + public float GetLoopPositionFromBeat(float startBeat, float length) + { + float final = Starpelly.Mathp.Normalize(songPositionInBeats, startBeat, startBeat + length); + + return final; + } + + public bool InThreshold(float beat) + { + //Check if the beat sent falls within beatThreshold + //Written to handle the looping + if (beat <= beatThreshold + 1) + { + //Debug.Log("Case 1, beat is close to 1"); + if (loopPositionInBeats > beat + beatThreshold) { - //Debug.Log("LoopPos just below loop point"); - return true; + if (loopPositionInBeats >= (beat + songPositionInBeats - 1) + beatThreshold) + { + //Debug.Log("LoopPos just below loop point"); + return true; + } + else + { + //Debug.Log("LoopPos not within beat threshold"); + } } else { - //Debug.Log("LoopPos not within beat threshold"); + //Debug.Log("Case 1, loopPos between loop point and beat threshold"); } } - else + else if (beat < (songPositionInBeats + 1 - beatThreshold)) { - //Debug.Log("Case 1, loopPos between loop point and beat threshold"); - } - } - else if (beat < (songPositionInBeats + 1 - beatThreshold)) - { - //Debug.Log("Case 2, beat is far from loop point."); - if (loopPositionInBeats >= beat - beatThreshold && loopPositionInBeats <= beat + beatThreshold) - { - //Debug.Log("LoopPos within threshold"); - return true; - } - } - else if (beat >= (songPositionInBeats + 1 - beatThreshold)) - { - //Debug.Log("Case 3, beat is close to loop point"); - if (loopPositionInBeats < beat) - { - if (loopPositionInBeats >= beat - beatThreshold) + //Debug.Log("Case 2, beat is far from loop point."); + if (loopPositionInBeats >= beat - beatThreshold && loopPositionInBeats <= beat + beatThreshold) { - //Debug.Log("LoopPos just below beat"); - return true; - } - else if (loopPositionInBeats < (beat - songPositionInBeats + 1) - beatThreshold) - { - //Debug.Log("LoopPos just above loop point"); + //Debug.Log("LoopPos within threshold"); return true; } } - else + else if (beat >= (songPositionInBeats + 1 - beatThreshold)) { - //Debug.Log("LoopPos just above beat"); - return true; - } + //Debug.Log("Case 3, beat is close to loop point"); + if (loopPositionInBeats < beat) + { + if (loopPositionInBeats >= beat - beatThreshold) + { + //Debug.Log("LoopPos just below beat"); + return true; + } + else if (loopPositionInBeats < (beat - songPositionInBeats + 1) - beatThreshold) + { + //Debug.Log("LoopPos just above loop point"); + return true; + } + } + else + { + //Debug.Log("LoopPos just above beat"); + return true; + } + } + else + { + Debug.LogError("Strange Case. Where is this beat? This should never happen"); + } + return false; } - else - { - Debug.LogError("Strange Case. Where is this beat? This should never happen"); - } - return false; } } \ No newline at end of file diff --git a/Assets/Scripts/ForkLifter/ForkLifter.cs b/Assets/Scripts/ForkLifter/ForkLifter.cs deleted file mode 100644 index d9fceeb7c..000000000 --- a/Assets/Scripts/ForkLifter/ForkLifter.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class ForkLifter : MonoBehaviour -{ - public static ForkLifter instance; - - GameManager GameManager; - - [Header("Objects")] - public Animator handAnim; - public GameObject flickedObject; - public SpriteRenderer peaPreview; - - public Sprite[] peaSprites; - public Sprite[] peaHitSprites; - - private void Awake() - { - instance = this; - } - - private void Start() - { - GameManager = GameManager.instance; - } - - public void Flick(float beat, int type) - { - Jukebox.PlayOneShot("flick"); - handAnim.Play("Hand_Flick", 0, 0); - GameObject fo = Instantiate(flickedObject); - fo.GetComponent().startBeat = beat; - fo.GetComponent().type = type; - fo.SetActive(true); - } -} diff --git a/Assets/Scripts/ForkLifter/ForkLifterHand.cs b/Assets/Scripts/ForkLifter/ForkLifterHand.cs deleted file mode 100644 index b8b173b81..000000000 --- a/Assets/Scripts/ForkLifter/ForkLifterHand.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -public class ForkLifterHand : MonoBehaviour -{ - public SpriteRenderer fastSprite; - - public Sprite[] fastSprites; - - List allPlayerActions; - - public static ForkLifterHand instance { get; set; } - - private void Awake() - { - instance = this; - } - - public void CheckNextFlick() - { - allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare"); - - if (GameManager.instance.currentEventPlayer < allPlayerActions.Count) - { - switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName) - { - case "pea": - ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0]; - fastSprite.sprite = fastSprites[0]; - break; - case "topbun": - fastSprite.sprite = fastSprites[0]; - ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1]; - break; - case "burger": - fastSprite.sprite = fastSprites[1]; - ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2]; - break; - case "bottombun": - fastSprite.sprite = fastSprites[0]; - ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3]; - break; - } - } - else - { - ForkLifter.instance.peaPreview.sprite = null; - } - } - - public void Prepare() - { - Jukebox.PlayOneShot("flickPrepare"); - GetComponent().Play("Hand_Prepare"); - } -} diff --git a/Assets/Scripts/ForkLifter/ForkLifterPlayer.cs b/Assets/Scripts/ForkLifter/ForkLifterPlayer.cs deleted file mode 100644 index 94f542013..000000000 --- a/Assets/Scripts/ForkLifter/ForkLifterPlayer.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -using DG.Tweening; - -public class ForkLifterPlayer : MonoBehaviour -{ - [Header("Objects")] - public GameObject fork; - public Sprite peaSprite; - public Sprite hitFX; - public Sprite hitFXG; - public Sprite hitFXMiss; - public Sprite hitFX2; - public Transform early, perfect, late; - - [SerializeField] - private BoxCollider2D col; - - private Animator anim; - - public List EligibleHits = new List(); - private int currentHitInList = 0; - - public static ForkLifterPlayer instance { get; set; } - - public float timescale = 1; - - private int currentEarlyPeasOnFork; - private int currentPerfectPeasOnFork; - private int currentLatePeasOnFork; - - private bool isEating = false; - - // Burger shit - - private bool topbun, middleburger, bottombun; - - // ----------- - - [System.Serializable] - public class Eligible - { - public Pea pea; - public bool early; - public bool perfect; - public bool late; - } - - private void Awake() - { - instance = this; - } - - private void Start() - { - anim = GetComponent(); - } - - private void Update() - { - Time.timeScale = timescale; - - if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space)) - { - Stab(); - } - - if (EligibleHits.Count == 0) - { - currentHitInList = 0; - } - - if (Input.GetKeyDown(KeyCode.A)) - { - Conductor.instance.musicSource.time += 3; - } - else if (Input.GetKeyDown(KeyCode.S)) - { - Conductor.instance.musicSource.time -= 3; - GameManager.instance.SetCurrentEventToClosest(); - } - } - - public void Eat() - { - if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0) - { - anim.Play("Player_Eat", 0, 0); - isEating = true; - } - } - - public void EatConfirm() - { - if (topbun && middleburger && bottombun) - { - Jukebox.PlayOneShot("burger"); - } - else - { - if (currentEarlyPeasOnFork > 0 || currentLatePeasOnFork > 0) - { - Jukebox.PlayOneShot($"cough_{Random.Range(1, 3)}"); - } - else - { - Jukebox.PlayOneShot("gulp"); - } - } - - for (int i = 0; i < early.transform.childCount; i++) - { - Destroy(early.transform.GetChild(i).gameObject); - } - for (int i = 0; i < perfect.transform.childCount; i++) - { - Destroy(perfect.transform.GetChild(i).gameObject); - } - for (int i = 0; i < late.transform.childCount; i++) - { - Destroy(late.transform.GetChild(i).gameObject); - } - currentEarlyPeasOnFork = 0; - currentPerfectPeasOnFork = 0; - currentLatePeasOnFork = 0; - - isEating = false; - - topbun = false; middleburger = false; bottombun = false; - } - - public void Stab() - { - if (isEating) return; - bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count); - - if (canHit) - { - GameObject pea = new GameObject(); - - if (EligibleHits[currentHitInList].perfect) - { - pea.transform.parent = perfect.transform; - pea.transform.localScale = Vector2.one; - - pea.transform.localPosition = Vector3.zero; - - for (int i = 0; i < perfect.transform.childCount; i++) - { - perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork); - } - - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - switch (EligibleHits[currentHitInList].pea.type) - { - case 0: - psprite.sortingOrder = 101; - break; - case 1: - psprite.sortingOrder = 104; - break; - case 2: - psprite.sortingOrder = 103; - break; - case 3: - psprite.sortingOrder = 102; - break; - } - - GameObject hitFXo = new GameObject(); - hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f); - hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f); - SpriteRenderer hfxs = hitFXo.AddComponent(); - hfxs.sprite = hitFX; - hfxs.sortingOrder = 100; - hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShot("stab"); - - currentPerfectPeasOnFork++; - - if (EligibleHits[currentHitInList].pea.type == 1) - { - topbun = true; - } - else if (EligibleHits[currentHitInList].pea.type == 2) - { - middleburger = true; - } - else if (EligibleHits[currentHitInList].pea.type == 3) - { - bottombun = true; - } - - RemovePea(); - - GoForAPerfect.instance.Hit(); - GameProfiler.instance.IncreaseScore(); - } - else if (EligibleHits[currentHitInList].early) - { - pea.transform.parent = early.transform; - pea.transform.localScale = Vector2.one; - - pea.transform.localPosition = Vector3.zero; - pea.transform.localRotation = Quaternion.Euler(0, 0, 90); - - for (int i = 0; i < early.transform.childCount; i++) - { - early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork); - } - - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); - HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); - HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); - HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShot("miss"); - - currentEarlyPeasOnFork++; - - RemovePea(); - - GoForAPerfect.instance.Miss(); - } - else if (EligibleHits[currentHitInList].late) - { - pea.transform.parent = late.transform; - pea.transform.localScale = Vector2.one; - - pea.transform.localPosition = Vector3.zero; - pea.transform.localRotation = Quaternion.Euler(0, 0, 90); - - for (int i = 0; i < late.transform.childCount; i++) - { - late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork); - } - - SpriteRenderer psprite = pea.AddComponent(); - psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; - psprite.sortingOrder = 20; - HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); - HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); - HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); - HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); - - FastEffectHit(EligibleHits[currentHitInList].pea.type); - - Jukebox.PlayOneShot("miss"); - - currentLatePeasOnFork++; - - RemovePea(); - - GoForAPerfect.instance.Miss(); - } - } - else - { - Jukebox.PlayOneShot("stabnohit"); - } - - anim.Play("Player_Stab", 0, 0); - } - - private void FastEffectHit(int type) - { - GameObject hitFX2o = new GameObject(); - hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f); - hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f); - hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f); - SpriteRenderer hfx2s = hitFX2o.AddComponent(); - if (type == 2) - hfx2s.sprite = hitFXG; - else - hfx2s.sprite = hitFX2; - hfx2s.sortingOrder = -5; - hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); }); - } - - private void HitFXMiss(Vector2 pos, Vector2 size) - { - GameObject hitFXo = new GameObject(); - hitFXo.transform.localPosition = new Vector3(pos.x, pos.y); - hitFXo.transform.localScale = new Vector3(size.x, size.y); - SpriteRenderer hfxs = hitFXo.AddComponent(); - hfxs.sprite = hitFXMiss; - hfxs.sortingOrder = 100; - hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); - } - - private void RemovePea() - { - if (currentHitInList < EligibleHits.Count) - { - Destroy(EligibleHits[currentHitInList].pea.gameObject); - EligibleHits.Remove(EligibleHits[currentHitInList]); - currentHitInList++; - } - } -} diff --git a/Assets/Scripts/ForkLifter/Pea.cs b/Assets/Scripts/ForkLifter/Pea.cs deleted file mode 100644 index 8fbfbd9a5..000000000 --- a/Assets/Scripts/ForkLifter/Pea.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Pea : MonoBehaviour -{ - [Header("Latency")] - public float earlyTime; - public float perfectTime; - public float lateTime; - public float endTime; - - private Animator anim; - - public float startBeat; - - private bool inList = false; - - public int type; - - private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible(); - - public int estate, pstate, lstate, endstate; - - private void Start() - { - anim = GetComponent(); - Jukebox.PlayOneShot("zoom"); - GetComponentInChildren().sprite = ForkLifter.instance.peaSprites[type]; - - e = new ForkLifterPlayer.Eligible(); - e.pea = this; - - for (int i = 0; i < transform.GetChild(0).childCount; i++) - { - transform.GetChild(0).GetChild(i).GetComponent().sprite = transform.GetChild(0).GetComponent().sprite; - } - } - - private void Update() - { - float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f)); - anim.Play("Flicked_Object", -1, normalizedBeat); - anim.speed = 0; - - // Early State - if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1) - { - estate++; - MakeEligible(true, false, false); - } - // Perfect State - else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1) - { - pstate++; - MakeEligible(false, true, false); - } - // Late State - else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1) - { - lstate++; - MakeEligible(false, false, true); - } - else if (normalizedBeat < earlyTime || normalizedBeat > endTime) - { - MakeInEligible(); - } - - if (normalizedBeat > endTime && endstate <= 1) - { - endstate++; - Jukebox.PlayOneShot("disappointed"); - GoForAPerfect.instance.Miss(); - } - - if (normalizedBeat > 1.35f) - { - MakeInEligible(); - Destroy(this.gameObject); - } - } - - public void MakeEligible(bool early, bool perfect, bool late) - { - // print($"{early}, {perfect}, {late}"); - - if (!inList) - { - e.early = early; - e.perfect = perfect; - e.late = late; - - ForkLifterPlayer.instance.EligibleHits.Add(e); - inList = true; - } - else - { - ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)]; - es.early = early; - es.perfect = perfect; - es.late = late; - } - } - - public void MakeInEligible() - { - if (!inList) return; - - ForkLifterPlayer.instance.EligibleHits.Remove(e); - inList = false; - } -} diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index cdccd847a..e46ce1915 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -7,176 +7,182 @@ using UnityEngine; using Starpelly; using Newtonsoft.Json; -public class GameManager : MonoBehaviour +using RhythmHeavenMania.Games.ForkLifter; +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania { - public static GameManager instance; - - public List Events = new List(); - public List AutoPlay = new List(); - public List allPlayerActions = new List(); - - public int currentEvent, currentEventAutoplay, currentEventPlayer; - - public TextAsset txt; - - public bool autoplay = false; - - public float startOffset; - - [Serializable] - public class Event : ICloneable + public class GameManager : MonoBehaviour { - public float spawnTime; - public string eventName; + public static GameManager instance; - public object Clone() + public List Events = new List(); + public List AutoPlay = new List(); + public List allPlayerActions = new List(); + + public int currentEvent, currentEventAutoplay, currentEventPlayer; + + public TextAsset txt; + + public bool autoplay = false; + + public float startOffset; + + [Serializable] + public class Event : ICloneable { - return this.MemberwiseClone(); - } - } + public float spawnTime; + public string eventName; - private void Awake() - { - instance = this; - } - - private void Start() - { - SortEventsList(); - - string json = txt.text; - Events = JsonConvert.DeserializeObject>(json); - - SortEventsList(); - - allPlayerActions = Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end"); - AutoPlay = allPlayerActions.Select(c => c.spawnTime + 2).ToList(); - - /*List temp = new List(); - for (int i = 0; i < allPlayerActions.Count; i++) - { - if (i - 1 > 0) + public object Clone() { - if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime)) - { - // do nothing lul - continue; - } - } - Event e = (Event)allPlayerActions[i].Clone(); - e.spawnTime = allPlayerActions[i].spawnTime - 1; - e.eventName = "prepare"; - - temp.Add(e); - } - - string s = JsonConvert.SerializeObject(temp); - print(s);*/ - - StartCoroutine(Begin()); - - GlobalGameManager.Init(); - } - - private IEnumerator Begin() - { - yield return new WaitForSeconds(startOffset); - Conductor.instance.musicSource.Play(); - GoForAPerfect.instance.Enable(); - } - - private void Update() - { - if (Input.GetKeyDown(KeyCode.Q)) - ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 0); - if (Input.GetKeyDown(KeyCode.W)) - ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 1); - if (Input.GetKeyDown(KeyCode.E)) - ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 2); - if (Input.GetKeyDown(KeyCode.R)) - ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 3); - - if (Events.Count < 1) - return; - - List floats = Events.Select(c => c.spawnTime).ToList(); - - if (currentEvent < Events.Count && currentEvent >= 0) - { - if (Conductor.instance.songPositionInBeats >= floats[currentEvent]) - { - - switch (Events[currentEvent].eventName) - { - case "pea": - currentEventPlayer++; - ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 0); - break; - case "topbun": - currentEventPlayer++; - ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 1); - break; - case "burger": - currentEventPlayer++; - ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 2); - break; - case "bottombun": - currentEventPlayer++; - ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 3); - break; - case "gulp": - ForkLifterPlayer.instance.Eat(); - break; - case "sigh": - Jukebox.PlayOneShot("sigh"); - break; - case "prepare": - ForkLifterHand.instance.Prepare(); - break; - case "end": - GlobalGameManager.LoadScene(2, 0.45f); - break; - - } - currentEvent++; + return this.MemberwiseClone(); } } - if (autoplay) + private void Awake() { - if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0) - { - if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay]) - { - ForkLifterPlayer.instance.Stab(); - currentEventAutoplay++; - } - } + instance = this; } - } - public void SortEventsList() - { - Events.Sort((x, y) => x.spawnTime.CompareTo(y.spawnTime)); - } - - public void SetCurrentEventToClosest() - { - if (Events.Count > 0) + private void Start() { + SortEventsList(); + + string json = txt.text; + Events = JsonConvert.DeserializeObject>(json); + + SortEventsList(); + + allPlayerActions = Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end"); + AutoPlay = allPlayerActions.Select(c => c.spawnTime + 2).ToList(); + + /*List temp = new List(); + for (int i = 0; i < allPlayerActions.Count; i++) + { + if (i - 1 > 0) + { + if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime)) + { + // do nothing lul + continue; + } + } + Event e = (Event)allPlayerActions[i].Clone(); + e.spawnTime = allPlayerActions[i].spawnTime - 1; + e.eventName = "prepare"; + + temp.Add(e); + } + + string s = JsonConvert.SerializeObject(temp); + print(s);*/ + + StartCoroutine(Begin()); + + GlobalGameManager.Init(); + } + + private IEnumerator Begin() + { + yield return new WaitForSeconds(startOffset); + Conductor.instance.musicSource.Play(); + GoForAPerfect.instance.Enable(); + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.Q)) + ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 0); + if (Input.GetKeyDown(KeyCode.W)) + ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 1); + if (Input.GetKeyDown(KeyCode.E)) + ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 2); + if (Input.GetKeyDown(KeyCode.R)) + ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 3); + + if (Events.Count < 1) + return; + List floats = Events.Select(c => c.spawnTime).ToList(); - currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats)); + + if (currentEvent < Events.Count && currentEvent >= 0) + { + if (Conductor.instance.songPositionInBeats >= floats[currentEvent]) + { + + switch (Events[currentEvent].eventName) + { + case "pea": + currentEventPlayer++; + ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 0); + break; + case "topbun": + currentEventPlayer++; + ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 1); + break; + case "burger": + currentEventPlayer++; + ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 2); + break; + case "bottombun": + currentEventPlayer++; + ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 3); + break; + case "gulp": + ForkLifterPlayer.instance.Eat(); + break; + case "sigh": + Jukebox.PlayOneShot("sigh"); + break; + case "prepare": + ForkLifterHand.instance.Prepare(); + break; + case "end": + GlobalGameManager.LoadScene(2, 0.45f); + break; + + } + currentEvent++; + } + } + + if (autoplay) + { + if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0) + { + if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay]) + { + ForkLifterPlayer.instance.Stab(); + currentEventAutoplay++; + } + } + } } - if (AutoPlay.Count > 0) + + public void SortEventsList() { - currentEvent = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats)); - currentEventPlayer = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats)); + Events.Sort((x, y) => x.spawnTime.CompareTo(y.spawnTime)); + } + + public void SetCurrentEventToClosest() + { + if (Events.Count > 0) + { + List floats = Events.Select(c => c.spawnTime).ToList(); + currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats)); + } + if (AutoPlay.Count > 0) + { + currentEvent = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats)); + currentEventPlayer = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats)); + } + } + + + private void OnGUI() + { + // GUI.Box(new Rect(0, 0, 300, 50), $"SongPosInBeats: {Conductor.instance.songPositionInBeats}"); } } - - - private void OnGUI() - { - // GUI.Box(new Rect(0, 0, 300, 50), $"SongPosInBeats: {Conductor.instance.songPositionInBeats}"); - } -} +} \ No newline at end of file diff --git a/Assets/Scripts/GameProfiler.cs b/Assets/Scripts/GameProfiler.cs index 8b40cbf4d..f1e9c5b57 100644 --- a/Assets/Scripts/GameProfiler.cs +++ b/Assets/Scripts/GameProfiler.cs @@ -2,33 +2,36 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class GameProfiler : MonoBehaviour +namespace RhythmHeavenMania { - public float score = 0; - public int totalHits = 0; - - public bool perfect = false; - - public static GameProfiler instance { get; set; } - - private void Awake() + public class GameProfiler : MonoBehaviour { - instance = this; - DontDestroyOnLoad(this.gameObject); - } - private void Start() - { - perfect = true; - } + public float score = 0; + public int totalHits = 0; - public void IncreaseScore() - { - totalHits++; - score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count); - } + public bool perfect = false; - public float GetPercent(float value, float totalValue) - { - return (value / totalValue) * 100; + public static GameProfiler instance { get; set; } + + private void Awake() + { + instance = this; + DontDestroyOnLoad(this.gameObject); + } + private void Start() + { + perfect = true; + } + + public void IncreaseScore() + { + totalHits++; + score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count); + } + + public float GetPercent(float value, float totalValue) + { + return (value / totalValue) * 100; + } } -} +} \ No newline at end of file diff --git a/Assets/Scripts/Games.meta b/Assets/Scripts/Games.meta new file mode 100644 index 000000000..f38f7dfcf --- /dev/null +++ b/Assets/Scripts/Games.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc7b4daee555e974cac4bcee60f9e6f0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ForkLifter.meta b/Assets/Scripts/Games/ForkLifter.meta similarity index 100% rename from Assets/Scripts/ForkLifter.meta rename to Assets/Scripts/Games/ForkLifter.meta diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifter.cs b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs new file mode 100644 index 000000000..88925e723 --- /dev/null +++ b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania.Games.ForkLifter +{ + public class ForkLifter : MonoBehaviour + { + public static ForkLifter instance; + + GameManager GameManager; + + [Header("Objects")] + public Animator handAnim; + public GameObject flickedObject; + public SpriteRenderer peaPreview; + + public Sprite[] peaSprites; + public Sprite[] peaHitSprites; + + private void Awake() + { + instance = this; + } + + private void Start() + { + GameManager = GameManager.instance; + } + + public void Flick(float beat, int type) + { + Jukebox.PlayOneShot("flick"); + handAnim.Play("Hand_Flick", 0, 0); + GameObject fo = Instantiate(flickedObject); + fo.GetComponent().startBeat = beat; + fo.GetComponent().type = type; + fo.SetActive(true); + } + } + +} \ No newline at end of file diff --git a/Assets/Scripts/ForkLifter/ForkLifter.cs.meta b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs.meta similarity index 100% rename from Assets/Scripts/ForkLifter/ForkLifter.cs.meta rename to Assets/Scripts/Games/ForkLifter/ForkLifter.cs.meta diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs new file mode 100644 index 000000000..ef5f9b77c --- /dev/null +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs @@ -0,0 +1,63 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania.Games.ForkLifter +{ + public class ForkLifterHand : MonoBehaviour + { + public SpriteRenderer fastSprite; + + public Sprite[] fastSprites; + + List allPlayerActions; + + public static ForkLifterHand instance { get; set; } + + private void Awake() + { + instance = this; + } + + public void CheckNextFlick() + { + allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare"); + + if (GameManager.instance.currentEventPlayer < allPlayerActions.Count) + { + switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName) + { + case "pea": + ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0]; + fastSprite.sprite = fastSprites[0]; + break; + case "topbun": + fastSprite.sprite = fastSprites[0]; + ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1]; + break; + case "burger": + fastSprite.sprite = fastSprites[1]; + ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2]; + break; + case "bottombun": + fastSprite.sprite = fastSprites[0]; + ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3]; + break; + } + } + else + { + ForkLifter.instance.peaPreview.sprite = null; + } + } + + public void Prepare() + { + Jukebox.PlayOneShot("flickPrepare"); + GetComponent().Play("Hand_Prepare"); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/ForkLifter/ForkLifterHand.cs.meta b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs.meta similarity index 100% rename from Assets/Scripts/ForkLifter/ForkLifterHand.cs.meta rename to Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs.meta diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs new file mode 100644 index 000000000..2d8771484 --- /dev/null +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs @@ -0,0 +1,317 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using DG.Tweening; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania.Games.ForkLifter +{ + public class ForkLifterPlayer : MonoBehaviour + { + [Header("Objects")] + public GameObject fork; + public Sprite peaSprite; + public Sprite hitFX; + public Sprite hitFXG; + public Sprite hitFXMiss; + public Sprite hitFX2; + public Transform early, perfect, late; + + [SerializeField] + private BoxCollider2D col; + + private Animator anim; + + public List EligibleHits = new List(); + private int currentHitInList = 0; + + public static ForkLifterPlayer instance { get; set; } + + public float timescale = 1; + + private int currentEarlyPeasOnFork; + private int currentPerfectPeasOnFork; + private int currentLatePeasOnFork; + + private bool isEating = false; + + // Burger shit + + private bool topbun, middleburger, bottombun; + + // ----------- + + [System.Serializable] + public class Eligible + { + public Pea pea; + public bool early; + public bool perfect; + public bool late; + } + + private void Awake() + { + instance = this; + } + + private void Start() + { + anim = GetComponent(); + } + + private void Update() + { + Time.timeScale = timescale; + + if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space)) + { + Stab(); + } + + if (EligibleHits.Count == 0) + { + currentHitInList = 0; + } + + if (Input.GetKeyDown(KeyCode.A)) + { + Conductor.instance.musicSource.time += 3; + } + else if (Input.GetKeyDown(KeyCode.S)) + { + Conductor.instance.musicSource.time -= 3; + GameManager.instance.SetCurrentEventToClosest(); + } + } + + public void Eat() + { + if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0) + { + anim.Play("Player_Eat", 0, 0); + isEating = true; + } + } + + public void EatConfirm() + { + if (topbun && middleburger && bottombun) + { + Jukebox.PlayOneShot("burger"); + } + else + { + if (currentEarlyPeasOnFork > 0 || currentLatePeasOnFork > 0) + { + Jukebox.PlayOneShot($"cough_{Random.Range(1, 3)}"); + } + else + { + Jukebox.PlayOneShot("gulp"); + } + } + + for (int i = 0; i < early.transform.childCount; i++) + { + Destroy(early.transform.GetChild(i).gameObject); + } + for (int i = 0; i < perfect.transform.childCount; i++) + { + Destroy(perfect.transform.GetChild(i).gameObject); + } + for (int i = 0; i < late.transform.childCount; i++) + { + Destroy(late.transform.GetChild(i).gameObject); + } + currentEarlyPeasOnFork = 0; + currentPerfectPeasOnFork = 0; + currentLatePeasOnFork = 0; + + isEating = false; + + topbun = false; middleburger = false; bottombun = false; + } + + public void Stab() + { + if (isEating) return; + bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count); + + if (canHit) + { + GameObject pea = new GameObject(); + + if (EligibleHits[currentHitInList].perfect) + { + pea.transform.parent = perfect.transform; + pea.transform.localScale = Vector2.one; + + pea.transform.localPosition = Vector3.zero; + + for (int i = 0; i < perfect.transform.childCount; i++) + { + perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; + psprite.sortingOrder = 20; + switch (EligibleHits[currentHitInList].pea.type) + { + case 0: + psprite.sortingOrder = 101; + break; + case 1: + psprite.sortingOrder = 104; + break; + case 2: + psprite.sortingOrder = 103; + break; + case 3: + psprite.sortingOrder = 102; + break; + } + + GameObject hitFXo = new GameObject(); + hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f); + hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f); + SpriteRenderer hfxs = hitFXo.AddComponent(); + hfxs.sprite = hitFX; + hfxs.sortingOrder = 100; + hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); + + FastEffectHit(EligibleHits[currentHitInList].pea.type); + + Jukebox.PlayOneShot("stab"); + + currentPerfectPeasOnFork++; + + if (EligibleHits[currentHitInList].pea.type == 1) + { + topbun = true; + } + else if (EligibleHits[currentHitInList].pea.type == 2) + { + middleburger = true; + } + else if (EligibleHits[currentHitInList].pea.type == 3) + { + bottombun = true; + } + + RemovePea(); + + GoForAPerfect.instance.Hit(); + GameProfiler.instance.IncreaseScore(); + } + else if (EligibleHits[currentHitInList].early) + { + pea.transform.parent = early.transform; + pea.transform.localScale = Vector2.one; + + pea.transform.localPosition = Vector3.zero; + pea.transform.localRotation = Quaternion.Euler(0, 0, 90); + + for (int i = 0; i < early.transform.childCount; i++) + { + early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; + psprite.sortingOrder = 20; + HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); + HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); + HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); + HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); + + FastEffectHit(EligibleHits[currentHitInList].pea.type); + + Jukebox.PlayOneShot("miss"); + + currentEarlyPeasOnFork++; + + RemovePea(); + + GoForAPerfect.instance.Miss(); + } + else if (EligibleHits[currentHitInList].late) + { + pea.transform.parent = late.transform; + pea.transform.localScale = Vector2.one; + + pea.transform.localPosition = Vector3.zero; + pea.transform.localRotation = Quaternion.Euler(0, 0, 90); + + for (int i = 0; i < late.transform.childCount; i++) + { + late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork); + } + + SpriteRenderer psprite = pea.AddComponent(); + psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type]; + psprite.sortingOrder = 20; + HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f)); + HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f)); + HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f)); + HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f)); + + FastEffectHit(EligibleHits[currentHitInList].pea.type); + + Jukebox.PlayOneShot("miss"); + + currentLatePeasOnFork++; + + RemovePea(); + + GoForAPerfect.instance.Miss(); + } + } + else + { + Jukebox.PlayOneShot("stabnohit"); + } + + anim.Play("Player_Stab", 0, 0); + } + + private void FastEffectHit(int type) + { + GameObject hitFX2o = new GameObject(); + hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f); + hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f); + hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f); + SpriteRenderer hfx2s = hitFX2o.AddComponent(); + if (type == 2) + hfx2s.sprite = hitFXG; + else + hfx2s.sprite = hitFX2; + hfx2s.sortingOrder = -5; + hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); }); + } + + private void HitFXMiss(Vector2 pos, Vector2 size) + { + GameObject hitFXo = new GameObject(); + hitFXo.transform.localPosition = new Vector3(pos.x, pos.y); + hitFXo.transform.localScale = new Vector3(size.x, size.y); + SpriteRenderer hfxs = hitFXo.AddComponent(); + hfxs.sprite = hitFXMiss; + hfxs.sortingOrder = 100; + hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); }); + } + + private void RemovePea() + { + if (currentHitInList < EligibleHits.Count) + { + Destroy(EligibleHits[currentHitInList].pea.gameObject); + EligibleHits.Remove(EligibleHits[currentHitInList]); + currentHitInList++; + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/ForkLifter/ForkLifterPlayer.cs.meta b/Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs.meta similarity index 100% rename from Assets/Scripts/ForkLifter/ForkLifterPlayer.cs.meta rename to Assets/Scripts/Games/ForkLifter/ForkLifterPlayer.cs.meta diff --git a/Assets/Scripts/Games/ForkLifter/Pea.cs b/Assets/Scripts/Games/ForkLifter/Pea.cs new file mode 100644 index 000000000..a1e95f865 --- /dev/null +++ b/Assets/Scripts/Games/ForkLifter/Pea.cs @@ -0,0 +1,117 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania.Games.ForkLifter +{ + public class Pea : MonoBehaviour + { + [Header("Latency")] + public float earlyTime; + public float perfectTime; + public float lateTime; + public float endTime; + + private Animator anim; + + public float startBeat; + + private bool inList = false; + + public int type; + + private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible(); + + public int estate, pstate, lstate, endstate; + + private void Start() + { + anim = GetComponent(); + Jukebox.PlayOneShot("zoom"); + GetComponentInChildren().sprite = ForkLifter.instance.peaSprites[type]; + + e = new ForkLifterPlayer.Eligible(); + e.pea = this; + + for (int i = 0; i < transform.GetChild(0).childCount; i++) + { + transform.GetChild(0).GetChild(i).GetComponent().sprite = transform.GetChild(0).GetComponent().sprite; + } + } + + private void Update() + { + float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f)); + anim.Play("Flicked_Object", -1, normalizedBeat); + anim.speed = 0; + + // Early State + if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1) + { + estate++; + MakeEligible(true, false, false); + } + // Perfect State + else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1) + { + pstate++; + MakeEligible(false, true, false); + } + // Late State + else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1) + { + lstate++; + MakeEligible(false, false, true); + } + else if (normalizedBeat < earlyTime || normalizedBeat > endTime) + { + MakeInEligible(); + } + + if (normalizedBeat > endTime && endstate <= 1) + { + endstate++; + Jukebox.PlayOneShot("disappointed"); + GoForAPerfect.instance.Miss(); + } + + if (normalizedBeat > 1.35f) + { + MakeInEligible(); + Destroy(this.gameObject); + } + } + + public void MakeEligible(bool early, bool perfect, bool late) + { + // print($"{early}, {perfect}, {late}"); + + if (!inList) + { + e.early = early; + e.perfect = perfect; + e.late = late; + + ForkLifterPlayer.instance.EligibleHits.Add(e); + inList = true; + } + else + { + ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)]; + es.early = early; + es.perfect = perfect; + es.late = late; + } + } + + public void MakeInEligible() + { + if (!inList) return; + + ForkLifterPlayer.instance.EligibleHits.Remove(e); + inList = false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/ForkLifter/Pea.cs.meta b/Assets/Scripts/Games/ForkLifter/Pea.cs.meta similarity index 100% rename from Assets/Scripts/ForkLifter/Pea.cs.meta rename to Assets/Scripts/Games/ForkLifter/Pea.cs.meta diff --git a/Assets/Scripts/GlobalGameManager.cs b/Assets/Scripts/GlobalGameManager.cs index f703ab9e7..c2231b124 100644 --- a/Assets/Scripts/GlobalGameManager.cs +++ b/Assets/Scripts/GlobalGameManager.cs @@ -5,88 +5,92 @@ using UnityEngine.SceneManagement; using UnityEngine.UI; using DG.Tweening; -public class GlobalGameManager : MonoBehaviour +namespace RhythmHeavenMania { - public static GlobalGameManager instance { get; set; } - - public static int loadedScene; - public int lastLoadedScene; - public static float fadeDuration; - - public GameObject loadScenePrefab; - public GameObject hourGlass; - - public static string levelLocation; - public static bool officialLevel; - - public enum Scenes : int + public class GlobalGameManager : MonoBehaviour { - SplashScreen = 0, - Menu = 1, - Editor = 2, - Game = 3 - } + public static GlobalGameManager instance { get; set; } - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] - public static void Init() - { - BasicCheck(); + public static int loadedScene; + public int lastLoadedScene; + public static float fadeDuration; - loadedScene = 0; - fadeDuration = 0; - } + public GameObject loadScenePrefab; + public GameObject hourGlass; - public void Awake() - { - Init(); - DontDestroyOnLoad(this.gameObject); - instance = this; - Starpelly.OS.Windows.ChangeWindowTitle($"Rhythm Heaven Mania DEMO"); - } + public static string levelLocation; + public static bool officialLevel; - public static GameObject CreateFade() - { - GameObject fade = new GameObject(); - DontDestroyOnLoad(fade); - fade.transform.localScale = new Vector3(4000, 4000); - SpriteRenderer sr = fade.AddComponent(); - sr.sprite = Resources.Load("Sprites/GeneralPurpose/Square"); - sr.sortingOrder = 20000; - fade.layer = 5; - return fade; - } - - - public static void BasicCheck() - { - if (FindGGM() == null) + public enum Scenes : int { - GameObject GlobalGameManager = new GameObject("GlobalGameManager"); - GlobalGameManager.name = "GlobalGameManager"; - GlobalGameManager.AddComponent(); + SplashScreen = 0, + Menu = 1, + Editor = 2, + Game = 3 + } + + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] + public static void Init() + { + BasicCheck(); + + loadedScene = 0; + fadeDuration = 0; + } + + public void Awake() + { + Init(); + DontDestroyOnLoad(this.gameObject); + instance = this; + Starpelly.OS.Windows.ChangeWindowTitle($"Rhythm Heaven Mania DEMO"); + } + + public static GameObject CreateFade() + { + GameObject fade = new GameObject(); + DontDestroyOnLoad(fade); + fade.transform.localScale = new Vector3(4000, 4000); + SpriteRenderer sr = fade.AddComponent(); + sr.sprite = Resources.Load("Sprites/GeneralPurpose/Square"); + sr.sortingOrder = 20000; + fade.layer = 5; + return fade; + } + + + public static void BasicCheck() + { + if (FindGGM() == null) + { + GameObject GlobalGameManager = new GameObject("GlobalGameManager"); + GlobalGameManager.name = "GlobalGameManager"; + GlobalGameManager.AddComponent(); + } + } + + public static GameObject FindGGM() + { + if (GameObject.Find("GlobalGameManager") != null) + return GameObject.Find("GlobalGameManager"); + else + return null; + } + + public static void LoadScene(int sceneIndex, float duration = 0.35f) + { + print("bruh"); + BasicCheck(); + loadedScene = sceneIndex; + fadeDuration = duration; + + // DOTween.Clear(true); + // SceneManager.LoadScene(sceneIndex); + + GameObject fade = CreateFade(); + fade.GetComponent().color = new Color(0, 0, 0, 0); + fade.GetComponent().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); }); } } - public static GameObject FindGGM() - { - if (GameObject.Find("GlobalGameManager") != null) - return GameObject.Find("GlobalGameManager"); - else - return null; - } - - public static void LoadScene(int sceneIndex, float duration = 0.35f) - { - print("bruh"); - BasicCheck(); - loadedScene = sceneIndex; - fadeDuration = duration; - - // DOTween.Clear(true); - // SceneManager.LoadScene(sceneIndex); - - GameObject fade = CreateFade(); - fade.GetComponent().color = new Color(0, 0, 0, 0); - fade.GetComponent().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); }); - } -} +} \ No newline at end of file diff --git a/Assets/Scripts/GoForAPerfect.cs b/Assets/Scripts/GoForAPerfect.cs new file mode 100644 index 000000000..4eefae4a7 --- /dev/null +++ b/Assets/Scripts/GoForAPerfect.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania +{ + public class GoForAPerfect : MonoBehaviour + { + public static GoForAPerfect instance { get; set; } + + private Animator pAnim; + + private bool active = false; + + public bool perfect; + + private void Awake() + { + instance = this; + } + + private void Start() + { + pAnim = transform.GetChild(0).GetChild(0).GetComponent(); + perfect = true; + } + + public void Hit() + { + if (!active) return; + pAnim.Play("PerfectIcon_Hit", 0, 0); + } + + public void Miss() + { + if (!active) return; + perfect = false; + + GameProfiler.instance.perfect = false; + + transform.GetChild(0).GetChild(1).gameObject.SetActive(false); + this.GetComponent().Play("GoForAPerfect_Miss"); + Jukebox.PlayOneShot("perfectMiss"); + } + + public void Enable() + { + SetActive(); + transform.GetChild(0).gameObject.SetActive(true); + } + + public void Disable() + { + SetInactive(); + transform.GetChild(0).gameObject.SetActive(false); + } + + public void SetActive() + { + active = true; + } + public void SetInactive() + { + active = false; + } + } + +} \ No newline at end of file diff --git a/Assets/Scripts/UI/GoForAPerfect.cs.meta b/Assets/Scripts/GoForAPerfect.cs.meta similarity index 100% rename from Assets/Scripts/UI/GoForAPerfect.cs.meta rename to Assets/Scripts/GoForAPerfect.cs.meta diff --git a/Assets/Scripts/Jukebox.cs b/Assets/Scripts/Jukebox.cs deleted file mode 100644 index bb403ad03..000000000 --- a/Assets/Scripts/Jukebox.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Jukebox -{ - public enum AudioType - { - OGG, - WAV - } - - /// - /// This is me just idiot-proofing. - /// - public static void BasicCheck() - { - if (FindJukebox() == null) - { - GameObject Jukebox = new GameObject("Jukebox"); - Jukebox.AddComponent(); - Jukebox.tag = "Jukebox"; - } - } - - public static GameObject FindJukebox() - { - if (GameObject.FindGameObjectWithTag("Jukebox") != null) - return GameObject.FindGameObjectWithTag("Jukebox"); - else - return null; - } - - public static void SetVolume(float volume) - { - BasicCheck(); - FindJukebox().GetComponent().volume = volume; - } - - public static void PlayOneShot(string name) - { - GameObject oneShot = new GameObject("oneShot"); - AudioSource aus = oneShot.AddComponent(); - aus.playOnAwake = false; - Sound snd = oneShot.AddComponent(); - snd.clip = Resources.Load($"Sfx/{name}"); - } -} diff --git a/Assets/Scripts/Sound.cs b/Assets/Scripts/Sound.cs deleted file mode 100644 index 00ae8ceba..000000000 --- a/Assets/Scripts/Sound.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Sound : MonoBehaviour -{ - public AudioClip clip; - public float pitch; - - private AudioSource audioSource; - - private void Start() - { - audioSource = GetComponent(); - audioSource.PlayOneShot(clip); - StartCoroutine(play()); - } - - private IEnumerator play() - { - yield return new WaitForSeconds(clip.length); - Destroy(this.gameObject); - } -} diff --git a/Assets/Scripts/UI/GoForAPerfect.cs b/Assets/Scripts/UI/GoForAPerfect.cs deleted file mode 100644 index b0a20e664..000000000 --- a/Assets/Scripts/UI/GoForAPerfect.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class GoForAPerfect : MonoBehaviour -{ - public static GoForAPerfect instance { get; set; } - - private Animator pAnim; - - private bool active = false; - - public bool perfect; - - private void Awake() - { - instance = this; - } - - private void Start() - { - pAnim = transform.GetChild(0).GetChild(0).GetComponent(); - perfect = true; - } - - public void Hit() - { - if (!active) return; - pAnim.Play("PerfectIcon_Hit", 0, 0); - } - - public void Miss() - { - if (!active) return; - perfect = false; - - GameProfiler.instance.perfect = false; - - transform.GetChild(0).GetChild(1).gameObject.SetActive(false); - this.GetComponent().Play("GoForAPerfect_Miss"); - Jukebox.PlayOneShot("perfectMiss"); - } - - public void Enable() - { - SetActive(); - transform.GetChild(0).gameObject.SetActive(true); - } - - public void Disable() - { - SetInactive(); - transform.GetChild(0).gameObject.SetActive(false); - } - - public void SetActive() - { - active = true; - } - public void SetInactive() - { - active = false; - } -} diff --git a/Assets/Scripts/UI/Prologue.cs b/Assets/Scripts/UI/Prologue.cs index e4c9a803c..e9b820266 100644 --- a/Assets/Scripts/UI/Prologue.cs +++ b/Assets/Scripts/UI/Prologue.cs @@ -2,34 +2,38 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class Prologue : MonoBehaviour +namespace RhythmHeavenMania { - [SerializeField] private float waitSeconds; - - public GameObject Holder; - public GameObject pressAny; - - bool inPrologue = false; - - private void Update() + public class Prologue : MonoBehaviour { - if (Input.anyKeyDown && !inPrologue) + [SerializeField] private float waitSeconds; + + public GameObject Holder; + public GameObject pressAny; + + bool inPrologue = false; + + private void Update() { - pressAny.SetActive(false); - Holder.SetActive(true); - StartCoroutine(Wait()); - inPrologue = true; + if (Input.anyKeyDown && !inPrologue) + { + pressAny.SetActive(false); + Holder.SetActive(true); + StartCoroutine(Wait()); + inPrologue = true; + } + } + + IEnumerator Wait() + { + transform.GetChild(0).gameObject.SetActive(false); + yield return new WaitForSeconds(1); + transform.GetChild(0).gameObject.SetActive(true); + yield return new WaitForSeconds(waitSeconds); + transform.GetChild(0).gameObject.SetActive(false); + yield return new WaitForSeconds(2); + UnityEngine.SceneManagement.SceneManager.LoadScene(1); } } - IEnumerator Wait() - { - transform.GetChild(0).gameObject.SetActive(false); - yield return new WaitForSeconds(1); - transform.GetChild(0).gameObject.SetActive(true); - yield return new WaitForSeconds(waitSeconds); - transform.GetChild(0).gameObject.SetActive(false); - yield return new WaitForSeconds(2); - UnityEngine.SceneManagement.SceneManager.LoadScene(1); - } -} +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Rating.cs b/Assets/Scripts/UI/Rating.cs index 49e0949b7..3efc86fda 100644 --- a/Assets/Scripts/UI/Rating.cs +++ b/Assets/Scripts/UI/Rating.cs @@ -5,135 +5,141 @@ using UnityEngine.UI; using TMPro; using DG.Tweening; -public class Rating : MonoBehaviour +using RhythmHeavenMania.Util; + +namespace RhythmHeavenMania { - public GameObject Title; - public GameObject Desc; - public GameObject Rank; - public GameObject Epilogue; - public GameObject Perfect; - - public GameObject RankingHolder; - - public GameObject Fade; - - private string rank; - private int rankId; - - public Sprite[] epilogueSprites; - public Image epilogueImage; - - public TMP_Text epilogueText; - - private void Start() + public class Rating : MonoBehaviour { - float score = GameProfiler.instance.score; - TMP_Text desc = Desc.GetComponent(); + public GameObject Title; + public GameObject Desc; + public GameObject Rank; + public GameObject Epilogue; + public GameObject Perfect; - if (GameProfiler.instance.perfect) + public GameObject RankingHolder; + + public GameObject Fade; + + private string rank; + private int rankId; + + public Sprite[] epilogueSprites; + public Image epilogueImage; + + public TMP_Text epilogueText; + + private void Start() { - Perfect.SetActive(true); - Jukebox.PlayOneShot("Rankings/ranking_perfect"); - StartCoroutine(PerfectIE()); + float score = GameProfiler.instance.score; + TMP_Text desc = Desc.GetComponent(); + + if (GameProfiler.instance.perfect) + { + Perfect.SetActive(true); + Jukebox.PlayOneShot("Rankings/ranking_perfect"); + StartCoroutine(PerfectIE()); + } + else + { + if (score < 59) + { + // try again + desc.text = "Your fork technique was rather uncouth. \nYour consecutive stabs needed work."; + rank = "Rankings/ranking_tryagain"; + rankId = 2; + } + else if (score >= 59 && score < 79) + { + // ok + desc.text = "Eh. Good enough."; + rank = "Rankings/ranking_ok"; + rankId = 1; + } + else if (score >= 79) + { + // superb + desc.text = "Your fork technique was quite elegant. \nYour consecutive stabs were excellent. \nYour triple-stab technique was sublime."; + rank = "Rankings/ranking_superb"; + rankId = 0; + } + + StartCoroutine(ShowRank()); + } } - else + + private IEnumerator ShowRank() { - if (score < 59) + // Title + yield return new WaitForSeconds(0.5f); + + Jukebox.PlayOneShot("Rankings/ranking_title_show"); + Title.SetActive(true); + + // Desc + yield return new WaitForSeconds(2f); + + Jukebox.PlayOneShot("Rankings/ranking_desc_show"); + Desc.SetActive(true); + + // Rating + yield return new WaitForSeconds(2f); + + Jukebox.PlayOneShot(rank); + Rank.transform.GetChild(rankId).gameObject.SetActive(true); + + // Epilogue + yield return new WaitForSeconds(5f); + Fade.GetComponent().DOColor(Color.black, 0.75f).OnComplete(delegate { - // try again - desc.text = "Your fork technique was rather uncouth. \nYour consecutive stabs needed work."; - rank = "Rankings/ranking_tryagain"; - rankId = 2; - } - else if (score >= 59 && score < 79) + StartCoroutine(ShowEpilogue()); + }); + } + + private IEnumerator ShowEpilogue() + { + epilogueImage.sprite = epilogueSprites[rankId]; + switch (rankId) { - // ok - desc.text = "Eh. Good enough."; - rank = "Rankings/ranking_ok"; - rankId = 1; - } - else if (score >= 79) - { - // superb - desc.text = "Your fork technique was quite elegant. \nYour consecutive stabs were excellent. \nYour triple-stab technique was sublime."; - rank = "Rankings/ranking_superb"; - rankId = 0; + case 2: + epilogueText.text = "Blood sugar...so...low..."; + break; + case 1: + epilogueText.text = "I could eat two more dinners!"; + break; + case 0: + epilogueText.text = "So full! So satisfied!"; + break; + } - StartCoroutine(ShowRank()); + yield return new WaitForSeconds(1); + Fade.GetComponent().color = new Color(0, 0, 0, 0); + RankingHolder.SetActive(false); + Epilogue.SetActive(true); + + switch (rankId) + { + case 0: + Jukebox.PlayOneShot("Rankings/epilogue_superb"); + break; + case 1: + Jukebox.PlayOneShot("Rankings/epilogue_ok"); + break; + case 2: + Jukebox.PlayOneShot("Rankings/epilogue_tryagain"); + break; + } + + yield return new WaitForSeconds(8); + GlobalGameManager.LoadScene(0); + } + + private IEnumerator PerfectIE() + { + yield return new WaitForSeconds(8); + GlobalGameManager.LoadScene(0); } } - private IEnumerator ShowRank() - { - // Title - yield return new WaitForSeconds(0.5f); - - Jukebox.PlayOneShot("Rankings/ranking_title_show"); - Title.SetActive(true); - - // Desc - yield return new WaitForSeconds(2f); - - Jukebox.PlayOneShot("Rankings/ranking_desc_show"); - Desc.SetActive(true); - - // Rating - yield return new WaitForSeconds(2f); - - Jukebox.PlayOneShot(rank); - Rank.transform.GetChild(rankId).gameObject.SetActive(true); - - // Epilogue - yield return new WaitForSeconds(5f); - Fade.GetComponent().DOColor(Color.black, 0.75f).OnComplete(delegate - { - StartCoroutine(ShowEpilogue()); - }); - } - - private IEnumerator ShowEpilogue() - { - epilogueImage.sprite = epilogueSprites[rankId]; - switch (rankId) - { - case 2: - epilogueText.text = "Blood sugar...so...low..."; - break; - case 1: - epilogueText.text = "I could eat two more dinners!"; - break; - case 0: - epilogueText.text = "So full! So satisfied!"; - break; - - } - - yield return new WaitForSeconds(1); - Fade.GetComponent().color = new Color(0, 0, 0, 0); - RankingHolder.SetActive(false); - Epilogue.SetActive(true); - - switch (rankId) - { - case 0: - Jukebox.PlayOneShot("Rankings/epilogue_superb"); - break; - case 1: - Jukebox.PlayOneShot("Rankings/epilogue_ok"); - break; - case 2: - Jukebox.PlayOneShot("Rankings/epilogue_tryagain"); - break; - } - - yield return new WaitForSeconds(8); - GlobalGameManager.LoadScene(0); - } - - private IEnumerator PerfectIE() - { - yield return new WaitForSeconds(8); - GlobalGameManager.LoadScene(0); - } -} +} \ No newline at end of file diff --git a/Assets/Scripts/Util.meta b/Assets/Scripts/Util.meta new file mode 100644 index 000000000..f57137d14 --- /dev/null +++ b/Assets/Scripts/Util.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23db959b7a4cf21438c0b20d9b30b688 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Util/CommonAnimEvents.cs b/Assets/Scripts/Util/CommonAnimEvents.cs new file mode 100644 index 000000000..f34f82630 --- /dev/null +++ b/Assets/Scripts/Util/CommonAnimEvents.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace RhythmHeavenMania.Util +{ + public class CommonAnimEvents : MonoBehaviour + { + public void Destroy() + { + Destroy(this.gameObject); + } + } + +} \ No newline at end of file diff --git a/Assets/Scripts/CommonAnimEvents.cs.meta b/Assets/Scripts/Util/CommonAnimEvents.cs.meta similarity index 100% rename from Assets/Scripts/CommonAnimEvents.cs.meta rename to Assets/Scripts/Util/CommonAnimEvents.cs.meta diff --git a/Assets/Scripts/Util/Jukebox.cs b/Assets/Scripts/Util/Jukebox.cs new file mode 100644 index 000000000..8e9f663e6 --- /dev/null +++ b/Assets/Scripts/Util/Jukebox.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace RhythmHeavenMania.Util +{ + public class Jukebox + { + public enum AudioType + { + OGG, + WAV + } + + /// + /// This is me just idiot-proofing. + /// + public static void BasicCheck() + { + if (FindJukebox() == null) + { + GameObject Jukebox = new GameObject("Jukebox"); + Jukebox.AddComponent(); + Jukebox.tag = "Jukebox"; + } + } + + public static GameObject FindJukebox() + { + if (GameObject.FindGameObjectWithTag("Jukebox") != null) + return GameObject.FindGameObjectWithTag("Jukebox"); + else + return null; + } + + public static void SetVolume(float volume) + { + BasicCheck(); + FindJukebox().GetComponent().volume = volume; + } + + public static void PlayOneShot(string name) + { + GameObject oneShot = new GameObject("oneShot"); + AudioSource aus = oneShot.AddComponent(); + aus.playOnAwake = false; + Sound snd = oneShot.AddComponent(); + snd.clip = Resources.Load($"Sfx/{name}"); + } + } + +} \ No newline at end of file diff --git a/Assets/Scripts/Jukebox.cs.meta b/Assets/Scripts/Util/Jukebox.cs.meta similarity index 100% rename from Assets/Scripts/Jukebox.cs.meta rename to Assets/Scripts/Util/Jukebox.cs.meta diff --git a/Assets/Scripts/Util/Sound.cs b/Assets/Scripts/Util/Sound.cs new file mode 100644 index 000000000..c93d9f5ea --- /dev/null +++ b/Assets/Scripts/Util/Sound.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace RhythmHeavenMania.Util +{ + public class Sound : MonoBehaviour + { + public AudioClip clip; + public float pitch; + + private AudioSource audioSource; + + private void Start() + { + audioSource = GetComponent(); + audioSource.PlayOneShot(clip); + StartCoroutine(play()); + } + + private IEnumerator play() + { + yield return new WaitForSeconds(clip.length); + Destroy(this.gameObject); + } + } +} diff --git a/Assets/Scripts/Sound.cs.meta b/Assets/Scripts/Util/Sound.cs.meta similarity index 100% rename from Assets/Scripts/Sound.cs.meta rename to Assets/Scripts/Util/Sound.cs.meta diff --git a/Assets/Scripts/WTF.cs b/Assets/Scripts/WTF.cs index 73bfe75e4..2bb7990fd 100644 --- a/Assets/Scripts/WTF.cs +++ b/Assets/Scripts/WTF.cs @@ -1,18 +1,21 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; -public class WTF : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } +// this is a script for testing - // Update is called once per frame - void Update() +namespace RhythmHeavenMania.Tests +{ + public class WTF : MonoBehaviour { - + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } } -} +} \ No newline at end of file diff --git a/Assets/Shaders.meta b/Assets/Shaders.meta new file mode 100644 index 000000000..2f838e563 --- /dev/null +++ b/Assets/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ba8fd574a5948a4b9c3bb56e0c57a2d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Invert.mat b/Assets/Shaders/Invert.mat similarity index 100% rename from Assets/Scripts/Invert.mat rename to Assets/Shaders/Invert.mat diff --git a/Assets/Scripts/Invert.mat.meta b/Assets/Shaders/Invert.mat.meta similarity index 100% rename from Assets/Scripts/Invert.mat.meta rename to Assets/Shaders/Invert.mat.meta diff --git a/Assets/Scripts/$dd_Invert.shader b/Assets/Shaders/Invert.shader similarity index 100% rename from Assets/Scripts/$dd_Invert.shader rename to Assets/Shaders/Invert.shader diff --git a/Assets/Scripts/$dd_Invert.shader.meta b/Assets/Shaders/Invert.shader.meta similarity index 100% rename from Assets/Scripts/$dd_Invert.shader.meta rename to Assets/Shaders/Invert.shader.meta