diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 230f2709..5f6ae058 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -7476,7 +7476,7 @@ Camera: y: 0 width: 1 height: 1 - near clip plane: 0.3 + near clip plane: 0.01 far clip plane: 1000 field of view: 53.15 orthographic: 0 @@ -14209,7 +14209,7 @@ MonoBehaviour: currentEvent: 0 currentPlayerEvent: 0 txt: {fileID: 4900000, guid: 50b54b23c06076c4598134813da27f18, type: 3} - startOffset: 0 + startOffset: 0.5 GameCamera: {fileID: 519420031} CursorCam: {fileID: 79134728} CircleCursor: {fileID: 1855769658} diff --git a/Assets/Scripts/EventCaller.cs b/Assets/Scripts/EventCaller.cs index e6e07b70..24e00881 100644 --- a/Assets/Scripts/EventCaller.cs +++ b/Assets/Scripts/EventCaller.cs @@ -90,7 +90,7 @@ namespace RhythmHeavenMania { new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, true ), new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(currentBeat, true, currentType); }, true ), - new GameAction("cameraZoom", delegate { Spaceball.instance.CameraZoom(currentBeat, currentLength, currentValA); } ), + // new GameAction("cameraZoom", delegate { Spaceball.instance.CameraZoom(currentBeat, currentLength, currentValA); } ), }) }; @@ -148,7 +148,21 @@ namespace RhythmHeavenMania } } - public static List GetAllInGameManagerList(string gameName, string[] exclude) + public static List GetAllInGameManagerList(string gameName, string[] include) + { + 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 (include.Any(temp1[i].datamodel.Split('/')[1].Contains)) + { + temp2.Add(temp1[i]); + } + } + return temp2; + } + + public static List GetAllInGameManagerListExclude(string gameName, string[] exclude) { List temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName); List temp2 = new List(); diff --git a/Assets/Scripts/EventCaller.cs.meta b/Assets/Scripts/EventCaller.cs.meta index ff770da7..140d2a56 100644 --- a/Assets/Scripts/EventCaller.cs.meta +++ b/Assets/Scripts/EventCaller.cs.meta @@ -4,7 +4,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: 150 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 453821d1..74a6148b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -37,7 +37,8 @@ namespace RhythmHeavenMania instance = this; } - private void Start() + // before Start() since this is very important + private void OnEnable() { SortEventsList(); @@ -71,11 +72,14 @@ namespace RhythmHeavenMania if (Input.GetKeyDown(KeyCode.A)) { Conductor.instance.musicSource.time += 3; + SetCurrentEventToClosest(); + GetGame(currentGame).holder.GetComponent().OnTimeChange(); } else if (Input.GetKeyDown(KeyCode.S)) { Conductor.instance.musicSource.time -= 3; - GameManager.instance.SetCurrentEventToClosest(); + SetCurrentEventToClosest(); + GetGame(currentGame).holder.GetComponent().OnTimeChange(); } List entities = Beatmap.entities.Select(c => c.beat).ToList(); @@ -84,9 +88,18 @@ namespace RhythmHeavenMania { if (Conductor.instance.songPositionInBeats >= entities[currentEvent]) { - eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel); + // allows for multiple events on the same beat to be executed on the same frame, so no more 1-frame delay + List entitesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentEvent].beat); - currentEvent++; + for (int i = 0; i < entitesAtSameBeat.Count; i++) + { + eventCaller.CallEvent(entitesAtSameBeat[i].datamodel); + currentEvent++; + } + + // eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel); + + // currentEvent++; } } } diff --git a/Assets/Scripts/Games/ClappyTrio/ClappyTrioPlayer.cs b/Assets/Scripts/Games/ClappyTrio/ClappyTrioPlayer.cs index fa161cf8..0272a209 100644 --- a/Assets/Scripts/Games/ClappyTrio/ClappyTrioPlayer.cs +++ b/Assets/Scripts/Games/ClappyTrio/ClappyTrioPlayer.cs @@ -60,18 +60,17 @@ namespace RhythmHeavenMania.Games.ClappyTrio lastClapLength = 0; lastClapBeat = 0; hit = false; - ClearLog(); } } } - public void ClearLog() + /*public void ClearLog() { var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor)); var type = assembly.GetType("UnityEditor.LogEntries"); var method = type.GetMethod("Clear"); method.Invoke(new object(), null); - } + }*/ public void SetClapAvailability(float startBeat, float length) { diff --git a/Assets/Scripts/Games/Minigame.cs b/Assets/Scripts/Games/Minigame.cs index 2c9ddf18..6e49958c 100644 --- a/Assets/Scripts/Games/Minigame.cs +++ b/Assets/Scripts/Games/Minigame.cs @@ -44,5 +44,10 @@ namespace RhythmHeavenMania.Games { } + + public virtual void OnTimeChange() + { + + } } } \ No newline at end of file diff --git a/Assets/Scripts/Games/Spaceball/Spaceball.cs b/Assets/Scripts/Games/Spaceball/Spaceball.cs index 2ac895d4..91885524 100644 --- a/Assets/Scripts/Games/Spaceball/Spaceball.cs +++ b/Assets/Scripts/Games/Spaceball/Spaceball.cs @@ -15,13 +15,16 @@ namespace RhythmHeavenMania.Games.Spaceball public GameObject Dust; private float lastCamDistance; - private bool zoomingCamera = false; - private float lastZoomCamBeat; - private float lastZoomCamLength; - private float lastZoomCamDistance; + private float currentZoomCamBeat; + private float currentZoomCamLength; + private float currentZoomCamDistance; + + private int currentZoomIndex; public Sprite[] Balls; + private List allCameraEvents = new List(); + public static Spaceball instance { get; set; } public override void OnGameSwitch() @@ -32,11 +35,21 @@ namespace RhythmHeavenMania.Games.Spaceball SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count); } + public override void OnTimeChange() + { + UpdateCameraZoom(); + } + private void Awake() { instance = this; } + private void Start() + { + UpdateCameraZoom(); + } + private void Update() { var allPlayerActions = EventCaller.GetAllPlayerEntities("spaceball"); @@ -50,30 +63,56 @@ namespace RhythmHeavenMania.Games.Spaceball } } - if (zoomingCamera) + if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0) { - float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(lastZoomCamBeat, lastZoomCamLength); - float newPosZ = Mathf.Lerp(lastCamDistance, lastZoomCamDistance, normalizedBeat); - GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, newPosZ); + if (Conductor.instance.songPositionInBeats >= allCameraEvents[currentZoomIndex].beat) + { + UpdateCameraZoom(); + currentZoomIndex++; + } + } + + float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(currentZoomCamBeat, currentZoomCamLength); + + if (normalizedBeat > Minigame.EndTime()) + { + lastCamDistance = GameManager.instance.GameCamera.transform.localPosition.z; + } + else + { + if (currentZoomCamLength <= 0) + GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, currentZoomCamDistance); + else + { + float newPosZ = Mathf.Lerp(lastCamDistance, currentZoomCamDistance, normalizedBeat); + GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, newPosZ); + } } } - - public void CameraZoom(float beat, float length, float distance) + private void UpdateCameraZoom() { - lastZoomCamBeat = beat; - lastZoomCamLength = length; + allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "cameraZoom" }); - float dist = distance; - dist = dist * -1; + if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0) + { + if (currentZoomIndex - 1 >= 0) + lastCamDistance = allCameraEvents[currentZoomIndex - 1].valA * -1; + else + lastCamDistance = allCameraEvents[0].valA * -1; - if (dist > 0) - lastZoomCamDistance = 0; - else - lastZoomCamDistance = dist; + currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat; + currentZoomCamLength = allCameraEvents[currentZoomIndex].length; - zoomingCamera = true; - lastCamDistance = GameManager.instance.GameCamera.transform.localPosition.z; + float dist = allCameraEvents[currentZoomIndex].valA * -1; + + print(dist); + + if (dist > 0) + currentZoomCamDistance = 0; + else + currentZoomCamDistance = dist; + } } public void Shoot(float beat, bool high, string type) diff --git a/Assets/Scripts/Games/Spaceball/SpaceballBall.cs b/Assets/Scripts/Games/Spaceball/SpaceballBall.cs index 44aa527f..2976769d 100644 --- a/Assets/Scripts/Games/Spaceball/SpaceballBall.cs +++ b/Assets/Scripts/Games/Spaceball/SpaceballBall.cs @@ -73,6 +73,10 @@ namespace RhythmHeavenMania.Games.Spaceball Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true); Destroy(this.gameObject); } + else if (Conductor.instance.songPositionInBeats < startBeat) + { + Destroy(this.gameObject); + } } public void MakeEligible(bool early, bool perfect, bool late) diff --git a/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs b/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs index b79ed268..4f50e37f 100644 --- a/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs +++ b/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs @@ -45,7 +45,7 @@ namespace RhythmHeavenMania.Games.Spaceball if (EligibleHits[currentHitInList].perfect) { Jukebox.PlayOneShotGame("spaceball/hit"); - EligibleHits[currentHitInList].gameObject.GetComponent().Holder.transform.DOMove(new Vector3(Random.Range(5, 25), 0, -600), 5f); + EligibleHits[currentHitInList].gameObject.GetComponent().Holder.transform.DOLocalMove(new Vector3(Random.Range(0, 8), 0, -600), 5f); EligibleHits[currentHitInList].gameObject.GetComponent().enabled = false; EligibleHits[currentHitInList].gameObject.GetComponent().enabled = false; diff --git a/Assets/spaceball.json b/Assets/spaceball.json index 2faab007..3e35e4c5 100644 --- a/Assets/spaceball.json +++ b/Assets/spaceball.json @@ -1,23 +1,29 @@ { "bpm": 105, "entities": [ + { + "beat": 0, + "length": 0, + "valA": 170, + "datamodel": "spaceball/cameraZoom" + }, + { + "beat": 0, + "length": 4, + "valA": 10, + "datamodel":"spaceball/cameraZoom" + }, { "beat": 4, "type": "riceball", "datamodel": "spaceball/shoot" }, { - "beat": 4, + "beat": 8, "length": 42, "valA": 30, "datamodel": "spaceball/cameraZoom" }, - { - "beat": 44, - "length": 2, - "valA": 170, - "datamodel": "spaceball/cameraZoom" - }, { "beat": 6, "datamodel": "spaceball/shoot" @@ -43,12 +49,12 @@ "datamodel": "gameManager/switchGame/clappyTrio" }, { - "beat": 16, + "beat": 17, "length": 2, "datamodel": "clappyTrio/clap" }, { - "beat": 21, + "beat": 22, "datamodel": "gameManager/switchGame/spaceball" }, { @@ -104,6 +110,12 @@ { "beat": 44, "datamodel": "spaceball/shootHigh" + }, + { + "beat": 44, + "length": 2, + "valA": 170, + "datamodel": "spaceball/cameraZoom" } ] } \ No newline at end of file diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index ff758a40..370f10b4 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -5,13 +5,7 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 m_Scenes: - - enabled: 1 - path: Assets/Scenes/Menu.unity - guid: 1acb71090c3028849a57a2c234e53a6d - enabled: 1 path: Assets/Scenes/Game.unity guid: 2cda990e2423bbf4892e6590ba056729 - - enabled: 1 - path: Assets/Scenes/Rating.unity - guid: 536b14300e086f04785985e8e915ca09 m_configObjects: {}