From f45007b9f92a052eafc7b4a8a485fc79b1210e4d Mon Sep 17 00:00:00 2001 From: Jeremy Smitherman Date: Sat, 25 Apr 2026 16:49:07 -0500 Subject: [PATCH] Added transition --- .idea/.idea.SpringJam2026/.idea/workspace.xml | 16 +++-- Assets/Prefabs/UI/MainMenu.prefab | 2 +- Assets/Scenes/Bootstrap.unity | 60 ++++++++++++++++++- Assets/Scenes/Game.unity | 30 ++-------- Assets/Scripts/Management/Services.cs | 31 ++++++++++ Assets/Scripts/State/Game/GameRunningState.cs | 1 + Assets/Scripts/State/Game/MainMenuState.cs | 9 ++- Assets/UI/DeathScreen.uxml | 2 +- Assets/UI/Transition.uxml | 6 ++ Assets/UI/Transition.uxml.meta | 10 ++++ Assets/UI/Tutorial.uxml | 10 ++-- 11 files changed, 138 insertions(+), 39 deletions(-) create mode 100644 Assets/UI/Transition.uxml create mode 100644 Assets/UI/Transition.uxml.meta diff --git a/.idea/.idea.SpringJam2026/.idea/workspace.xml b/.idea/.idea.SpringJam2026/.idea/workspace.xml index 2f6f46d..9fb8aaf 100644 --- a/.idea/.idea.SpringJam2026/.idea/workspace.xml +++ b/.idea/.idea.SpringJam2026/.idea/workspace.xml @@ -5,7 +5,15 @@ - + + + + + + + + + diff --git a/Assets/Prefabs/UI/MainMenu.prefab b/Assets/Prefabs/UI/MainMenu.prefab index fabc4c5..ec9707a 100644 --- a/Assets/Prefabs/UI/MainMenu.prefab +++ b/Assets/Prefabs/UI/MainMenu.prefab @@ -48,7 +48,7 @@ MonoBehaviour: m_PanelSettings: {fileID: 11400000, guid: 4f01bbaf43abd294b9e7341d0530a9aa, type: 2} m_ParentUI: {fileID: 0} sourceAsset: {fileID: 9197481963319205126, guid: d29bfcc0217a10b488edd76a7ae59cf2, type: 3} - m_SortingOrder: 0 + m_SortingOrder: 98 m_Position: 0 m_WorldSpaceSizeMode: 1 m_WorldSpaceWidth: 1920 diff --git a/Assets/Scenes/Bootstrap.unity b/Assets/Scenes/Bootstrap.unity index 1bae119..cd1ac34 100644 --- a/Assets/Scenes/Bootstrap.unity +++ b/Assets/Scenes/Bootstrap.unity @@ -557,6 +557,8 @@ MonoBehaviour: bgm: {fileID: 1755353617} sfx: {fileID: 1327356649} inputRouter: {fileID: 1131356127} + transition: {fileID: 1947609808} + transitionTime: 0.5 --- !u!4 &1671688485 Transform: m_ObjectHideFlags: 0 @@ -584,7 +586,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4b256c4001284134990a2af43c375455, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::Bootstrap - startType: 3 + startType: 1 gameStateMachine: {fileID: 1469922750} --- !u!1 &1755353616 GameObject: @@ -894,6 +896,61 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!1 &1947609808 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1947609810} + - component: {fileID: 1947609809} + m_Layer: 0 + m_Name: Transition + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1947609809 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947609808} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.UIDocument + m_PanelSettings: {fileID: 11400000, guid: 4f01bbaf43abd294b9e7341d0530a9aa, type: 2} + m_ParentUI: {fileID: 0} + sourceAsset: {fileID: 9197481963319205126, guid: e0e8530a45831f04ea7c4fb8ac4ef3fd, type: 3} + m_SortingOrder: 99 + m_Position: 0 + m_WorldSpaceSizeMode: 1 + m_WorldSpaceWidth: 1920 + m_WorldSpaceHeight: 1080 + m_PivotReferenceSize: 0 + m_Pivot: 0 + m_WorldSpaceCollider: {fileID: 0} +--- !u!4 &1947609810 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947609808} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2045788189 GameObject: m_ObjectHideFlags: 0 @@ -935,3 +992,4 @@ SceneRoots: - {fileID: 1469922751} - {fileID: 1131356126} - {fileID: 564331331} + - {fileID: 1947609810} diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index b0e47b8..8fbbc91 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -5573,16 +5573,6 @@ Tilemap: m_TileObjectToInstantiateIndex: 65535 dummyAlignment: 0 m_AllTileFlags: 2147483649 - - first: {x: 10, y: 73, z: 0} - second: - serializedVersion: 2 - m_TileIndex: 17 - m_TileSpriteIndex: 17 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_TileObjectToInstantiateIndex: 65535 - dummyAlignment: 0 - m_AllTileFlags: 2147483649 - first: {x: 16, y: 73, z: 0} second: serializedVersion: 2 @@ -5699,7 +5689,7 @@ Tilemap: m_Data: {fileID: 11400000, guid: bd577f0b0ff284445b29aecf84626b4b, type: 2} - m_RefCount: 1 m_Data: {fileID: 11400000, guid: 1d5b15715d21a964cada298dc7fefb17, type: 2} - - m_RefCount: 10 + - m_RefCount: 9 m_Data: {fileID: 11400000, guid: 79658d08f0cc20242980b0ed645de8b5, type: 2} - m_RefCount: 1 m_Data: {fileID: 11400000, guid: bdd97f5a2dcbb4e47a0084db2d949bbf, type: 2} @@ -5742,7 +5732,7 @@ Tilemap: m_Data: {fileID: -1245410657, guid: 4efdfdbf2085f1c4aade8e3d44b1ea43, type: 3} - m_RefCount: 1 m_Data: {fileID: -779581496, guid: 4efdfdbf2085f1c4aade8e3d44b1ea43, type: 3} - - m_RefCount: 10 + - m_RefCount: 9 m_Data: {fileID: -3755448495774436313, guid: 4efdfdbf2085f1c4aade8e3d44b1ea43, type: 3} - m_RefCount: 1 m_Data: {fileID: -5622494010663576134, guid: 4efdfdbf2085f1c4aade8e3d44b1ea43, type: 3} @@ -5751,7 +5741,7 @@ Tilemap: - m_RefCount: 2 m_Data: {fileID: 1101770504183819589, guid: 4efdfdbf2085f1c4aade8e3d44b1ea43, type: 3} m_TileMatrixArray: - - m_RefCount: 466 + - m_RefCount: 465 m_Data: e00: 1 e01: 0 @@ -5770,7 +5760,7 @@ Tilemap: e32: 0 e33: 1 m_TileColorArray: - - m_RefCount: 466 + - m_RefCount: 465 m_Data: {r: 1, g: 1, b: 1, a: 1} m_TileObjectToInstantiateArray: [] m_AnimationFrameRate: 1 @@ -5851,14 +5841,6 @@ CompositeCollider2D: Y: 405000000 - X: 80000000 Y: 365000000 - - X: 55000000 - Y: 365000000 - - X: 55000000 - Y: 370000000 - - X: 50000000 - Y: 370000000 - - X: 50000000 - Y: 365000000 - X: 45000000 Y: 365000000 - X: 45000000 @@ -6099,10 +6081,6 @@ CompositeCollider2D: - {x: 8.49997, y: 40.5} - {x: 8, y: 40.499973} - {x: 7.9999704, y: 36.5} - - {x: 5.5, y: 36.50003} - - {x: 5.499971, y: 37} - - {x: 5, y: 36.999973} - - {x: 4.9999704, y: 36.5} - {x: 4.5, y: 36.499973} - {x: 4.500029, y: 35.5} - {x: 5, y: 35.50003} diff --git a/Assets/Scripts/Management/Services.cs b/Assets/Scripts/Management/Services.cs index 6dbc7d2..91f6762 100644 --- a/Assets/Scripts/Management/Services.cs +++ b/Assets/Scripts/Management/Services.cs @@ -1,4 +1,7 @@ +using System.Collections; +using Unity.VisualScripting; using UnityEngine; +using UnityEngine.UIElements; namespace Management { @@ -21,6 +24,32 @@ namespace Management [SerializeField] private BGM bgm; [SerializeField] private SFX sfx; [SerializeField] private InputRouter inputRouter; + [SerializeField] private GameObject transition; + [SerializeField] private float transitionTime; + + private Coroutine _transitionRoutine; + private VisualElement _loadingScreen; + + public void ShowTransition(bool show) + { + if (_transitionRoutine != null) + StopCoroutine(_transitionRoutine); + _transitionRoutine = StartCoroutine(TransitionRoutine(!show)); + } + + private IEnumerator TransitionRoutine(bool reverse) + { + var timer = 0f; + while (timer < transitionTime) + { + timer += Time.deltaTime; + _loadingScreen.style.opacity = Mathf.Lerp( + reverse ? 1 : 0, + reverse ? 0: 1, timer / transitionTime); + yield return null; + } + _transitionRoutine = null; + } private void Awake() { @@ -35,6 +64,8 @@ namespace Management // survive scene reloads DontDestroyOnLoad(gameObject); + + _loadingScreen = transition.GetComponent().rootVisualElement.Q("transitionContainer"); } } } diff --git a/Assets/Scripts/State/Game/GameRunningState.cs b/Assets/Scripts/State/Game/GameRunningState.cs index 2118bb8..68fb501 100644 --- a/Assets/Scripts/State/Game/GameRunningState.cs +++ b/Assets/Scripts/State/Game/GameRunningState.cs @@ -13,6 +13,7 @@ namespace State.Game MainStateMachine.PlayerMovement.OnDeath += HandleDeath; MainStateMachine.PlayerMovement.GetPickup += HandleTutorial; MainStateMachine.PlayerMovement.EnterSpring += HandleTutorial; + Services.Instance.ShowTransition(false); } private void HandleTutorial() diff --git a/Assets/Scripts/State/Game/MainMenuState.cs b/Assets/Scripts/State/Game/MainMenuState.cs index a8c91a2..6725508 100644 --- a/Assets/Scripts/State/Game/MainMenuState.cs +++ b/Assets/Scripts/State/Game/MainMenuState.cs @@ -1,4 +1,5 @@ using System.Collections; +using Management; using UI; using UnityEngine; using UnityEngine.SceneManagement; @@ -47,10 +48,16 @@ namespace State.Game } private void HandleStartGame() + { + StateMachine.StartCoroutine(ExecuteStartGame()); + } + + private IEnumerator ExecuteStartGame() { _mainMenuInstance.OnStartGame -= HandleStartGame; + Services.Instance.ShowTransition(true); + yield return new WaitForSeconds(2f); StateMachine.ChangeState(new StartGameState()); } - } } \ No newline at end of file diff --git a/Assets/UI/DeathScreen.uxml b/Assets/UI/DeathScreen.uxml index aa559aa..e011764 100644 --- a/Assets/UI/DeathScreen.uxml +++ b/Assets/UI/DeathScreen.uxml @@ -1,5 +1,5 @@ - + diff --git a/Assets/UI/Transition.uxml b/Assets/UI/Transition.uxml new file mode 100644 index 0000000..4e867ea --- /dev/null +++ b/Assets/UI/Transition.uxml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Assets/UI/Transition.uxml.meta b/Assets/UI/Transition.uxml.meta new file mode 100644 index 0000000..19baee0 --- /dev/null +++ b/Assets/UI/Transition.uxml.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e0e8530a45831f04ea7c4fb8ac4ef3fd +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Assets/UI/Tutorial.uxml b/Assets/UI/Tutorial.uxml index 2682b59..04d1860 100644 --- a/Assets/UI/Tutorial.uxml +++ b/Assets/UI/Tutorial.uxml @@ -1,10 +1,10 @@ - - - + + + - - + +