게이트 완성
This commit is contained in:
@@ -15,6 +15,11 @@ public class RandomSceneRouteManager : MonoBehaviour
|
||||
private readonly HashSet<string> visitedScenes = new HashSet<string>();
|
||||
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<string> 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("랜덤 방 방문 기록 초기화");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user