diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 9e4aca16..97ada52a 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -6595,7 +6595,6 @@ GameObject: - component: {fileID: 2072389417} - component: {fileID: 2072389418} - component: {fileID: 2072389419} - - component: {fileID: 2072389420} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -6632,7 +6631,9 @@ MonoBehaviour: Beatmap: bpm: 0 entities: [] + playerEntities: [] currentEvent: 0 + currentPlayerEvent: 0 txt: {fileID: 4900000, guid: cbe1a43c8ddc790498fde2e01e66d23e, type: 3} startOffset: 1 --- !u!212 &2072389418 @@ -6700,18 +6701,6 @@ MonoBehaviour: m_EditorClassIdentifier: GamesHolder: {fileID: 1923614611} minigames: [] ---- !u!114 &2072389420 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2072389415} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b526b8bc5e3c6894a9d30b072c68fa27, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &2127056958 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Conductor.cs.meta b/Assets/Scripts/Conductor.cs.meta index c9d49012..eeb95698 100644 --- a/Assets/Scripts/Conductor.cs.meta +++ b/Assets/Scripts/Conductor.cs.meta @@ -4,7 +4,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: 50 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Assets/Scripts/EventCaller.cs b/Assets/Scripts/EventCaller.cs index f7e90c03..d9dc7734 100644 --- a/Assets/Scripts/EventCaller.cs +++ b/Assets/Scripts/EventCaller.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; @@ -38,11 +39,13 @@ namespace RhythmHeavenMania { public string actionName; public EventCallback function; + public bool playerAction = false; - public GameAction(string actionName, EventCallback function) + public GameAction(string actionName, EventCallback function, bool playerAction = false) { this.actionName = actionName; this.function = function; + this.playerAction = playerAction; } } @@ -50,22 +53,42 @@ namespace RhythmHeavenMania { minigames = new List() { + new MiniGame("gameManager", new List() + { + new GameAction("end", delegate { Debug.Log("end"); }) + }), new MiniGame("forkLifter", new List() { - new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); } ), - new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); } ), - new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); } ), - new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); } ), + new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); }, true ), + new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); }, true ), + new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); }, true ), + new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); }, true ), new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }), new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }), new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); }) }) }; - for (int i = 0; i < minigames.Count; i++) + for (int i = 1; i < minigames.Count; i++) { minigames[i].holder = GamesHolder.Find(minigames[i].name).gameObject; } + + for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++) + { + string[] e = GameManager.instance.Beatmap.entities[i].datamodel.Split('/'); + try + { + if (minigames.Find(c => c.name == e[0]).actions.Find(c => c.actionName == e[1]).playerAction == true) + { + GameManager.instance.playerEntities.Add(GameManager.instance.Beatmap.entities[i]); + } + } + catch (Exception ex) + { + Debug.LogWarning(ex); + } + } } private void Update() @@ -74,7 +97,7 @@ namespace RhythmHeavenMania currentBeat = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].beat; } - public void CallEvent(string event_, float beat) + public void CallEvent(string event_) { string[] details = event_.Split('/'); MiniGame game = minigames.Find(c => c.name == details[0]); @@ -83,11 +106,28 @@ namespace RhythmHeavenMania { GameAction action = game.actions.Find(c => c.actionName == details[1]); action.function.Invoke(); + + if (action.playerAction == true) + GameManager.instance.currentPlayerEvent++; } catch (Exception ex) { Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented."); } } + + public static List GetAllInGameManagerListExcept(string gameName, string[] exclude) + { + List temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName); + List temp2 = new List(); + for (int i = 0; i < temp1.Count; i++) + { + if (!exclude.Any(temp1[i].datamodel.Split('/')[1].Contains)) + { + temp2.Add(temp1[i]); + } + } + return temp2; + } } } \ No newline at end of file diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 503d554c..39e7577a 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -15,8 +15,9 @@ namespace RhythmHeavenMania private EventCaller eventCaller; public Beatmap Beatmap; + [HideInInspector] public List playerEntities; - public int currentEvent; + public int currentEvent, currentPlayerEvent; public TextAsset txt; @@ -62,7 +63,7 @@ namespace RhythmHeavenMania { if (Conductor.instance.songPositionInBeats >= entities[currentEvent]) { - eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel, Beatmap.entities[currentEvent].beat); + eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel); currentEvent++; } @@ -79,7 +80,9 @@ namespace RhythmHeavenMania if (Beatmap.entities.Count > 0) { List entities = Beatmap.entities.Select(c => c.beat).ToList(); + List entities_p = playerEntities.Select(c => c.beat).ToList(); currentEvent = entities.IndexOf(Mathp.GetClosestInList(entities, Conductor.instance.songPositionInBeats)); + currentPlayerEvent = entities_p.IndexOf(Mathp.GetClosestInList(entities_p, Conductor.instance.songPositionInBeats)); } } diff --git a/Assets/Scripts/GameManager.cs.meta b/Assets/Scripts/GameManager.cs.meta index 6b02dfc7..f5da0c3f 100644 --- a/Assets/Scripts/GameManager.cs.meta +++ b/Assets/Scripts/GameManager.cs.meta @@ -4,7 +4,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: 100 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs index 5b324907..63587ddd 100644 --- a/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs +++ b/Assets/Scripts/Games/ForkLifter/ForkLifterHand.cs @@ -13,15 +13,15 @@ namespace RhythmHeavenMania.Games.ForkLifter public Sprite[] fastSprites; - // List allPlayerActions; + List allPlayerActions; public void CheckNextFlick() { - // allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare"); + allPlayerActions = EventCaller.GetAllInGameManagerListExcept("forkLifter", new string[] { "gulp", "sigh", "prepare" }); - /*if (GameManager.instance.currentEventPlayer < allPlayerActions.Count) + if (GameManager.instance.currentPlayerEvent < allPlayerActions.Count) { - switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName) + switch (allPlayerActions[GameManager.instance.currentPlayerEvent].datamodel.Split('/')[1]) { case "pea": ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0]; @@ -44,7 +44,7 @@ namespace RhythmHeavenMania.Games.ForkLifter else { ForkLifter.instance.peaPreview.sprite = null; - }*/ + } } public void Prepare() diff --git a/Assets/forklifter.json b/Assets/forklifter.json index df7983e1..a4f85953 100644 --- a/Assets/forklifter.json +++ b/Assets/forklifter.json @@ -421,12 +421,12 @@ }, { "beat": 201, - "datamodel": "sigh" + "datamodel": "forkLifter/sigh" }, {"beat":8.0,"datamodel":"forkLifter/prepare"},{"beat":12.0,"datamodel":"forkLifter/prepare"},{"beat":17.0,"datamodel":"forkLifter/prepare"},{"beat":20.0,"datamodel":"forkLifter/prepare"},{"beat":24.0,"datamodel":"forkLifter/prepare"},{"beat":28.0,"datamodel":"forkLifter/prepare"},{"beat":33.0,"datamodel":"forkLifter/prepare"},{"beat":36.0,"datamodel":"forkLifter/prepare"},{"beat":40.0,"datamodel":"forkLifter/prepare"},{"beat":44.0,"datamodel":"forkLifter/prepare"},{"beat":48.0,"datamodel":"forkLifter/prepare"},{"beat":52.0,"datamodel":"forkLifter/prepare"},{"beat":56.0,"datamodel":"forkLifter/prepare"},{"beat":61.0,"datamodel":"forkLifter/prepare"},{"beat":64.0,"datamodel":"forkLifter/prepare"},{"beat":68.0,"datamodel":"forkLifter/prepare"},{"beat":72.0,"datamodel":"forkLifter/prepare"},{"beat":76.0,"datamodel":"forkLifter/prepare"},{"beat":80.0,"datamodel":"forkLifter/prepare"},{"beat":84.5,"datamodel":"forkLifter/prepare"},{"beat":89.0,"datamodel":"forkLifter/prepare"},{"beat":92.0,"datamodel":"forkLifter/prepare"},{"beat":97.0,"datamodel":"forkLifter/prepare"},{"beat":100.0,"datamodel":"forkLifter/prepare"},{"beat":104.0,"datamodel":"forkLifter/prepare"},{"beat":108.0,"datamodel":"forkLifter/prepare"},{"beat":113.0,"datamodel":"forkLifter/prepare"},{"beat":116.0,"datamodel":"forkLifter/prepare"},{"beat":120.0,"datamodel":"forkLifter/prepare"},{"beat":124.0,"datamodel":"forkLifter/prepare"},{"beat":129.0,"datamodel":"forkLifter/prepare"},{"beat":132.0,"datamodel":"forkLifter/prepare"},{"beat":136.5,"datamodel":"forkLifter/prepare"},{"beat":140.0,"datamodel":"forkLifter/prepare"},{"beat":144.5,"datamodel":"forkLifter/prepare"},{"beat":148.0,"datamodel":"forkLifter/prepare"},{"beat":152.5,"datamodel":"forkLifter/prepare"},{"beat":156.0,"datamodel":"forkLifter/prepare"},{"beat":160.5,"datamodel":"forkLifter/prepare"},{"beat":164.0,"datamodel":"forkLifter/prepare"},{"beat":168.5,"datamodel":"forkLifter/prepare"},{"beat":172.0,"datamodel":"forkLifter/prepare"},{"beat":176.5,"datamodel":"forkLifter/prepare"},{"beat":180.0,"datamodel":"forkLifter/prepare"},{"beat":184.5,"datamodel":"forkLifter/prepare"},{"beat":187.5,"datamodel":"forkLifter/prepare"},{"beat":192.0,"datamodel":"forkLifter/prepare"},{"beat":195.0,"datamodel":"forkLifter/prepare"} , { "beat": 206, - "datamodel": "end" + "datamodel": "gameManager/end" } ] \ No newline at end of file diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 00000000..6f3e60fd --- /dev/null +++ b/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,167 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": false + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "ignore": true, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "ignore": false, + "defaultInstantiationMode": 0, + "supportsModification": true + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "ignore": false, + "defaultInstantiationMode": 1, + "supportsModification": true + }, + "newSceneOverride": 0 +} \ No newline at end of file