Merge branch 'main' of https://www.nakjungit.site/sharedacc520k/WhaleAdventure_VR
This commit is contained in:
BIN
Assets/01_Scenes/MazeRoom.unity
LFS
BIN
Assets/01_Scenes/MazeRoom.unity
LFS
Binary file not shown.
Binary file not shown.
BIN
Assets/01_Scenes/blackjack.unity
LFS
BIN
Assets/01_Scenes/blackjack.unity
LFS
Binary file not shown.
@@ -13,7 +13,6 @@ public class RandomSceneRouteManager : MonoBehaviour
|
|||||||
[SerializeField] private string finalSceneName;
|
[SerializeField] private string finalSceneName;
|
||||||
|
|
||||||
private readonly HashSet<string> visitedScenes = new HashSet<string>();
|
private readonly HashSet<string> visitedScenes = new HashSet<string>();
|
||||||
private bool finalSceneUsed = false;
|
|
||||||
|
|
||||||
private string nextSceneCode1 = "";
|
private string nextSceneCode1 = "";
|
||||||
private string nextSceneCode2 = "";
|
private string nextSceneCode2 = "";
|
||||||
@@ -26,6 +25,7 @@ private void Awake()
|
|||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
DontDestroyOnLoad(gameObject);
|
DontDestroyOnLoad(gameObject);
|
||||||
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||||
}
|
}
|
||||||
else
|
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()
|
public void PrepareNextSceneChoices()
|
||||||
{
|
{
|
||||||
string currentSceneName = SceneManager.GetActiveScene().name;
|
string currentSceneName = SceneManager.GetActiveScene().name.Trim();
|
||||||
Debug.Log("현재 씬 이름: " + currentSceneName);
|
|
||||||
|
|
||||||
if (IsRoomScene(currentSceneName))
|
if (IsRoomScene(currentSceneName))
|
||||||
{
|
{
|
||||||
@@ -48,21 +66,17 @@ public void PrepareNextSceneChoices()
|
|||||||
foreach (string sceneName in roomSceneNames)
|
foreach (string sceneName in roomSceneNames)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(sceneName))
|
if (string.IsNullOrWhiteSpace(sceneName))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
string cleanSceneName = sceneName.Trim();
|
string cleanSceneName = sceneName.Trim();
|
||||||
|
|
||||||
|
// 현재 방은 선택지에서 제외
|
||||||
if (cleanSceneName == currentSceneName)
|
if (cleanSceneName == currentSceneName)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
|
// 이미 방문한 방도 제외
|
||||||
if (visitedScenes.Contains(cleanSceneName))
|
if (visitedScenes.Contains(cleanSceneName))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
candidates.Add(cleanSceneName);
|
candidates.Add(cleanSceneName);
|
||||||
}
|
}
|
||||||
@@ -74,29 +88,35 @@ public void PrepareNextSceneChoices()
|
|||||||
nextSceneName1 = "";
|
nextSceneName1 = "";
|
||||||
nextSceneName2 = "";
|
nextSceneName2 = "";
|
||||||
|
|
||||||
if (candidates.Count >= 1)
|
// 남은 방이 2개 이상이면 방 2개 선택지 표시
|
||||||
|
if (candidates.Count >= 2)
|
||||||
{
|
{
|
||||||
nextSceneCode1 = candidates[0];
|
nextSceneCode1 = candidates[0];
|
||||||
nextSceneName1 = GetDisplayName(nextSceneCode1);
|
nextSceneName1 = GetDisplayName(nextSceneCode1);
|
||||||
}
|
|
||||||
|
|
||||||
if (candidates.Count >= 2)
|
|
||||||
{
|
|
||||||
nextSceneCode2 = candidates[1];
|
nextSceneCode2 = candidates[1];
|
||||||
nextSceneName2 = GetDisplayName(nextSceneCode2);
|
nextSceneName2 = GetDisplayName(nextSceneCode2);
|
||||||
}
|
}
|
||||||
else if (candidates.Count == 1 && !finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName))
|
// 남은 방이 1개면 그 방만 표시
|
||||||
|
else if (candidates.Count == 1)
|
||||||
{
|
{
|
||||||
nextSceneCode2 = finalSceneName.Trim();
|
nextSceneCode1 = candidates[0];
|
||||||
nextSceneName2 = GetDisplayName(nextSceneCode2);
|
nextSceneName1 = GetDisplayName(nextSceneCode1);
|
||||||
}
|
|
||||||
|
|
||||||
if (candidates.Count == 0)
|
// 중요: 마지막 방이 남아있을 때는 제페토 방을 선택지 2로 넣지 않음
|
||||||
|
nextSceneCode2 = "";
|
||||||
|
nextSceneName2 = "";
|
||||||
|
}
|
||||||
|
// 남은 방이 0개면 그때만 제페토 방 표시
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!finalSceneUsed && !string.IsNullOrWhiteSpace(finalSceneName))
|
if (!string.IsNullOrWhiteSpace(finalSceneName))
|
||||||
{
|
{
|
||||||
nextSceneCode1 = finalSceneName.Trim();
|
nextSceneCode1 = finalSceneName.Trim();
|
||||||
nextSceneName1 = GetDisplayName(nextSceneCode1);
|
nextSceneName1 = GetDisplayName(nextSceneCode1);
|
||||||
|
|
||||||
|
nextSceneCode2 = "";
|
||||||
|
nextSceneName2 = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -104,6 +124,8 @@ public void PrepareNextSceneChoices()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log("현재 씬: " + currentSceneName);
|
||||||
|
Debug.Log("방문한 씬 수: " + visitedScenes.Count);
|
||||||
Debug.Log("¼±ÅÃÁö 1: " + nextSceneName1 + " / " + nextSceneCode1);
|
Debug.Log("¼±ÅÃÁö 1: " + nextSceneName1 + " / " + nextSceneCode1);
|
||||||
Debug.Log("¼±ÅÃÁö 2: " + nextSceneName2 + " / " + nextSceneCode2);
|
Debug.Log("¼±ÅÃÁö 2: " + nextSceneName2 + " / " + nextSceneCode2);
|
||||||
}
|
}
|
||||||
@@ -133,33 +155,45 @@ public string GetNextSceneName()
|
|||||||
PrepareNextSceneChoices();
|
PrepareNextSceneChoices();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(nextSceneCode1))
|
if (!string.IsNullOrEmpty(nextSceneCode1))
|
||||||
{
|
|
||||||
return nextSceneCode1;
|
return nextSceneCode1;
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string cleanSceneName = sceneName.Trim();
|
SceneLoadManager loadManager = FindFirstObjectByType<SceneLoadManager>();
|
||||||
|
|
||||||
if (cleanSceneName == finalSceneName)
|
if (loadManager != null)
|
||||||
{
|
{
|
||||||
finalSceneUsed = true;
|
Debug.Log("랜덤 씬 이동 요청: " + nextSceneName);
|
||||||
|
loadManager.RequestSceneChange(nextSceneName);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (IsRoomScene(cleanSceneName))
|
|
||||||
{
|
{
|
||||||
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<string> list)
|
private void Shuffle(List<string> list)
|
||||||
@@ -189,6 +223,9 @@ private string GetDisplayName(string sceneName)
|
|||||||
case "Cave_Test_2":
|
case "Cave_Test_2":
|
||||||
return "µ¿±¼¹æ";
|
return "µ¿±¼¹æ";
|
||||||
|
|
||||||
|
case "Gepto first":
|
||||||
|
return "제페토";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return sceneName;
|
return sceneName;
|
||||||
}
|
}
|
||||||
@@ -199,49 +236,12 @@ private bool IsRoomScene(string sceneName)
|
|||||||
foreach (string roomSceneName in roomSceneNames)
|
foreach (string roomSceneName in roomSceneNames)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(roomSceneName))
|
if (string.IsNullOrWhiteSpace(roomSceneName))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (roomSceneName.Trim() == sceneName)
|
if (roomSceneName.Trim() == sceneName.Trim())
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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("랜덤 방 방문 기록 초기화");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user