From c958e20ceb38552fd3c6db33f44b1dd1ff61dc8f Mon Sep 17 00:00:00 2001 From: Braedon Date: Thu, 3 Feb 2022 22:25:18 -0500 Subject: [PATCH] Spaceball camera and more entity parameters. (ugly UI) --- Assets/Scenes/Editor.unity | 23 ++++------ Assets/Scripts/Games/Spaceball/Spaceball.cs | 20 +++++---- Assets/Scripts/LevelEditor/BoxSelection.cs | 2 +- Assets/Scripts/LevelEditor/Editor.cs | 16 +------ .../EventSelector/EventParameterManager.cs | 42 +++++++++++++++++-- .../EventSelector/EventPropertyPrefab.cs | 6 +++ .../Scripts/LevelEditor/Timeline/Timeline.cs | 26 ++++++++++++ .../LevelEditor/Timeline/TimelineEventObj.cs | 6 ++- Assets/Scripts/Minigames.cs | 2 +- 9 files changed, 97 insertions(+), 46 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 635a0a1b..c1e9c572 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -3160,6 +3160,7 @@ MonoBehaviour: m_EditorClassIdentifier: caption: {fileID: 5490985} slider: {fileID: 2067224779} + inputField: {fileID: 1182082595} parameterManager: {fileID: 830452354} --- !u!1 &411779173 GameObject: @@ -6970,6 +6971,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: eventSelector: {fileID: 1056099131} + gridGameSelector: {fileID: 1154875947} IntegerP: {fileID: 396879232} entity: beat: 0 @@ -9428,14 +9430,14 @@ MonoBehaviour: m_VerticalScrollbarEventHandler: {fileID: 0} m_LayoutGroup: {fileID: 0} m_ScrollSensitivity: 1 - m_ContentType: 0 + m_ContentType: 2 m_InputType: 0 m_AsteriskChar: 42 - m_KeyboardType: 0 + m_KeyboardType: 4 m_LineType: 0 m_HideMobileInput: 0 m_HideSoftKeyboard: 0 - m_CharacterValidation: 0 + m_CharacterValidation: 2 m_RegexValue: m_GlobalPointSize: 14 m_CharacterLimit: 0 @@ -11140,6 +11142,7 @@ MonoBehaviour: ScreenRenderTexture: {fileID: 8400000, guid: d3f3d6ca32122da4d9e3a8e7aa2ede16, type: 2} Screen: {fileID: 558010761} GridGameSelector: {fileID: 1154875943} + eventSelectorBG: {fileID: 110654310} Timeline: {fileID: 1861169747} GameEventSelectorTitle: {fileID: 246861490} NewBTN: {fileID: 1683100750} @@ -15217,19 +15220,7 @@ MonoBehaviour: m_Value: 0 m_OnValueChanged: m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 396879234} - m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.EventPropertyPrefab, Assembly-CSharp - m_MethodName: TestChange - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 + m_Calls: [] --- !u!1 &2127582756 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/Spaceball/Spaceball.cs b/Assets/Scripts/Games/Spaceball/Spaceball.cs index 66f36165..f422d156 100644 --- a/Assets/Scripts/Games/Spaceball/Spaceball.cs +++ b/Assets/Scripts/Games/Spaceball/Spaceball.cs @@ -51,13 +51,14 @@ namespace RhythmHeavenMania.Games.Spaceball private void Start() { - allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "cameraZoom" }); - GameCamera.instance.camera.transform.localPosition = new Vector3(0, 0, -10); + allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "camera" }); + + UpdateCameraZoom(); // can't believe this shit actually works } private void Update() { - /*try + if (allCameraEvents.Count > 0) { if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0) { @@ -72,11 +73,11 @@ namespace RhythmHeavenMania.Games.Spaceball if (normalizedBeat > Minigame.EndTime()) { - lastCamDistance = GameCamera.instance.camera.transform.localPosition.z; + // lastCamDistance = GameCamera.instance.camera.transform.localPosition.z; } else { - if (currentZoomCamLength <= 0) + if (currentZoomCamLength < 0) { GameCamera.instance.camera.transform.localPosition = new Vector3(0, 0, currentZoomCamDistance); } @@ -87,10 +88,6 @@ namespace RhythmHeavenMania.Games.Spaceball } } } - catch (System.Exception ex) - { - // this technically isn't game breaking so oh well - }*/ } private void UpdateCameraZoom() @@ -122,6 +119,11 @@ namespace RhythmHeavenMania.Games.Spaceball } } + public void OverrideCurrentZoom() + { + // lastCamDistance = GameCamera.instance.camera.transform.localPosition.z; + } + public void Shoot(float beat, bool high, int type) { GameObject ball = Instantiate(Ball); diff --git a/Assets/Scripts/LevelEditor/BoxSelection.cs b/Assets/Scripts/LevelEditor/BoxSelection.cs index b9cb6361..b2b67e3a 100644 --- a/Assets/Scripts/LevelEditor/BoxSelection.cs +++ b/Assets/Scripts/LevelEditor/BoxSelection.cs @@ -146,7 +146,7 @@ namespace RhythmHeavenMania.Editor private void SelectEvents() { - if (!Input.GetKey(KeyCode.LeftShift) && !Timeline.instance.InteractingWithEvents()) Selections.instance.DeselectAll(); + if (!Input.GetKey(KeyCode.LeftShift) && !Timeline.instance.InteractingWithEvents() && !Timeline.instance.MouseInRectTransform(Editor.instance.eventSelectorBG)) Selections.instance.DeselectAll(); int selected = 0; diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index d4cc1dfb..4c9a26cd 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -32,6 +32,7 @@ namespace RhythmHeavenMania.Editor [SerializeField] private RenderTexture ScreenRenderTexture; [SerializeField] private RawImage Screen; [SerializeField] private RectTransform GridGameSelector; + public RectTransform eventSelectorBG; [Header("Components")] [SerializeField] private Timeline Timeline; @@ -133,7 +134,7 @@ namespace RhythmHeavenMania.Editor } } - if (Timeline.instance.timelineState.selected == true) + if (Timeline.instance.timelineState.selected) { if (Input.GetMouseButtonUp(0)) { @@ -156,19 +157,6 @@ namespace RhythmHeavenMania.Editor } } - if (Input.GetMouseButtonUp(1)) - { - List selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true); - - if (selectedEvents.Count > 0) - { - for (int i = 0; i < selectedEvents.Count; i++) - { - // EventParameterManager.instance.StartParams(selectedEvents[i].entity); - } - } - } - if (Input.GetKey(KeyCode.LeftControl)) { if (Input.GetKeyDown(KeyCode.O)) diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs index 24bdb242..3a305743 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs @@ -2,18 +2,23 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using RhythmHeavenMania.Editor.Track; + namespace RhythmHeavenMania.Editor { public class EventParameterManager : MonoBehaviour { [Header("General References")] [SerializeField] private GameObject eventSelector; + [SerializeField] private GridGameSelector gridGameSelector; [Header("Property Prefabs")] [SerializeField] private GameObject IntegerP; public Beatmap.Entity entity; + private bool active; + public static EventParameterManager instance { get; set; } private void Awake() @@ -21,8 +26,29 @@ namespace RhythmHeavenMania.Editor instance = this; } + private void Update() + { + if (Input.GetMouseButtonDown(0)) + { + if (!Timeline.instance.MouseInRectTransform(Editor.instance.eventSelectorBG) && active) + { + Disable(); + } + } + } + + public void Disable() + { + active = false; + eventSelector.SetActive(true); + + DestroyParams(); + Editor.instance.SetGameEventTitle($"Select game event for {gridGameSelector.SelectedMinigame}"); + } + public void StartParams(Beatmap.Entity entity) { + active = true; AddParams(entity); } @@ -39,10 +65,7 @@ namespace RhythmHeavenMania.Editor Editor.instance.SetGameEventTitle($"Properties for {entity.datamodel}"); - for (int i = 1; i < transform.childCount; i++) - { - Destroy(transform.GetChild(i).gameObject); - } + DestroyParams(); for (int i = 0; i < action.parameters.Count; i++) { @@ -52,6 +75,8 @@ namespace RhythmHeavenMania.Editor AddParam(propertyName, param, caption); } + + active = true; } } @@ -72,5 +97,14 @@ namespace RhythmHeavenMania.Editor var property = input.GetComponent(); property.SetProperties(propertyName, type, caption); } + + private void DestroyParams() + { + active = false; + for (int i = 1; i < transform.childCount; i++) + { + Destroy(transform.GetChild(i).gameObject); + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs index 8576fe24..9ff5fa96 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs @@ -26,10 +26,16 @@ namespace RhythmHeavenMania.Editor slider.minValue = integer.min; slider.maxValue = integer.max; + + slider.value = Mathf.RoundToInt(System.Convert.ToSingle(parameterManager.entity[propertyName])); + inputField.text = slider.value.ToString(); + + slider.onValueChanged.AddListener(delegate { TestChange(); }); } public void TestChange() { + print("bru"); inputField.text = slider.value.ToString(); parameterManager.entity[propertyName] = (int)slider.value; } diff --git a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs index 0120f38e..f943747b 100644 --- a/Assets/Scripts/LevelEditor/Timeline/Timeline.cs +++ b/Assets/Scripts/LevelEditor/Timeline/Timeline.cs @@ -473,8 +473,11 @@ namespace RhythmHeavenMania.Editor.Track entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1); } + if (addEvent) { + Beatmap.Entity tempEntity = entity; + if (entity == null) { Beatmap.Entity en = new Beatmap.Entity(); @@ -483,12 +486,32 @@ namespace RhythmHeavenMania.Editor.Track GameManager.instance.Beatmap.entities.Add(en); GameManager.instance.SortEventsList(); + + tempEntity = en; } else { GameManager.instance.Beatmap.entities.Add(entity); GameManager.instance.SortEventsList(); } + + // default param value + var game = EventCaller.instance.GetMinigame(eventName.Split(0)); + var ep = EventCaller.instance.GetGameAction(game, eventName.Split(1)).parameters; + + if (ep != null) + { + for (int i = 0; i < ep.Count; i++) + { + object returnVal = ep[i].parameter; + if (ep[i].parameter.GetType() == typeof(EntityTypes.Integer)) + { + returnVal = ((EntityTypes.Integer)ep[i].parameter).val; + } + + tempEntity[ep[i].propertyName] = returnVal; + } + } } eventObjs.Add(eventObj); @@ -500,6 +523,9 @@ namespace RhythmHeavenMania.Editor.Track public void DestroyEventObject(Beatmap.Entity entity) { + if (EventParameterManager.instance.entity == entity) + EventParameterManager.instance.Disable(); + eventObjs.Remove(entity.eventObj); GameManager.instance.Beatmap.entities.Remove(entity); Timeline.instance.eventObjs.Remove(entity.eventObj); diff --git a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs index 4d44d699..014ff237 100644 --- a/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs +++ b/Assets/Scripts/LevelEditor/Timeline/TimelineEventObj.cs @@ -135,7 +135,7 @@ namespace RhythmHeavenMania.Editor.Track { if (!Input.GetKey(KeyCode.LeftShift)) { - Selections.instance.Deselect(this); + // Selections.instance.Deselect(this); } } @@ -249,6 +249,10 @@ namespace RhythmHeavenMania.Editor.Track // OnComplete(); } } + else if (Input.GetMouseButton(1)) + { + EventParameterManager.instance.StartParams(entity); + } } public void OnUp() diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index c683c4a2..346a0ed8 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -127,7 +127,7 @@ namespace RhythmHeavenMania new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentBeat, true, eventCaller.currentType); }, 3), new GameAction("costume", delegate { Spaceball.instance.Costume(eventCaller.currentType); }, 1f, false, new List() { new Param("type", new EntityTypes.Integer(0, 2), "type") } ), new GameAction("alien", delegate { Spaceball.instance.alien.Show(eventCaller.currentBeat); } ), - new GameAction("camera", delegate { }, 4, true ), + new GameAction("camera", delegate { Spaceball.instance.OverrideCurrentZoom(); }, 4, true, new List() { new Param("valA", new EntityTypes.Integer(1, 320, 10), "zoom") } ), new GameAction("prepare dispenser", delegate { Spaceball.instance.PrepareDispenser(); }, 1 ), }), new Minigame("karateman", "Karate Man", "70A8D8", false, false, new List()