DEG-167-탈진연출
This commit is contained in:
parent
7becedc9d5
commit
fc273e6511
@ -91,6 +91,24 @@ public class PlayerStats : MonoBehaviour,ISaveable
|
||||
GameManager.Instance.SetEvents();
|
||||
SceneManager.sceneLoaded += OnSceneLoaded; // 씬 전환 이벤트
|
||||
_mealCount = 0; // 식사 횟수 0회
|
||||
|
||||
var panel = FindObjectOfType<InteractionAnimationPanelController>();
|
||||
if (panel != null)
|
||||
{
|
||||
PlayerStats.Instance.SetInteractionPanelController(panel);
|
||||
}
|
||||
}
|
||||
|
||||
private void TriggerExhaustion()
|
||||
{
|
||||
if (HealthStat > 0) return;
|
||||
|
||||
Exhaustion?.Invoke(); // 탈진 이벤트 발생
|
||||
}
|
||||
|
||||
public InteractionAnimationPanelController GetInteractionPanelController()
|
||||
{
|
||||
return _interactionAnimation;
|
||||
}
|
||||
|
||||
#region 말풍선(Bubble) 관련
|
||||
@ -373,7 +391,8 @@ public class PlayerStats : MonoBehaviour,ISaveable
|
||||
|
||||
// 탈진 이벤트 발생
|
||||
Debug.Log("탈진! 체력 0");
|
||||
Exhaustion?.Invoke();
|
||||
GameManager.Instance.gotoBed = true;
|
||||
Invoke(nameof(TriggerExhaustion), 2f);
|
||||
}
|
||||
|
||||
if (HealthStat > MaxHealth)
|
||||
|
@ -66,6 +66,7 @@ public class ChatWindowController : MonoBehaviour, IPointerClickHandler
|
||||
private void Start()
|
||||
{
|
||||
_dialogueManager = new FairyDialogueManager(this);
|
||||
onComplete += SetCompleteEvent;
|
||||
|
||||
/*onComplete = () => {
|
||||
// 대화문 종료 call back
|
||||
@ -73,6 +74,11 @@ public class ChatWindowController : MonoBehaviour, IPointerClickHandler
|
||||
};*/
|
||||
}
|
||||
|
||||
private void SetCompleteEvent()
|
||||
{
|
||||
GameManager.Instance.gotoBed = true;
|
||||
}
|
||||
|
||||
// 외부 호출용 함수 (대화 시작)
|
||||
public void SetGamePhase(GamePhase phase)
|
||||
{
|
||||
|
@ -26,6 +26,10 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
private PanelManager panelManager;
|
||||
public PanelManager PanelManager => panelManager;
|
||||
|
||||
//탈진 관련
|
||||
[HideInInspector]
|
||||
public bool gotoBed = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 오디오 초기화
|
||||
@ -35,10 +39,17 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
panelManager = Instantiate(Resources.Load<GameObject>("Prefabs/PanelManager")).GetComponent<PanelManager>();
|
||||
}
|
||||
|
||||
private IEnumerator DelayedForcedSleep(float delay)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
PlayerStats.Instance.PerformAction(ActionType.ForcedSleep);
|
||||
}
|
||||
|
||||
#region 대화 관련
|
||||
|
||||
public void StartNPCDialogue(GamePhase phase) // intro, gameplay, end 존재
|
||||
{
|
||||
gotoBed = false;
|
||||
StartCoroutine(StartNPCDialogueCoroutine(phase));
|
||||
}
|
||||
|
||||
@ -77,6 +88,7 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
{
|
||||
PlayerStats.Instance.OnDayEnded += AdvanceDay; // 날짜 변경
|
||||
PlayerStats.Instance.ZeroReputation += ZeroReputationEnd; // 평판 0 엔딩
|
||||
PlayerStats.Instance.Exhaustion += ExhaustionToSleep; // 탈진 이벤트
|
||||
}
|
||||
|
||||
// 날짜 진행
|
||||
@ -92,21 +104,73 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
}
|
||||
}
|
||||
|
||||
// 탈진
|
||||
private void ExhaustionToSleep()
|
||||
{
|
||||
StartCoroutine(WaitOtherEvents());
|
||||
}
|
||||
|
||||
private IEnumerator WaitOtherEvents()
|
||||
{
|
||||
yield return new WaitForSeconds(Time.deltaTime);
|
||||
|
||||
if (gotoBed)
|
||||
{
|
||||
var panel = PlayerStats.Instance.GetInteractionPanelController();
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
panel.ShowAnimationPanel(ActionType.Sleep, "탈진했습니다");
|
||||
GameManager.Instance.StartCoroutine(DelayedForcedSleep(2.0f)); // 애니메이션 끝나고 강제 수면 처리
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerStats.Instance.PerformAction(ActionType.ForcedSleep);
|
||||
}
|
||||
|
||||
gotoBed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(WaitOtherEvents());
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeToGameScene()
|
||||
{
|
||||
tryStageCount++; // 던전 시도 횟수 증가
|
||||
SceneManager.LoadScene("ReDungeon"); // 던전 Scene
|
||||
HandleSceneAudio("Dungeon");
|
||||
StartCoroutine(CheckDungeonScene());
|
||||
}
|
||||
private IEnumerator CheckDungeonScene()
|
||||
{
|
||||
yield return new WaitForSeconds(Time.deltaTime);
|
||||
|
||||
if (SceneManager.GetActiveScene().name == "ReDungeon")
|
||||
gotoBed = false;
|
||||
else
|
||||
StartCoroutine(CheckHomeScene());
|
||||
}
|
||||
|
||||
public void ChangeToHomeScene()
|
||||
{
|
||||
SceneManager.LoadScene("ReHousing"); // Home Scene
|
||||
HandleSceneAudio("Housing");
|
||||
|
||||
StartCoroutine(CheckHomeScene());
|
||||
if (tryStageCount >= 3) FailEnd(); // 엔딩
|
||||
}
|
||||
|
||||
private IEnumerator CheckHomeScene()
|
||||
{
|
||||
yield return new WaitForSeconds(Time.deltaTime);
|
||||
|
||||
if (SceneManager.GetActiveScene().name == "ReHousing")
|
||||
gotoBed = true;
|
||||
else
|
||||
StartCoroutine(CheckHomeScene());
|
||||
}
|
||||
|
||||
// TODO: Open Setting Panel 등 Panel 처리
|
||||
|
||||
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user