77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using UnityEngine;
|
|
|
|
public class RoomClearGateController : MonoBehaviour
|
|
{
|
|
[Header("룸 클리어 후 열릴 게이트")]
|
|
[SerializeField] private RoomExitGate exitGate;
|
|
|
|
[Header("Option")]
|
|
[SerializeField] private bool requireRoomClearedBeforeOpen = true;
|
|
|
|
private bool isRoomCleared = false;
|
|
private bool gateOpened = false;
|
|
private string selectedSceneCode = "";
|
|
|
|
public bool IsRoomCleared => isRoomCleared;
|
|
public string SelectedSceneCode => selectedSceneCode;
|
|
public bool HasSelectedScene => !string.IsNullOrEmpty(selectedSceneCode);
|
|
|
|
public void MarkRoomCleared()
|
|
{
|
|
isRoomCleared = true;
|
|
Debug.Log("방 클리어 완료. 이제 선택지에서 다음 방을 고를 수 있습니다.");
|
|
}
|
|
|
|
// 기존 트리거가 이걸 호출해도, 선택 전이면 문 안 열리게 막음
|
|
public void OpenClearGate()
|
|
{
|
|
if (requireRoomClearedBeforeOpen && !isRoomCleared)
|
|
{
|
|
Debug.Log("아직 방 클리어 전이라 게이트를 열 수 없습니다.");
|
|
return;
|
|
}
|
|
|
|
if (!HasSelectedScene)
|
|
{
|
|
Debug.Log("아직 다음 방을 선택하지 않아서 게이트를 열지 않습니다.");
|
|
return;
|
|
}
|
|
|
|
if (gateOpened)
|
|
{
|
|
return;
|
|
}
|
|
|
|
gateOpened = true;
|
|
|
|
if (exitGate != null)
|
|
{
|
|
exitGate.OpenGate();
|
|
Debug.Log("클리어 게이트 열림. 선택된 다음 씬: " + selectedSceneCode);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning("Exit Gate가 연결되지 않았습니다.");
|
|
}
|
|
}
|
|
|
|
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 = "";
|
|
}
|
|
} |