From a84e394b5046c9167256747a49e60de3424fe2e3 Mon Sep 17 00:00:00 2001 From: dldydtn9755-crypto Date: Wed, 24 Jun 2026 20:10:43 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=9D=B4=ED=8A=B8=20=EC=99=84?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01_Scenes/blackjack.unity | 4 +- Assets/02_Scripts/Managers/GameClear.cs | 41 +++-- .../change room manager/GateOpenZone.cs | 55 ------- .../change room manager/GateOpenZone.cs.meta | 2 - .../RandomSceneRouteManager.cs | 147 ++++++++++++++++-- .../RoomClearGateController.cs | 65 ++++++-- .../BlackJackRoom/Fairy_black_Area 3.wdg | 12 +- ProjectSettings/EditorBuildSettings.asset | 4 +- 8 files changed, 223 insertions(+), 107 deletions(-) delete mode 100644 Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs delete mode 100644 Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs.meta diff --git a/Assets/01_Scenes/blackjack.unity b/Assets/01_Scenes/blackjack.unity index 7ed4de79..6c89d984 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:9a0a4405662462bd6d57fd8f67eb1bb6ee9bfc72542f4a6cfb625eb06c0ea95f -size 2311897 +oid sha256:2e603c009e5f5edf2dd1d44454578237d02df7a9dadaeff9e31ff7ee1e0023f6 +size 2311527 diff --git a/Assets/02_Scripts/Managers/GameClear.cs b/Assets/02_Scripts/Managers/GameClear.cs index 840eb45d..b3dc85e6 100644 --- a/Assets/02_Scripts/Managers/GameClear.cs +++ b/Assets/02_Scripts/Managers/GameClear.cs @@ -94,16 +94,39 @@ public void SetZoneActive(DialogRegion zone, bool active) public void SetClearDialogParameter() { + string sceneName1 = "블랙잭"; + string sceneCode1 = "blackjack"; + string sceneName2 = "캣룸"; + string sceneCode2 = "CatsRoom"; - //DialogVariables.Set("SpaceSceneName1", RandomSceneRouteManager.Instance.GetNextSceneName1()); - //DialogVariables.Set("SpaceSceneCode1", RandomSceneRouteManager.Instance.GetNextSceneCode1()); - //DialogVariables.Set("SpaceSceneName2", RandomSceneRouteManager.Instance.GetNextSceneName2()); - //DialogVariables.Set("SpaceSceneCode2", RandomSceneRouteManager.Instance.GetNextSceneCode2()); + if (RandomSceneRouteManager.Instance != null) + { + RandomSceneRouteManager.Instance.PrepareNextSceneChoices(); - //테스트용 - DialogVariables.Set("SpaceSceneName1", "블랙잭"); - DialogVariables.Set("SpaceSceneCode1", "blackjack"); - DialogVariables.Set("SpaceSceneName2", "미로방"); - DialogVariables.Set("SpaceSceneCode2", "MazeRoom"); + sceneName1 = RandomSceneRouteManager.Instance.GetNextSceneName1(); + sceneCode1 = RandomSceneRouteManager.Instance.GetNextSceneCode1(); + sceneName2 = RandomSceneRouteManager.Instance.GetNextSceneName2(); + sceneCode2 = RandomSceneRouteManager.Instance.GetNextSceneCode2(); + } + else + { + Debug.LogWarning("RandomSceneRouteManager가 없어서 테스트용 선택지를 사용합니다."); + } + + DialogVariables.Set("SpaceSceneName1", sceneName1); + DialogVariables.Set("SpaceSceneCode1", sceneCode1); + DialogVariables.Set("SpaceSceneName2", sceneName2); + DialogVariables.Set("SpaceSceneCode2", sceneCode2); + + if (_clearGate != null) + { + _clearGate.SetDoorChoices(sceneCode1, sceneCode2); + } + else + { + Debug.LogWarning("GameClear에 RoomClearGateController가 연결되지 않았습니다."); + } + + Debug.Log($"선택지 세팅 완료: {sceneName1}/{sceneCode1}, {sceneName2}/{sceneCode2}"); } } diff --git a/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs b/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs deleted file mode 100644 index 0745de74..00000000 --- a/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; - -public class GateOpenZone : MonoBehaviour -{ - [Header("Ʈ ")] - [SerializeField] private RoomClearGateController roomClearGateController; - - [Header("Player Check")] - [SerializeField] private string playerTag = "Player"; - - private bool used = false; - - private void OnTriggerEnter(Collider other) - { - if (used) - { - return; - } - - if (!IsPlayer(other)) - { - return; - } - - if (roomClearGateController == null) - { - Debug.LogWarning("RoomClearGateController ʾҽϴ."); - return; - } - - if (!roomClearGateController.IsRoomCleared) - { - Debug.Log(" Ŭ Դϴ. Ʈ ʽϴ."); - return; - } - - used = true; - roomClearGateController.OpenClearGate(); - } - - private bool IsPlayer(Collider other) - { - if (other.CompareTag(playerTag)) - { - return true; - } - - if (other.transform.root.CompareTag(playerTag)) - { - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs.meta b/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs.meta deleted file mode 100644 index 16038a4f..00000000 --- a/Assets/02_Scripts/Managers/change room manager/GateOpenZone.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 6986d649e7cfba74881058e544e2f727 \ No newline at end of file diff --git a/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs b/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs index b268d287..73b6870c 100644 --- a/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs +++ b/Assets/02_Scripts/Managers/change room manager/RandomSceneRouteManager.cs @@ -15,6 +15,11 @@ public class RandomSceneRouteManager : MonoBehaviour private readonly HashSet visitedScenes = new HashSet(); private bool finalSceneUsed = false; + private string nextSceneCode1 = ""; + private string nextSceneCode2 = ""; + private string nextSceneName1 = ""; + private string nextSceneName2 = ""; + private void Awake() { if (Instance == null) @@ -28,10 +33,9 @@ private void Awake() } } - public string GetNextSceneName() + public void PrepareNextSceneChoices() { string currentSceneName = SceneManager.GetActiveScene().name; - Debug.Log(" ̸: " + currentSceneName); if (IsRoomScene(currentSceneName)) @@ -63,28 +67,131 @@ public string GetNextSceneName() candidates.Add(cleanSceneName); } - if (candidates.Count > 0) + Shuffle(candidates); + + nextSceneCode1 = ""; + nextSceneCode2 = ""; + nextSceneName1 = ""; + nextSceneName2 = ""; + + if (candidates.Count >= 1) { - int randomIndex = Random.Range(0, candidates.Count); - string selectedSceneName = candidates[randomIndex]; - - visitedScenes.Add(selectedSceneName); - - Debug.Log(" õ : " + selectedSceneName); - return selectedSceneName; + nextSceneCode1 = candidates[0]; + nextSceneName1 = GetDisplayName(nextSceneCode1); } - if (!finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName)) + if (candidates.Count >= 2) + { + 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)) + { + nextSceneCode1 = finalSceneName.Trim(); + nextSceneName1 = GetDisplayName(nextSceneCode1); + } + else + { + Debug.LogWarning("̵ ϴ."); + } + } + + Debug.Log(" 1: " + nextSceneName1 + " / " + nextSceneCode1); + Debug.Log(" 2: " + nextSceneName2 + " / " + nextSceneCode2); + } + + public string GetNextSceneName1() + { + return nextSceneName1; + } + + public string GetNextSceneCode1() + { + return nextSceneCode1; + } + + public string GetNextSceneName2() + { + return nextSceneName2; + } + + public string GetNextSceneCode2() + { + return nextSceneCode2; + } + + public string GetNextSceneName() + { + PrepareNextSceneChoices(); + + if (!string.IsNullOrEmpty(nextSceneCode1)) + { + return nextSceneCode1; + } + + return string.Empty; + } + + public void MarkSceneVisited(string sceneName) + { + if (string.IsNullOrWhiteSpace(sceneName)) + { + return; + } + + string cleanSceneName = sceneName.Trim(); + + if (cleanSceneName == finalSceneName) { finalSceneUsed = true; - - string cleanFinalSceneName = finalSceneName.Trim(); - Debug.Log(" 湮 Ϸ. ̵: " + cleanFinalSceneName); - return cleanFinalSceneName; } - Debug.LogWarning("̵ ϴ."); - return string.Empty; + if (IsRoomScene(cleanSceneName)) + { + visitedScenes.Add(cleanSceneName); + } + + Debug.Log("湮 ó : " + cleanSceneName); + } + + private void Shuffle(List list) + { + for (int i = 0; i < list.Count; i++) + { + int randomIndex = Random.Range(i, list.Count); + string temp = list[i]; + list[i] = list[randomIndex]; + list[randomIndex] = temp; + } + } + + private string GetDisplayName(string sceneName) + { + switch (sceneName) + { + case "blackjack": + return ""; + + case "CatsRoom": + return "Ĺ"; + + case "MazeRoom": + return "̷ι"; + + case "Cave_Test_2": + return ""; + + default: + return sceneName; + } } private bool IsRoomScene(string sceneName) @@ -129,6 +236,12 @@ public void ResetRoute() { visitedScenes.Clear(); finalSceneUsed = false; + + nextSceneCode1 = ""; + nextSceneCode2 = ""; + nextSceneName1 = ""; + nextSceneName2 = ""; + Debug.Log(" 湮 ʱȭ"); } } \ No newline at end of file diff --git a/Assets/02_Scripts/Managers/change room manager/RoomClearGateController.cs b/Assets/02_Scripts/Managers/change room manager/RoomClearGateController.cs index 6d0fb190..99318ca1 100644 --- a/Assets/02_Scripts/Managers/change room manager/RoomClearGateController.cs +++ b/Assets/02_Scripts/Managers/change room manager/RoomClearGateController.cs @@ -10,8 +10,13 @@ public class RoomClearGateController : MonoBehaviour private bool isRoomCleared = false; private bool gateOpened = false; + private string selectedSceneCode = ""; + // 랜덤 선택지 1, 2에 들어갈 씬 코드 + private string choiceSceneCode1 = ""; + private string choiceSceneCode2 = ""; + public bool IsRoomCleared => isRoomCleared; public string SelectedSceneCode => selectedSceneCode; public bool HasSelectedScene => !string.IsNullOrEmpty(selectedSceneCode); @@ -22,7 +27,50 @@ public void MarkRoomCleared() Debug.Log("방 클리어 완료. 이제 선택지에서 다음 방을 고를 수 있습니다."); } - // 기존 트리거가 이걸 호출해도, 선택 전이면 문 안 열리게 막음 + // GameClear에서 랜덤으로 뽑은 선택지 코드를 여기에 저장 + public void SetDoorChoices(string code1, string code2) + { + choiceSceneCode1 = code1; + choiceSceneCode2 = code2; + + Debug.Log("문 선택지 1 코드: " + choiceSceneCode1); + Debug.Log("문 선택지 2 코드: " + choiceSceneCode2); + } + + // 대화 선택지 1번에서 호출 + public void OpenDoorChoice1() + { + OpenDoor(choiceSceneCode1); + } + + // 대화 선택지 2번에서 호출 + public void OpenDoorChoice2() + { + OpenDoor(choiceSceneCode2); + } + + // 실제 문 열기 + public void OpenDoor(string code) + { + if (string.IsNullOrEmpty(code)) + { + Debug.LogWarning("선택된 씬 코드가 비어있습니다."); + return; + } + + selectedSceneCode = code; + + Debug.Log("선택된 다음 씬 코드: " + selectedSceneCode); + + if (exitGate != null) + { + exitGate.SetNextSceneName(selectedSceneCode); + } + + OpenClearGate(); + } + + // 문 열기 실행 public void OpenClearGate() { if (requireRoomClearedBeforeOpen && !isRoomCleared) @@ -55,23 +103,12 @@ public void OpenClearGate() } } - public void OpenDoor(string code) - { - selectedSceneCode = code; - - Debug.Log("선택된 다음 씬 코드: " + selectedSceneCode); - - if (exitGate != null) - { - exitGate.SetNextSceneName(selectedSceneCode); - } - - OpenClearGate(); - } public void ResetClearState() { isRoomCleared = false; gateOpened = false; selectedSceneCode = ""; + choiceSceneCode1 = ""; + choiceSceneCode2 = ""; } } \ No newline at end of file diff --git a/Assets/07_Data/Communication/DialogGraph/BlackJackRoom/Fairy_black_Area 3.wdg b/Assets/07_Data/Communication/DialogGraph/BlackJackRoom/Fairy_black_Area 3.wdg index 9f819f96..e90a7e59 100644 --- a/Assets/07_Data/Communication/DialogGraph/BlackJackRoom/Fairy_black_Area 3.wdg +++ b/Assets/07_Data/Communication/DialogGraph/BlackJackRoom/Fairy_black_Area 3.wdg @@ -137,20 +137,20 @@ MonoBehaviour: type: {class: 'Constant`1[[WhaleAdventure.Dialog.GraphTool.Editor.DialogText, Assembly-CSharp-Editor]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: - Value: "\uBE14\uB799\uC7AD" + Value: '{SpaceSceneName1}' - rid: 1895995099136655531 type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: blackjack + m_Value: 1 - rid: 1895995099136655532 type: {class: 'Constant`1[[WhaleAdventure.Dialog.GraphTool.Editor.DialogText, Assembly-CSharp-Editor]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: - Value: "\uCEA3\uB8F8\n" + Value: '{SpaceSceneName2}' - rid: 1895995099136655533 type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: CatsRoom + m_Value: 2 - rid: 1895995099136655534 type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: @@ -244,7 +244,7 @@ MonoBehaviour: - rid: 1895995099136655537 type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: OPEN_DOOR_BLACKJACK + m_Value: OPEN_DOOR_CHOICE_1 - rid: 1895995099136655538 type: {class: 'Constant`1[[CharacterData, Assembly-CSharp]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: @@ -342,7 +342,7 @@ MonoBehaviour: - rid: 1895995099136655560 type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: - m_Value: OPEN_DOOR_CatsRoom + m_Value: OPEN_DOOR_CHOICE_2 - rid: 1895995099136655561 type: {class: 'Constant`1[[CharacterData, Assembly-CSharp]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 22d18211..d42f1967 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c97619610ec8363e88d2adbf7ba17f88b6e72ffa0f5e61abf2a72b5795c0bfd7 -size 1278 +oid sha256:4f6b61f6821d80d13471aa364a5b681770e7ab678c120bdf8b4d4ee081242477 +size 1481