From 23e411b6e17eeff2034e9b0542f74bd4edecb5d2 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Mon, 28 Apr 2025 16:32:12 +0900 Subject: [PATCH] =?UTF-8?q?DEG-54=20[Feat]=20=EC=97=94=EB=94=A9=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/DungeonLogic.cs | 5 +- Assets/Scripts/Common/GameConstants.cs | 3 + Assets/Scripts/Common/GameManager.cs | 14 ++--- .../Scripts/Common/GameUtility/EndingLogic.cs | 58 +++++++++++++++++++ .../Common/GameUtility/EndingLogic.cs.meta | 11 ++++ 5 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 Assets/Scripts/Common/GameUtility/EndingLogic.cs create mode 100644 Assets/Scripts/Common/GameUtility/EndingLogic.cs.meta diff --git a/Assets/KSH/DungeonLogic.cs b/Assets/KSH/DungeonLogic.cs index e5b66d8f..ca7ef0aa 100644 --- a/Assets/KSH/DungeonLogic.cs +++ b/Assets/KSH/DungeonLogic.cs @@ -83,8 +83,9 @@ public class DungeonLogic : MonoBehaviour if (!isCompleted && !isFailed) { Debug.Log("던전 공략 성공~!"); + GameManager.Instance.ClearStage(); // 스테이지 수 증가 isCompleted = true; - OnDungeonSuccess?.Invoke(); + // OnDungeonSuccess?.Invoke(); _dungeonPanelController.SetBossHealthBar(0.0f); // 보스 체력 0 재설정 @@ -100,7 +101,7 @@ public class DungeonLogic : MonoBehaviour { Debug.Log("던전 공략 실패~!"); isFailed = true; - OnDungeonFailure?.Invoke(); + // OnDungeonFailure?.Invoke(); _player.SetState(PlayerState.Dead); diff --git a/Assets/Scripts/Common/GameConstants.cs b/Assets/Scripts/Common/GameConstants.cs index 2bd483bb..e4b32d72 100644 --- a/Assets/Scripts/Common/GameConstants.cs +++ b/Assets/Scripts/Common/GameConstants.cs @@ -40,4 +40,7 @@ public class GameConstants // 날짜 한계 값 public static int maxDays = 7; + + // 스테이지 한계 값 + public static int maxStage = 3; // 기본 값 1 + 스테이지 2가지 } diff --git a/Assets/Scripts/Common/GameManager.cs b/Assets/Scripts/Common/GameManager.cs index 6a1ef48a..568c78ea 100644 --- a/Assets/Scripts/Common/GameManager.cs +++ b/Assets/Scripts/Common/GameManager.cs @@ -11,10 +11,13 @@ public partial class GameManager : Singleton private Canvas _canvas; // 게임 진행 상태 - private int currentDay = 1; + private int currentDay = 1; // 날짜 public int CurrentDay => currentDay; private int maxDays = GameConstants.maxDays; + private int stageLevel = 1; // 스테이지 정보 + public int StageLevel => stageLevel; + // 날짜 변경 이벤트, 추후에 UI 상의 날짜를 변경할 때 사용 public event Action OnDayChanged; @@ -44,19 +47,12 @@ public partial class GameManager : Singleton OnDayChanged?.Invoke(currentDay); // 최대 일수 도달 체크 - if (currentDay > maxDays) + if (currentDay > maxDays) // 8일차에 검사 { TriggerTimeEnding(); } } - // 엔딩 트리거 - private void TriggerTimeEnding() - { - // TODO: 엔딩 처리 로직 - Debug.Log("7일이 지나 게임이 종료됩니다."); - } - public void ChangeToGameScene() { SceneManager.LoadScene("Game"); // 던전 Scene diff --git a/Assets/Scripts/Common/GameUtility/EndingLogic.cs b/Assets/Scripts/Common/GameUtility/EndingLogic.cs new file mode 100644 index 00000000..29633018 --- /dev/null +++ b/Assets/Scripts/Common/GameUtility/EndingLogic.cs @@ -0,0 +1,58 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// 엔딩 타입 정의 +public enum EndingType +{ + Normal, // 던전 공략 O + Bad, // 던전 공략 X + Happy // 던전 공략 O, 평판 기본 스탯 값 * 1.5 이상 +} + +public partial class GameManager : Singleton +{ + private float happyEndReputation = 3.0f; + + public void ClearStage() + { + Debug.Log($"스테이지 레벨 {stageLevel}을 클리어 하셨습니다!"); + stageLevel++; + } + + // 엔딩 관련 메서드. 7일차에 실행 + private void TriggerTimeEnding() + { + // 플레이어 상태에 따라 엔딩 판별 + EndingType endingType = DetermineEnding(); + + // 엔딩 타입에 따라 다른 씬이나 UI 표시 + switch (endingType) + { + case EndingType.Normal: + Debug.Log("던전 공략 성공"); + // TODO: 엔딩 관련 패널 띄우기 + break; + case EndingType.Bad: + Debug.Log("던전 공략 실패"); + + break; + case EndingType.Happy: + Debug.Log("던전 공략 성공과 훌륭한 평판 작"); + + break; + } + } + + // 던전 스테이지와 평판 수치로 엔딩 판별 + private EndingType DetermineEnding() + { + if (stageLevel < GameConstants.maxStage) // 현재 스테이지 1 혹은 2 + return EndingType.Bad; + + if (playerStats.ReputationStat >= happyEndReputation) // 평판이 일정 수치 이상 + return EndingType.Happy; + + return EndingType.Normal; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Common/GameUtility/EndingLogic.cs.meta b/Assets/Scripts/Common/GameUtility/EndingLogic.cs.meta new file mode 100644 index 00000000..ebbc98b7 --- /dev/null +++ b/Assets/Scripts/Common/GameUtility/EndingLogic.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0967fea1a1fa5048b551b72f9d3bc16 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: