diff --git a/Assets/01_Scenes/MazeRoom.unity b/Assets/01_Scenes/MazeRoom.unity index d7e2943c..bc4df383 100644 --- a/Assets/01_Scenes/MazeRoom.unity +++ b/Assets/01_Scenes/MazeRoom.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aeb3d59a18b6a33575598f737931085b02561dba8dc1e83a9b77f626b75423e5 -size 3357599 +oid sha256:8f649eeb59aacf4816e7d310ffdaceefe8a926da6805c1a56bd8ac0186b87fda +size 3360046 diff --git a/Assets/01_Scenes/WhaleAdventure_VR/WhaleAttackScene.unity b/Assets/01_Scenes/WhaleAdventure_VR/WhaleAttackScene.unity index 21414f04..557b78ea 100644 --- a/Assets/01_Scenes/WhaleAdventure_VR/WhaleAttackScene.unity +++ b/Assets/01_Scenes/WhaleAdventure_VR/WhaleAttackScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a8814b35845dc5a63b68d93dcc9f4ea6939346c1a30ceffc6864f6fcf57d65f -size 73032 +oid sha256:7d6586ca857eeac3d4d13d6394a57d9e97e31015c70268164a28a4d1066a989d +size 76700 diff --git a/Assets/01_Scenes/blackjack.unity b/Assets/01_Scenes/blackjack.unity index dcb56037..119c20c6 100644 --- a/Assets/01_Scenes/blackjack.unity +++ b/Assets/01_Scenes/blackjack.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b593ef51335c380326430e147b400c442953ef410da8e3899d88bc8042c35c14 -size 2310050 +oid sha256:9aa57a2c6111cb1db90a502532e68953f2851a1b5f7b404543be9f5c5ae377d8 +size 3137795 diff --git a/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs b/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs index 73b6870c..54f6e665 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 loadedSceneName = scene.name.Trim(); + + if (IsRoomScene(loadedSceneName)) + { + visitedScenes.Add(loadedSceneName); + Debug.Log("¹æ¹® ó¸®µÈ ¾À: " + loadedSceneName); + } + } + 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); } @@ -74,29 +88,35 @@ public void PrepareNextSceneChoices() nextSceneName1 = ""; nextSceneName2 = ""; - if (candidates.Count >= 1) + // ³²Àº ¹æÀÌ 2°³ ÀÌ»óÀÌ¸é ¹æ 2°³ ¼±ÅÃÁö Ç¥½Ã + if (candidates.Count >= 2) { nextSceneCode1 = candidates[0]; nextSceneName1 = GetDisplayName(nextSceneCode1); - } - if (candidates.Count >= 2) - { nextSceneCode2 = candidates[1]; nextSceneName2 = GetDisplayName(nextSceneCode2); } - else if (candidates.Count == 1 && !finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName)) + // ³²Àº ¹æÀÌ 1°³¸é ±× ¹æ¸¸ Ç¥½Ã + else if (candidates.Count == 1) { - nextSceneCode2 = finalSceneName.Trim(); - nextSceneName2 = GetDisplayName(nextSceneCode2); - } + nextSceneCode1 = candidates[0]; + nextSceneName1 = GetDisplayName(nextSceneCode1); - if (candidates.Count == 0) + // Áß¿ä: ¸¶Áö¸· ¹æÀÌ ³²¾ÆÀÖÀ» ¶§´Â Á¦ÆäÅä ¹æÀ» ¼±ÅÃÁö 2·Î ³ÖÁö ¾ÊÀ½ + nextSceneCode2 = ""; + nextSceneName2 = ""; + } + // ³²Àº ¹æÀÌ 0°³¸é ±×¶§¸¸ Á¦ÆäÅä ¹æ Ç¥½Ã + else { - if (!finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName)) + if (!string.IsNullOrWhiteSpace(finalSceneName)) { nextSceneCode1 = finalSceneName.Trim(); nextSceneName1 = GetDisplayName(nextSceneCode1); + + nextSceneCode2 = ""; + nextSceneName2 = ""; } else { @@ -104,6 +124,8 @@ public void PrepareNextSceneChoices() } } + 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