diff --git a/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs b/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs index 73b6870c..f297b17c 100644 --- a/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs +++ b/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs @@ -13,7 +13,6 @@ public class RandomSceneRouteManager : MonoBehaviour [SerializeField] private string finalSceneName; private readonly HashSet visitedScenes = new HashSet(); - private bool finalSceneUsed = false; private string nextSceneCode1 = ""; private string nextSceneCode2 = ""; @@ -26,6 +25,7 @@ private void Awake() { Instance = this; DontDestroyOnLoad(gameObject); + SceneManager.sceneLoaded += OnSceneLoaded; } else { @@ -33,10 +33,28 @@ private void Awake() } } + private void OnDestroy() + { + if (Instance == this) + { + SceneManager.sceneLoaded -= OnSceneLoaded; + } + } + + private void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + string sceneName = scene.name.Trim(); + + if (IsRoomScene(sceneName)) + { + visitedScenes.Add(sceneName); + Debug.Log("ÇöÀç ¹æ ¹æ¹® ó¸®: " + sceneName); + } + } + public void PrepareNextSceneChoices() { - string currentSceneName = SceneManager.GetActiveScene().name; - Debug.Log("ÇöÀç ¾À À̸§: " + currentSceneName); + string currentSceneName = SceneManager.GetActiveScene().name.Trim(); if (IsRoomScene(currentSceneName)) { @@ -48,21 +66,17 @@ public void PrepareNextSceneChoices() foreach (string sceneName in roomSceneNames) { if (string.IsNullOrWhiteSpace(sceneName)) - { continue; - } string cleanSceneName = sceneName.Trim(); + // ÀÚ±â Àڽйæ Á¦¿Ü if (cleanSceneName == currentSceneName) - { continue; - } + // ÀÌ¹Ì ¹æ¹®ÇÑ ¹æ Á¦¿Ü if (visitedScenes.Contains(cleanSceneName)) - { continue; - } candidates.Add(cleanSceneName); } @@ -85,15 +99,11 @@ public void PrepareNextSceneChoices() nextSceneCode2 = candidates[1]; nextSceneName2 = GetDisplayName(nextSceneCode2); } - else if (candidates.Count == 1 && !finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName)) - { - nextSceneCode2 = finalSceneName.Trim(); - nextSceneName2 = GetDisplayName(nextSceneCode2); - } + // ³²Àº ¹æÀÌ Çϳªµµ ¾øÀ¸¸é ¸¶Áö¸· ¾ÀÀ¸·Î º¸³¿ if (candidates.Count == 0) { - if (!finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName)) + if (!string.IsNullOrWhiteSpace(finalSceneName)) { nextSceneCode1 = finalSceneName.Trim(); nextSceneName1 = GetDisplayName(nextSceneCode1); @@ -104,6 +114,18 @@ public void PrepareNextSceneChoices() } } + // ³²Àº ¹æÀÌ Çϳª»ÓÀ̸é 1¹øÀº ³²Àº ¹æ, 2¹øÀº ¸¶Áö¸· ¾ÀÀ¸·Î °¡´É + if (candidates.Count == 1) + { + if (!string.IsNullOrWhiteSpace(finalSceneName)) + { + nextSceneCode2 = finalSceneName.Trim(); + nextSceneName2 = GetDisplayName(nextSceneCode2); + } + } + + Debug.Log("ÇöÀç ¾À: " + currentSceneName); + Debug.Log("¹æ¹®ÇÑ ¾À ¼ö: " + visitedScenes.Count); Debug.Log("¼±ÅÃÁö 1: " + nextSceneName1 + " / " + nextSceneCode1); Debug.Log("¼±ÅÃÁö 2: " + nextSceneName2 + " / " + nextSceneCode2); } @@ -133,33 +155,45 @@ public string GetNextSceneName() PrepareNextSceneChoices(); if (!string.IsNullOrEmpty(nextSceneCode1)) - { return nextSceneCode1; - } return string.Empty; } - public void MarkSceneVisited(string sceneName) + public void RequestRandomSceneChange() { - if (string.IsNullOrWhiteSpace(sceneName)) + string nextSceneName = GetNextSceneName(); + + if (string.IsNullOrEmpty(nextSceneName)) { + Debug.LogWarning("À̵¿ÇÒ ´ÙÀ½ ¾À À̸§ÀÌ ºñ¾îÀÖ½À´Ï´Ù."); return; } - string cleanSceneName = sceneName.Trim(); + SceneLoadManager loadManager = FindFirstObjectByType(); - if (cleanSceneName == finalSceneName) + if (loadManager != null) { - finalSceneUsed = true; + Debug.Log("·£´ý ¾À À̵¿ ¿äû: " + nextSceneName); + loadManager.RequestSceneChange(nextSceneName); } - - if (IsRoomScene(cleanSceneName)) + else { - visitedScenes.Add(cleanSceneName); + Debug.LogWarning("SceneLoadManager°¡ ¾ø¾î¼­ ¹Ù·Î ¾À À̵¿ÇÕ´Ï´Ù: " + nextSceneName); + SceneManager.LoadScene(nextSceneName); } + } - Debug.Log("¹æ¹® ó¸®µÈ ¾À: " + cleanSceneName); + public void ResetRoute() + { + visitedScenes.Clear(); + + nextSceneCode1 = ""; + nextSceneCode2 = ""; + nextSceneName1 = ""; + nextSceneName2 = ""; + + Debug.Log("·£´ý ¹æ ¹æ¹® ±â·Ï ÃʱâÈ­"); } private void Shuffle(List list) @@ -189,6 +223,9 @@ private string GetDisplayName(string sceneName) case "Cave_Test_2": return "µ¿±¼¹æ"; + case "Gepto first": + return "Á¦ÆäÅä"; + default: return sceneName; } @@ -199,49 +236,12 @@ private bool IsRoomScene(string sceneName) foreach (string roomSceneName in roomSceneNames) { if (string.IsNullOrWhiteSpace(roomSceneName)) - { continue; - } - if (roomSceneName.Trim() == sceneName) - { + if (roomSceneName.Trim() == sceneName.Trim()) return true; - } } return false; } - - public void RequestRandomSceneChange() - { - if (SceneLoadManager.Instance == null) - { - Debug.LogError("SceneLoadManager°¡ ¾ø½À´Ï´Ù."); - return; - } - - string nextSceneName = GetNextSceneName(); - - if (string.IsNullOrEmpty(nextSceneName)) - { - Debug.LogWarning("À̵¿ÇÒ ´ÙÀ½ ¾À À̸§ÀÌ ºñ¾îÀÖ½À´Ï´Ù."); - return; - } - - Debug.Log("·£´ý ¾À À̵¿ ¿äû: " + nextSceneName); - SceneLoadManager.Instance.RequestSceneChange(nextSceneName); - } - - public void ResetRoute() - { - visitedScenes.Clear(); - finalSceneUsed = false; - - nextSceneCode1 = ""; - nextSceneCode2 = ""; - nextSceneName1 = ""; - nextSceneName2 = ""; - - Debug.Log("·£´ý ¹æ ¹æ¹® ±â·Ï ÃʱâÈ­"); - } } \ No newline at end of file diff --git a/Assets/My project/Fonts/Pretendard-Black SDF.asset b/Assets/My project/Fonts/Pretendard-Black SDF.asset index 617368a4..afbcf0ab 100644 --- a/Assets/My project/Fonts/Pretendard-Black SDF.asset +++ b/Assets/My project/Fonts/Pretendard-Black SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:683f3abcb887175600cc47702f9e566c4c614b8ef41438a4c516a23b997d26c6 -size 41413216 +oid sha256:a81a06b57f04031dc553ed2a18857edbf18e5f2ef32f65f713e538f6cebf5da5 +size 7807136 diff --git a/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset b/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset index 19f87263..625a1c4a 100644 --- a/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset +++ b/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06458142b1e806fbba1e415f22b2c262a80a8881a3ebb880f89a841f77f3eb3f -size 544626 +oid sha256:8dc6471d84975f90f9f65db979eb4b41da6f0d61c6b8b5b891e86f7123c11a10 +size 17480