Got rid of all hard-coded ForkLifter code from GameManager.

This commit is contained in:
Starpelly 2021-12-20 23:38:59 -05:00
parent 6040f859a9
commit 1bdf6c68e8
12 changed files with 325 additions and 108 deletions

View file

@ -188,7 +188,7 @@ SpriteRenderer:
m_Size: {x: 12.8, y: 7.2} m_Size: {x: 12.8, y: 7.2}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 0
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!4 &142958111 --- !u!4 &142958111
@ -1586,7 +1586,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &978514678 --- !u!114 &978514678
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2234,7 +2234,7 @@ SpriteRenderer:
m_Size: {x: 12.8, y: 7.2} m_Size: {x: 12.8, y: 7.2}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 0
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!4 &1315562762 --- !u!4 &1315562762
@ -2316,7 +2316,7 @@ SpriteRenderer:
m_Size: {x: 12.8, y: 7.2} m_Size: {x: 12.8, y: 7.2}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 0
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!4 &1317788235 --- !u!4 &1317788235

251
Assets/Scenes/Test.unity Normal file
View file

@ -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}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d4b8980a5e4f8de488c872bd5268587b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -7,9 +7,6 @@ using UnityEngine;
using Starpelly; using Starpelly;
using Newtonsoft.Json; using Newtonsoft.Json;
using RhythmHeavenMania.Games.ForkLifter;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania namespace RhythmHeavenMania
{ {
public class GameManager : MonoBehaviour public class GameManager : MonoBehaviour
@ -17,15 +14,11 @@ namespace RhythmHeavenMania
public static GameManager instance; public static GameManager instance;
public List<Event> Events = new List<Event>(); public List<Event> Events = new List<Event>();
public List<float> AutoPlay = new List<float>();
public List<Event> allPlayerActions = new List<Event>();
public int currentEvent, currentEventAutoplay, currentEventPlayer; public int currentEvent;
public TextAsset txt; public TextAsset txt;
public bool autoplay = false;
public float startOffset; public float startOffset;
[Serializable] [Serializable]
@ -54,30 +47,6 @@ namespace RhythmHeavenMania
SortEventsList(); 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<Event> temp = new List<Event>();
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()); StartCoroutine(Begin());
GlobalGameManager.Init(); GlobalGameManager.Init();
@ -87,20 +56,10 @@ namespace RhythmHeavenMania
{ {
yield return new WaitForSeconds(startOffset); yield return new WaitForSeconds(startOffset);
Conductor.instance.musicSource.Play(); Conductor.instance.musicSource.Play();
GoForAPerfect.instance.Enable();
} }
private void Update() 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) if (Events.Count < 1)
return; return;
@ -110,54 +69,9 @@ namespace RhythmHeavenMania
{ {
if (Conductor.instance.songPositionInBeats >= floats[currentEvent]) 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++; currentEvent++;
} }
} }
if (autoplay)
{
if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0)
{
if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay])
{
ForkLifterPlayer.instance.Stab();
currentEventAutoplay++;
}
}
}
} }
public void SortEventsList() public void SortEventsList()
@ -172,11 +86,6 @@ namespace RhythmHeavenMania
List<float> floats = Events.Select(c => c.spawnTime).ToList(); List<float> floats = Events.Select(c => c.spawnTime).ToList();
currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats)); 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));
}
} }

View file

@ -26,7 +26,7 @@ namespace RhythmHeavenMania
public void IncreaseScore() public void IncreaseScore()
{ {
totalHits++; 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) public float GetPercent(float value, float totalValue)

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18fa454b7a49ea94fa7d33add3f9ebec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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");
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7c8ebd2f1b0ce448acc55b6f6608e15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -12,6 +12,8 @@ namespace RhythmHeavenMania.Games.ForkLifter
GameManager GameManager; GameManager GameManager;
public List<GameManager.Event> allPlayerActions = new List<GameManager.Event>();
[Header("Objects")] [Header("Objects")]
public Animator handAnim; public Animator handAnim;
public GameObject flickedObject; public GameObject flickedObject;
@ -28,6 +30,28 @@ namespace RhythmHeavenMania.Games.ForkLifter
private void Start() private void Start()
{ {
GameManager = GameManager.instance; GameManager = GameManager.instance;
allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
/*List<Event> temp = new List<Event>();
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) public void Flick(float beat, int type)

View file

@ -26,7 +26,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
{ {
allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare"); 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) switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName)
{ {
@ -51,7 +51,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
else else
{ {
ForkLifter.instance.peaPreview.sprite = null; ForkLifter.instance.peaPreview.sprite = null;
} }*/
} }
public void Prepare() public void Prepare()

View file

@ -9,13 +9,6 @@ namespace RhythmHeavenMania.Tests
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
} }
}
// Update is called once per frame
void Update()
{
}
}
} }

View file

@ -153,7 +153,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1 androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: applicationIdentifier:
Standalone: com.DefaultCompany.RhythmHeavenMania Standalone: com.Starpelly.RhythmHeavenMania
buildNumber: buildNumber:
Standalone: 0 Standalone: 0
iPhone: 0 iPhone: 0