From 286c8621978e82d5ff2eb8bb715b0a1c80c49c1b Mon Sep 17 00:00:00 2001 From: Starpelly Date: Mon, 20 Dec 2021 23:38:59 -0500 Subject: [PATCH] Got rid of all hard-coded ForkLifter code from GameManager. --- Assets/Scenes/Game.unity | 8 +- Assets/Scenes/Test.unity | 251 ++++++++++++++++++ Assets/Scenes/Test.unity.meta | 7 + Assets/Scripts/GameManager.cs | 93 +------ Assets/Scripts/GameProfiler.cs | 2 +- Assets/Scripts/Games/ClappyTrio.meta | 8 + Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs | 14 + .../Games/ClappyTrio/ClappyTrio.cs.meta | 11 + Assets/Scripts/Games/ForkLifter/ForkLifter.cs | 24 ++ .../Games/ForkLifter/ForkLifterHand.cs | 4 +- Assets/Scripts/WTF.cs | 9 +- ProjectSettings/ProjectSettings.asset | 2 +- 12 files changed, 325 insertions(+), 108 deletions(-) create mode 100644 Assets/Scenes/Test.unity create mode 100644 Assets/Scenes/Test.unity.meta create mode 100644 Assets/Scripts/Games/ClappyTrio.meta create mode 100644 Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs create mode 100644 Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 75a33ab1..53774e9b 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -188,7 +188,7 @@ SpriteRenderer: m_Size: {x: 12.8, y: 7.2} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 + m_WasSpriteAssigned: 0 m_MaskInteraction: 0 m_SpriteSortPoint: 0 --- !u!4 &142958111 @@ -1586,7 +1586,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &978514678 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2234,7 +2234,7 @@ SpriteRenderer: m_Size: {x: 12.8, y: 7.2} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 + m_WasSpriteAssigned: 0 m_MaskInteraction: 0 m_SpriteSortPoint: 0 --- !u!4 &1315562762 @@ -2316,7 +2316,7 @@ SpriteRenderer: m_Size: {x: 12.8, y: 7.2} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 + m_WasSpriteAssigned: 0 m_MaskInteraction: 0 m_SpriteSortPoint: 0 --- !u!4 &1317788235 diff --git a/Assets/Scenes/Test.unity b/Assets/Scenes/Test.unity new file mode 100644 index 00000000..17ae818b --- /dev/null +++ b/Assets/Scenes/Test.unity @@ -0,0 +1,251 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &749282583 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 749282586} + - component: {fileID: 749282585} + - component: {fileID: 749282584} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &749282584 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 749282583} + m_Enabled: 1 +--- !u!20 &749282585 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 749282583} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &749282586 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 749282583} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1377032294 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1377032296} + - component: {fileID: 1377032295} + m_Layer: 0 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1377032295 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1377032294} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 490e729f742a40644a3a2abd88fce1a3, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1377032296 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1377032294} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1.7458284, y: -0.54262644, z: 220.13306} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/Test.unity.meta b/Assets/Scenes/Test.unity.meta new file mode 100644 index 00000000..c14e3bff --- /dev/null +++ b/Assets/Scenes/Test.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d4b8980a5e4f8de488c872bd5268587b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index e46ce191..d218cf8f 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -7,9 +7,6 @@ using UnityEngine; using Starpelly; using Newtonsoft.Json; -using RhythmHeavenMania.Games.ForkLifter; -using RhythmHeavenMania.Util; - namespace RhythmHeavenMania { public class GameManager : MonoBehaviour @@ -17,15 +14,11 @@ 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 int currentEvent; public TextAsset txt; - public bool autoplay = false; - public float startOffset; [Serializable] @@ -54,30 +47,6 @@ namespace RhythmHeavenMania 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(); @@ -87,20 +56,10 @@ namespace RhythmHeavenMania { 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; @@ -110,54 +69,9 @@ namespace RhythmHeavenMania { 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++; - } - } - } } public void SortEventsList() @@ -172,11 +86,6 @@ namespace RhythmHeavenMania 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)); - } } diff --git a/Assets/Scripts/GameProfiler.cs b/Assets/Scripts/GameProfiler.cs index f1e9c5b5..1962dfd7 100644 --- a/Assets/Scripts/GameProfiler.cs +++ b/Assets/Scripts/GameProfiler.cs @@ -26,7 +26,7 @@ namespace RhythmHeavenMania public void IncreaseScore() { totalHits++; - score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count); + // score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count); broken right now will fix eventually } public float GetPercent(float value, float totalValue) diff --git a/Assets/Scripts/Games/ClappyTrio.meta b/Assets/Scripts/Games/ClappyTrio.meta new file mode 100644 index 00000000..7cb8a4c6 --- /dev/null +++ b/Assets/Scripts/Games/ClappyTrio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18fa454b7a49ea94fa7d33add3f9ebec +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs new file mode 100644 index 00000000..fef4fdd6 --- /dev/null +++ b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace RhythmHeavenMania.Games.ClappyTrio +{ + public class ClappyTrio : MonoBehaviour + { + void Start() + { + Debug.Log("ClappyTrio"); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta new file mode 100644 index 00000000..7ac76e1f --- /dev/null +++ b/Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a7c8ebd2f1b0ce448acc55b6f6608e15 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifter.cs b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs index 88925e72..53a89367 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifter.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifter.cs @@ -12,6 +12,8 @@ namespace RhythmHeavenMania.Games.ForkLifter GameManager GameManager; + public List allPlayerActions = new List(); + [Header("Objects")] public Animator handAnim; public GameObject flickedObject; @@ -28,6 +30,28 @@ namespace RhythmHeavenMania.Games.ForkLifter private void Start() { GameManager = GameManager.instance; + allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end"); + + /*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);*/ } public void Flick(float beat, int type) diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs index ef5f9b77..1fb12705 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs @@ -26,7 +26,7 @@ namespace RhythmHeavenMania.Games.ForkLifter { allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare"); - if (GameManager.instance.currentEventPlayer < allPlayerActions.Count) + /*if (GameManager.instance.currentEventPlayer < allPlayerActions.Count) { switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName) { @@ -51,7 +51,7 @@ namespace RhythmHeavenMania.Games.ForkLifter else { ForkLifter.instance.peaPreview.sprite = null; - } + }*/ } public void Prepare() diff --git a/Assets/Scripts/WTF.cs b/Assets/Scripts/WTF.cs index 2bb7990f..71323c03 100644 --- a/Assets/Scripts/WTF.cs +++ b/Assets/Scripts/WTF.cs @@ -9,13 +9,6 @@ namespace RhythmHeavenMania.Tests // 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/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3db5ab22..7bec10c1 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -153,7 +153,7 @@ PlayerSettings: androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 applicationIdentifier: - Standalone: com.DefaultCompany.RhythmHeavenMania + Standalone: com.Starpelly.RhythmHeavenMania buildNumber: Standalone: 0 iPhone: 0