diff --git a/Assets/_Datas/02.Scripts/Controllers/GameManager.cs b/Assets/_Datas/02.Scripts/Controllers/GameManager.cs index 1e7cd89a7..e36ea9f1c 100644 --- a/Assets/_Datas/02.Scripts/Controllers/GameManager.cs +++ b/Assets/_Datas/02.Scripts/Controllers/GameManager.cs @@ -13,14 +13,21 @@ public enum SceneType Restaurant = 1 } + public static class SceneTypeExtensions + { + public static string ToSceneName(this SceneType sceneType) + { + return sceneType switch + { + SceneType.Title => "00.Title", + SceneType.Restaurant => "01.Restaurant", + _ => throw new ArgumentOutOfRangeException(nameof(sceneType), sceneType, null) + }; + } + } + public class GameManager : Singleton { - private static readonly Dictionary SceneTypeDict = new() - { - { SceneType.Title, "00.Title" }, - { SceneType.Restaurant, "01.Restaurant" } - }; - public SceneType CurrentSceneType { get; private set; } private void Start() @@ -30,9 +37,15 @@ private void Start() public async Task ChangeScene(SceneType sceneType) { - if (!SceneTypeDict.TryGetValue(sceneType, out string changeSceneName)) + string changeSceneName; + + try { - Debug.LogError($"[GameManager] 정의되지 않은 SceneType: {sceneType}"); + changeSceneName = sceneType.ToSceneName(); + } + catch (ArgumentOutOfRangeException e) + { + Debug.LogError($"[GameManager] 정의되지 않은 SceneType: {sceneType} - {e.Message}"); return; } @@ -57,8 +70,8 @@ public async Task ChangeScene(SceneType sceneType) public void ChangeSceneByIndex(int index) { - var sceneEnum = (SceneType)index; - _ = ChangeScene(sceneEnum); + var sceneType = (SceneType)index; + _ = ChangeScene(sceneType); } } } \ No newline at end of file