mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:57:39 +02:00
Got rid of all hard-coded ForkLifter code from GameManager.
This commit is contained in:
@ -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<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 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<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());
|
||||
|
||||
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<float> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
8
Assets/Scripts/Games/ClappyTrio.meta
Normal file
8
Assets/Scripts/Games/ClappyTrio.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18fa454b7a49ea94fa7d33add3f9ebec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs
Normal file
14
Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta
Normal file
11
Assets/Scripts/Games/ClappyTrio/ClappyTrio.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7c8ebd2f1b0ce448acc55b6f6608e15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -12,6 +12,8 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
GameManager GameManager;
|
||||
|
||||
public List<GameManager.Event> allPlayerActions = new List<GameManager.Event>();
|
||||
|
||||
[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<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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user