From bd44a7cdc5de1a4795af313f520b492b8057ca23 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Wed, 16 Apr 2025 17:19:58 +0900 Subject: [PATCH 1/9] =?UTF-8?q?DEG-15=20=EA=B8=B0=EB=B3=B8=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspectionProfiles/Project_Default.xml | 6 +++ Assets/KSH.meta | 8 ++++ Assets/KSH/GameConstants.cs | 10 +++++ Assets/KSH/GameConstants.cs.meta | 11 +++++ Assets/KSH/GameManager.cs | 34 ++++++++++++++ Assets/KSH/GameManager.cs.meta | 11 +++++ Assets/KSH/PlayerStats.cs | 8 ++++ Assets/KSH/PlayerStats.cs.meta | 11 +++++ Assets/KSH/Singleton.cs | 45 +++++++++++++++++++ Assets/KSH/Singleton.cs.meta | 11 +++++ 10 files changed, 155 insertions(+) create mode 100644 .idea/.idea.Degulleo3D/.idea/inspectionProfiles/Project_Default.xml create mode 100644 Assets/KSH.meta create mode 100644 Assets/KSH/GameConstants.cs create mode 100644 Assets/KSH/GameConstants.cs.meta create mode 100644 Assets/KSH/GameManager.cs create mode 100644 Assets/KSH/GameManager.cs.meta create mode 100644 Assets/KSH/PlayerStats.cs create mode 100644 Assets/KSH/PlayerStats.cs.meta create mode 100644 Assets/KSH/Singleton.cs create mode 100644 Assets/KSH/Singleton.cs.meta diff --git a/.idea/.idea.Degulleo3D/.idea/inspectionProfiles/Project_Default.xml b/.idea/.idea.Degulleo3D/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..dfb35ffb --- /dev/null +++ b/.idea/.idea.Degulleo3D/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Assets/KSH.meta b/Assets/KSH.meta new file mode 100644 index 00000000..32286553 --- /dev/null +++ b/Assets/KSH.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8899b70334c78204fb97b6da706ac4c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/GameConstants.cs b/Assets/KSH/GameConstants.cs new file mode 100644 index 00000000..66c4bf53 --- /dev/null +++ b/Assets/KSH/GameConstants.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + + +public class GameConstants : MonoBehaviour +{ + +} diff --git a/Assets/KSH/GameConstants.cs.meta b/Assets/KSH/GameConstants.cs.meta new file mode 100644 index 00000000..7fb223ac --- /dev/null +++ b/Assets/KSH/GameConstants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1e1682026c3858a4f8974675387aaf5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs new file mode 100644 index 00000000..73945d41 --- /dev/null +++ b/Assets/KSH/GameManager.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class GameManager : Singleton +{ + private Canvas _canvas; + + public void ChangeToGameScene() + { + SceneManager.LoadScene("Game"); // 던전 Scene + } + + public void ChangeToMainScene() + { + SceneManager.LoadScene("Housing"); // Home Scene + } + + // ToDo: Open Setting Panel 등 Panel 처리 + + protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + // ToDo: 씬 로드 시 동작 구현. ex: BGM 변경 + + // UI용 Canvas 찾기 + // _canvas = GameObject.FindObjectOfType(); + } + + private void OnApplicationQuit() + { + // TODO: 게임 종료 시 로직 추가 + } +} diff --git a/Assets/KSH/GameManager.cs.meta b/Assets/KSH/GameManager.cs.meta new file mode 100644 index 00000000..7f546e24 --- /dev/null +++ b/Assets/KSH/GameManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 450038edae05f9b4d94ff56c62444048 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs new file mode 100644 index 00000000..e0ba559f --- /dev/null +++ b/Assets/KSH/PlayerStats.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerStats : MonoBehaviour +{ + +} diff --git a/Assets/KSH/PlayerStats.cs.meta b/Assets/KSH/PlayerStats.cs.meta new file mode 100644 index 00000000..448b945c --- /dev/null +++ b/Assets/KSH/PlayerStats.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8bccfaf46267e2544aa4bae52756f182 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/Singleton.cs b/Assets/KSH/Singleton.cs new file mode 100644 index 00000000..9cc4927b --- /dev/null +++ b/Assets/KSH/Singleton.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +public abstract class Singleton : MonoBehaviour where T : Component +{ + private static T _instance; + + public static T Instance + { + get + { + if (_instance == null) + { + _instance = FindObjectOfType(); + if (_instance == null) + { + GameObject obj = new GameObject(); + obj.name = typeof(T).Name; + _instance = obj.AddComponent(); + } + } + return _instance; + } + } + + void Awake() + { + if (_instance == null) + { + _instance = this as T; + DontDestroyOnLoad(gameObject); // obj가 destory 안되도록 설정 + + // 씬 전환시 호출되는 액션 메서드 할당 + SceneManager.sceneLoaded += OnSceneLoaded; + } + else + { + Destroy(gameObject); + } + } + + protected abstract void OnSceneLoaded(Scene scene, LoadSceneMode mode); +} diff --git a/Assets/KSH/Singleton.cs.meta b/Assets/KSH/Singleton.cs.meta new file mode 100644 index 00000000..477ec449 --- /dev/null +++ b/Assets/KSH/Singleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 014fe0082bc24a041a78cce62ba16b5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From c8c1978aed166d38b9035888718101eeb0825ae1 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 17 Apr 2025 11:28:08 +0900 Subject: [PATCH 2/9] =?UTF-8?q?DEG-15=20[Feat]=20=EC=8A=A4=ED=83=AF=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=95=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Editor.meta | 8 ++ Assets/Editor/ReadOnlyDrawer.cs | 24 +++++ Assets/Editor/ReadOnlyDrawer.cs.meta | 11 +++ Assets/KSH/GameConstants.cs | 37 ++++++- Assets/KSH/GameManager.cs | 49 +++++++++- Assets/KSH/PlayerStats.cs | 86 ++++++++++++++++ Assets/KSH/TestCode.meta | 8 ++ Assets/KSH/TestCode/PlayerStatsTest.cs | 103 ++++++++++++++++++++ Assets/KSH/TestCode/PlayerStatsTest.cs.meta | 11 +++ Assets/KSH/TestCode/Test.prefab | 3 + Assets/KSH/TestCode/Test.prefab.meta | 7 ++ Assets/KSH/ValueByAction.cs | 61 ++++++++++++ Assets/KSH/ValueByAction.cs.meta | 11 +++ 13 files changed, 413 insertions(+), 6 deletions(-) create mode 100644 Assets/Editor.meta create mode 100644 Assets/Editor/ReadOnlyDrawer.cs create mode 100644 Assets/Editor/ReadOnlyDrawer.cs.meta create mode 100644 Assets/KSH/TestCode.meta create mode 100644 Assets/KSH/TestCode/PlayerStatsTest.cs create mode 100644 Assets/KSH/TestCode/PlayerStatsTest.cs.meta create mode 100644 Assets/KSH/TestCode/Test.prefab create mode 100644 Assets/KSH/TestCode/Test.prefab.meta create mode 100644 Assets/KSH/ValueByAction.cs create mode 100644 Assets/KSH/ValueByAction.cs.meta diff --git a/Assets/Editor.meta b/Assets/Editor.meta new file mode 100644 index 00000000..d3e3b472 --- /dev/null +++ b/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb977eee32cc2024181234437bfb8480 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/ReadOnlyDrawer.cs b/Assets/Editor/ReadOnlyDrawer.cs new file mode 100644 index 00000000..f28e0596 --- /dev/null +++ b/Assets/Editor/ReadOnlyDrawer.cs @@ -0,0 +1,24 @@ +#if UNITY_EDITOR +using UnityEngine; +using UnityEditor; + +// PlayerStatsTest.ReadOnlyAttribute를 위한 에디터 속성 드로어 +[CustomPropertyDrawer(typeof(PlayerStatsTest.ReadOnlyAttribute))] +public class ReadOnlyDrawer : PropertyDrawer +{ + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // 이전 GUI 활성화 상태 저장 + bool wasEnabled = GUI.enabled; + + // 필드 비활성화 (읽기 전용) + GUI.enabled = false; + + // 속성 그리기 + EditorGUI.PropertyField(position, property, label, true); + + // GUI 활성화 상태 복원 + GUI.enabled = wasEnabled; + } +} +#endif \ No newline at end of file diff --git a/Assets/Editor/ReadOnlyDrawer.cs.meta b/Assets/Editor/ReadOnlyDrawer.cs.meta new file mode 100644 index 00000000..3f22dabf --- /dev/null +++ b/Assets/Editor/ReadOnlyDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb5079b7064e2324890f78e18dfe7a6e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/GameConstants.cs b/Assets/KSH/GameConstants.cs index 66c4bf53..61771aa4 100644 --- a/Assets/KSH/GameConstants.cs +++ b/Assets/KSH/GameConstants.cs @@ -2,9 +2,38 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; - - -public class GameConstants : MonoBehaviour +// 행동 타입 +public enum ActionType { - + NotSleep, // 5시간 미만 취침 + LessSleep, // 5시간 취침 + SleepWell, // 8시간 취침 + ForcedSleep, // 강제 수면(10시간) + Eat, + Work, + Dungeon, + // 보너스 스테이지 제외 + Housework, // 집안일 + OvertimeWork, // 야근 + TeamDinner, // 회식 + Absence // 결근 +} + +public class GameConstants +{ + // 기본 스탯 값 + public float baseHealth = 8f; + public float baseTime = 8f; + public float baseReputation = 5f; + + // 스탯 한계 값 + public float maxHealth = 10f; + public float maxTime = 24f; + public float maxReputation = 10f; + + // 강제 값 + public float forcedValue = 999f; + + // 날짜 한계 값 + public static int maxDays = 7; } diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs index 73945d41..9be64878 100644 --- a/Assets/KSH/GameManager.cs +++ b/Assets/KSH/GameManager.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -5,8 +6,52 @@ using UnityEngine.SceneManagement; public class GameManager : Singleton { + [SerializeField] private PlayerStats playerStats; + private Canvas _canvas; + // 게임 진행 상태 + private int currentDay = 1; + public int CurrentDay => currentDay; + private int maxDays = GameConstants.maxDays; + + // 날짜 변경 이벤트 + public event Action OnDayChanged; + + private void Start() + { + // PlayerStats의 하루 종료 이벤트 구독 + if (playerStats == null) + { + playerStats = FindObjectOfType(); + if (playerStats == null) + { + Debug.LogError("PlayerStats 컴포넌트를 찾을 수 없습니다. 함께 추가해주세요."); + } + } + playerStats.OnDayEnded += AdvanceDay; + } + + // 날짜 진행 + public void AdvanceDay() + { + currentDay++; + OnDayChanged?.Invoke(currentDay); + + // 최대 일수 도달 체크 + if (currentDay > maxDays) + { + TriggerTimeEnding(); + } + } + + // 엔딩 트리거 + private void TriggerTimeEnding() + { + // TODO: 엔딩 처리 로직 + Debug.Log("7일이 지나 게임이 종료됩니다."); + } + public void ChangeToGameScene() { SceneManager.LoadScene("Game"); // 던전 Scene @@ -17,11 +62,11 @@ public class GameManager : Singleton SceneManager.LoadScene("Housing"); // Home Scene } - // ToDo: Open Setting Panel 등 Panel 처리 + // TODO: Open Setting Panel 등 Panel 처리 protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) { - // ToDo: 씬 로드 시 동작 구현. ex: BGM 변경 + // TODO: 씬 로드 시 동작 구현. ex: BGM 변경 // UI용 Canvas 찾기 // _canvas = GameObject.FindObjectOfType(); diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index e0ba559f..0dd56cfe 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -1,8 +1,94 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerStats : MonoBehaviour { + private GameConstants _gameConstants; + private ValueByAction _valueByAction; + public float Time { get; private set; } + public float Health { get; private set; } + public float Reputation { get; private set; } + + public event Action OnDayEnded; + + private void Start() + { + _gameConstants = new GameConstants(); + _valueByAction = new ValueByAction(); + _valueByAction.Initialize(); // 값 초기화 + + Health = _gameConstants.baseHealth; + Time = _gameConstants.baseTime; + Reputation = _gameConstants.baseReputation; + } + + // 행동 처리 메서드 + public void PerformAction(ActionType actionType) + { + // 액션에 따른 스탯 소모 값 가져오기 + ActionEffect effect = _valueByAction.GetActionEffect(actionType); + + // 스탯 변경 적용 + ModifyTime(effect.timeChange); + ModifyHealth(effect.healthChange); + ModifyReputation(effect.reputationChange); + } + + // 하루 종료 처리 + private void EndDay(bool isForced) //bool isForced? 해서 true면 강제 수면이라 8시에 깨는 + { + // 하루 종료 이벤트 발생 + OnDayEnded?.Invoke(); + + // 시간 리셋 + if (isForced) + { + Time = _gameConstants.baseTime; // 강제 수면일 시 아침 8시 기상 고정 + } + else + { + Time -= _gameConstants.maxTime; + } + } + + // 행동에 따른 내부 스탯 변경 메서드 + public void ModifyTime(float time) + { + Time += time; + + if (Time >= _gameConstants.maxTime) + { + if (time == _gameConstants.forcedValue) + { + EndDay(true); + } + else + { + EndDay(false); + } + } + } + + public void ModifyHealth(float health) + { + Health += health; + + if (Health > _gameConstants.maxHealth) + { + Health = _gameConstants.maxHealth; + } + } + + public void ModifyReputation(float reputation) + { + Reputation += reputation; + + if (Reputation > _gameConstants.maxReputation) + { + Reputation = _gameConstants.maxReputation; + } + } } diff --git a/Assets/KSH/TestCode.meta b/Assets/KSH/TestCode.meta new file mode 100644 index 00000000..bc9a631b --- /dev/null +++ b/Assets/KSH/TestCode.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 533241c82a79dcc46932391bf865ce21 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/TestCode/PlayerStatsTest.cs b/Assets/KSH/TestCode/PlayerStatsTest.cs new file mode 100644 index 00000000..c16f496a --- /dev/null +++ b/Assets/KSH/TestCode/PlayerStatsTest.cs @@ -0,0 +1,103 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerStatsTest : MonoBehaviour +{ + [Header("현재 스탯")] + [SerializeField, ReadOnly] private float currentTime; + [SerializeField, ReadOnly] private float currentHealth; + [SerializeField, ReadOnly] private float currentReputation; + [SerializeField, ReadOnly] private int currentDay; + + [Header("테스트 액션")] + [Tooltip("액션을 선택하고 체크박스를 체크하여 실행")] + [SerializeField] private ActionType actionToTest; + [SerializeField] private bool executeAction; + + // 컴포넌트 참조 + [Header("필수 참조")] + [SerializeField] private PlayerStats playerStats; + [SerializeField] private GameManager gameManager; + + // ReadOnly 속성 (인스펙터에서 수정 불가능하게 만듦) + public class ReadOnlyAttribute : PropertyAttribute { } + + private void Start() + { + // 참조 찾기 (없을 경우) + if (playerStats == null) + { + playerStats = FindObjectOfType(); + Debug.Log("PlayerStats를 찾아 참조했습니다."); + } + + if (gameManager == null) + { + gameManager = FindObjectOfType(); + Debug.Log("GameManager를 찾아 참조했습니다."); + } + + // 초기 스탯 표시 업데이트 + UpdateStatsDisplay(); + } + + private void Update() + { + if (Application.isPlaying) + { + // 매 프레임마다 스탯 업데이트 + UpdateStatsDisplay(); + + // 체크박스가 체크되면 선택된 액션 실행 + if (executeAction) + { + ExecuteSelectedAction(); + executeAction = false; // 체크박스 초기화 + } + } + } + + private void UpdateStatsDisplay() + { + // 참조 확인 후 스탯 업데이트 + if (playerStats != null) + { + currentTime = playerStats.Time; + currentHealth = playerStats.Health; + currentReputation = playerStats.Reputation; + + // GameManager에서 날짜 정보 가져오기 + if (gameManager != null) + { + currentDay = gameManager.CurrentDay; + } + else + { + Debug.LogWarning("GameManager 참조가 없습니다."); + } + } + else + { + Debug.LogWarning("PlayerStats 참조가 없습니다."); + } + } + + private void ExecuteSelectedAction() + { + if (playerStats != null) + { + // 선택한 액션 실행 + playerStats.PerformAction(actionToTest); + UpdateStatsDisplay(); + Debug.Log($"액션 실행: {actionToTest}"); + + // 콘솔에 현재 스탯 정보 출력 + Debug.Log($"현재 스탯 - 시간: {currentTime}, 체력: {currentHealth}, 평판: {currentReputation}, 날짜: {currentDay}"); + } + else + { + Debug.LogError("PlayerStats 참조가 없어 액션을 실행할 수 없습니다."); + } + } +} \ No newline at end of file diff --git a/Assets/KSH/TestCode/PlayerStatsTest.cs.meta b/Assets/KSH/TestCode/PlayerStatsTest.cs.meta new file mode 100644 index 00000000..6b74a38e --- /dev/null +++ b/Assets/KSH/TestCode/PlayerStatsTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae7f2b39529d58a4fa75cf1d30dae9be +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/TestCode/Test.prefab b/Assets/KSH/TestCode/Test.prefab new file mode 100644 index 00000000..b1d3b885 --- /dev/null +++ b/Assets/KSH/TestCode/Test.prefab @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a65e9dd60a7532ae1c4c43fda477ac0940c18c5c60f8a164b6fd52b9f1f4a42 +size 5196 diff --git a/Assets/KSH/TestCode/Test.prefab.meta b/Assets/KSH/TestCode/Test.prefab.meta new file mode 100644 index 00000000..0bbcf71a --- /dev/null +++ b/Assets/KSH/TestCode/Test.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 90448f678f8c503408de14c38cd7c653 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KSH/ValueByAction.cs b/Assets/KSH/ValueByAction.cs new file mode 100644 index 00000000..03df3f7e --- /dev/null +++ b/Assets/KSH/ValueByAction.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// 각 액션이 스탯에 미치는 영향을 담는 간단한 구조체 +public struct ActionEffect +{ + public float timeChange; + public float healthChange; + public float reputationChange; + + public ActionEffect(float time, float health, float reputation) + { + timeChange = time; + healthChange = health; + reputationChange = reputation; + } +} + +public class ValueByAction +{ + private GameConstants _gameConstants; + private Dictionary actionEffects; + + public void Initialize() + { + _gameConstants = new GameConstants(); + InitializeActionEffects(); + } + + private void InitializeActionEffects() + { + actionEffects = new Dictionary + { + // 기본 액션들, 효과(시간, 체력, 평판 순) + { ActionType.NotSleep, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 8시 강제 기상 + { ActionType.LessSleep, new ActionEffect(+5.0f, +6.0f, 0) }, + { ActionType.SleepWell, new ActionEffect(+8.0f, +8.0f, 0) }, + { ActionType.ForcedSleep, new ActionEffect(+10.0f, +4.0f, 0) }, + { ActionType.Eat, new ActionEffect(+1.0f, +1.0f, 0) }, + { ActionType.Work, new ActionEffect(+10.0f, -3.0f, +0.2f) }, // 8to6: 10시간 + { ActionType.Dungeon, new ActionEffect(+3.0f, -3.0f, 0) }, + { ActionType.Housework, new ActionEffect(+1.0f, -1.0f, +0.2f) }, + { ActionType.OvertimeWork, new ActionEffect(+4.0f, -5.0f, +1.0f) }, + { ActionType.TeamDinner, new ActionEffect(_gameConstants.forcedValue, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 + { ActionType.Absence, new ActionEffect(0, 0, -3.0f) } + }; + } + + // 액션에 따른 효과(스탯 가감) + public ActionEffect GetActionEffect(ActionType actionType) + { + if (actionEffects.TryGetValue(actionType, out ActionEffect effect)) + { + return effect; + } + + // 없으면 기본값 반환 + return new ActionEffect(0, 0, 0); + } +} diff --git a/Assets/KSH/ValueByAction.cs.meta b/Assets/KSH/ValueByAction.cs.meta new file mode 100644 index 00000000..4efa939c --- /dev/null +++ b/Assets/KSH/ValueByAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2aa1af61c6712fc45bf458c18cd2c874 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 7302efaebc0576e3a0de1eaf6652e2e42cca9ab9 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 17 Apr 2025 13:11:03 +0900 Subject: [PATCH 3/9] =?UTF-8?q?DEG-15=20[Fix]=20=EC=9D=8C=EC=88=98=20?= =?UTF-8?q?=EA=B0=92=20=EC=A0=9C=ED=95=9C=EA=B3=BC=20=EC=B2=B4=EB=A0=A5?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20=ED=96=89=EB=8F=99=EC=9D=B4=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=ED=95=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameManager.cs | 8 ++++ Assets/KSH/PlayerStats.cs | 60 ++++++++++++++++++-------- Assets/KSH/TestCode/PlayerStatsTest.cs | 6 +-- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs index 9be64878..6b1146df 100644 --- a/Assets/KSH/GameManager.cs +++ b/Assets/KSH/GameManager.cs @@ -72,6 +72,14 @@ public class GameManager : Singleton // _canvas = GameObject.FindObjectOfType(); } + private void OnDestroy() + { + if (playerStats != null) + { + playerStats.OnDayEnded -= AdvanceDay; // 이벤트 구독 해제 + } + } + private void OnApplicationQuit() { // TODO: 게임 종료 시 로직 추가 diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index 0dd56cfe..90cb3db6 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -8,9 +8,9 @@ public class PlayerStats : MonoBehaviour private GameConstants _gameConstants; private ValueByAction _valueByAction; - public float Time { get; private set; } - public float Health { get; private set; } - public float Reputation { get; private set; } + public float TimeStat { get; private set; } + public float HealthStat { get; private set; } + public float ReputationStat { get; private set; } public event Action OnDayEnded; @@ -20,9 +20,24 @@ public class PlayerStats : MonoBehaviour _valueByAction = new ValueByAction(); _valueByAction.Initialize(); // 값 초기화 - Health = _gameConstants.baseHealth; - Time = _gameConstants.baseTime; - Reputation = _gameConstants.baseReputation; + HealthStat = _gameConstants.baseHealth; + TimeStat = _gameConstants.baseTime; + ReputationStat = _gameConstants.baseReputation; + } + + // 현재 체력으로 해당 행동이 가능한 지 확인 + public bool canPerformByHealth(ActionType actionType) + { + ActionEffect effect = _valueByAction.GetActionEffect(actionType); + + if (HealthStat >= effect.healthChange) + { + return true; + } + else + { + return false; + } } // 행동 처리 메서드 @@ -46,20 +61,20 @@ public class PlayerStats : MonoBehaviour // 시간 리셋 if (isForced) { - Time = _gameConstants.baseTime; // 강제 수면일 시 아침 8시 기상 고정 + TimeStat = _gameConstants.baseTime; // 강제 수면일 시 아침 8시 기상 고정 } else { - Time -= _gameConstants.maxTime; + TimeStat -= _gameConstants.maxTime; } } // 행동에 따른 내부 스탯 변경 메서드 public void ModifyTime(float time) { - Time += time; + TimeStat += time; - if (Time >= _gameConstants.maxTime) + if (TimeStat >= _gameConstants.maxTime) { if (time == _gameConstants.forcedValue) { @@ -74,21 +89,32 @@ public class PlayerStats : MonoBehaviour public void ModifyHealth(float health) { - Health += health; - - if (Health > _gameConstants.maxHealth) + HealthStat += health; + + // 혹시 모를 음수 값 처리 + if (HealthStat < 0) { - Health = _gameConstants.maxHealth; + HealthStat = 0.0f; + } + + if (HealthStat > _gameConstants.maxHealth) + { + HealthStat = _gameConstants.maxHealth; } } public void ModifyReputation(float reputation) { - Reputation += reputation; + ReputationStat += reputation; - if (Reputation > _gameConstants.maxReputation) + if (ReputationStat < 0) { - Reputation = _gameConstants.maxReputation; + ReputationStat = 0.0f; + } + + if (ReputationStat > _gameConstants.maxReputation) + { + ReputationStat = _gameConstants.maxReputation; } } } diff --git a/Assets/KSH/TestCode/PlayerStatsTest.cs b/Assets/KSH/TestCode/PlayerStatsTest.cs index c16f496a..445d3f8b 100644 --- a/Assets/KSH/TestCode/PlayerStatsTest.cs +++ b/Assets/KSH/TestCode/PlayerStatsTest.cs @@ -63,9 +63,9 @@ public class PlayerStatsTest : MonoBehaviour // 참조 확인 후 스탯 업데이트 if (playerStats != null) { - currentTime = playerStats.Time; - currentHealth = playerStats.Health; - currentReputation = playerStats.Reputation; + currentTime = playerStats.TimeStat; + currentHealth = playerStats.HealthStat; + currentReputation = playerStats.ReputationStat; // GameManager에서 날짜 정보 가져오기 if (gameManager != null) From 349c07acde8d2012ab60b1a647e2be03d7047874 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 17 Apr 2025 13:11:50 +0900 Subject: [PATCH 4/9] =?UTF-8?q?DEG-15=20[Style]=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EB=AA=85=20=EB=8C=80=EB=AC=B8=EC=9E=90=20=EC=8B=9C=EC=9E=91?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/PlayerStats.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index 90cb3db6..cb37aec3 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -26,7 +26,7 @@ public class PlayerStats : MonoBehaviour } // 현재 체력으로 해당 행동이 가능한 지 확인 - public bool canPerformByHealth(ActionType actionType) + public bool CanPerformByHealth(ActionType actionType) { ActionEffect effect = _valueByAction.GetActionEffect(actionType); From 15384a1e282c4c8172a70d7358342bbb2182781d Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 17 Apr 2025 13:20:55 +0900 Subject: [PATCH 5/9] =?UTF-8?q?DEG-15=20[Fix]=20null=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs index 6b1146df..2281a049 100644 --- a/Assets/KSH/GameManager.cs +++ b/Assets/KSH/GameManager.cs @@ -27,6 +27,7 @@ public class GameManager : Singleton if (playerStats == null) { Debug.LogError("PlayerStats 컴포넌트를 찾을 수 없습니다. 함께 추가해주세요."); + return; } } playerStats.OnDayEnded += AdvanceDay; From 3c5623016f667c5d606441b46ec82d64a85321f6 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Fri, 18 Apr 2025 09:30:08 +0900 Subject: [PATCH 6/9] =?UTF-8?q?DEG-15=20[Feat]=20=EC=B6=9C=EA=B7=BC=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameConstants.cs | 3 ++- Assets/KSH/PlayerStats.cs | 9 +++++++++ Assets/KSH/ValueByAction.cs | 6 ++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Assets/KSH/GameConstants.cs b/Assets/KSH/GameConstants.cs index 61771aa4..065d0426 100644 --- a/Assets/KSH/GameConstants.cs +++ b/Assets/KSH/GameConstants.cs @@ -9,6 +9,7 @@ public enum ActionType LessSleep, // 5시간 취침 SleepWell, // 8시간 취침 ForcedSleep, // 강제 수면(10시간) + Sleep, Eat, Work, Dungeon, @@ -24,7 +25,7 @@ public class GameConstants // 기본 스탯 값 public float baseHealth = 8f; public float baseTime = 8f; - public float baseReputation = 5f; + public float baseReputation = 2f; // 스탯 한계 값 public float maxHealth = 10f; diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index cb37aec3..ea693331 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -51,6 +51,15 @@ public class PlayerStats : MonoBehaviour ModifyHealth(effect.healthChange); ModifyReputation(effect.reputationChange); } + + // 출근 가능 여부 확인 메서드 + public bool CanWork() + { + bool isTimeToWork = TimeStat is >= 8.0f and < 9.0f; // 8시에서 9시 사이만 true + bool isCanPerformWork = CanPerformByHealth(ActionType.Work); // 체력상 가능한지 확인 + + return isTimeToWork && isCanPerformWork; + } // 하루 종료 처리 private void EndDay(bool isForced) //bool isForced? 해서 true면 강제 수면이라 8시에 깨는 diff --git a/Assets/KSH/ValueByAction.cs b/Assets/KSH/ValueByAction.cs index 03df3f7e..3d7796e3 100644 --- a/Assets/KSH/ValueByAction.cs +++ b/Assets/KSH/ValueByAction.cs @@ -33,10 +33,8 @@ public class ValueByAction actionEffects = new Dictionary { // 기본 액션들, 효과(시간, 체력, 평판 순) - { ActionType.NotSleep, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 8시 강제 기상 - { ActionType.LessSleep, new ActionEffect(+5.0f, +6.0f, 0) }, - { ActionType.SleepWell, new ActionEffect(+8.0f, +8.0f, 0) }, - { ActionType.ForcedSleep, new ActionEffect(+10.0f, +4.0f, 0) }, + { ActionType.Sleep, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 8시 강제 기상 + { ActionType.ForcedSleep, new ActionEffect(+10.0f, +4.0f, 0) }, // 체력 0 { ActionType.Eat, new ActionEffect(+1.0f, +1.0f, 0) }, { ActionType.Work, new ActionEffect(+10.0f, -3.0f, +0.2f) }, // 8to6: 10시간 { ActionType.Dungeon, new ActionEffect(+3.0f, -3.0f, 0) }, From 5420028b34f1e87717ecd3aa05c2928f620fcd6b Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Fri, 18 Apr 2025 11:52:16 +0900 Subject: [PATCH 7/9] =?UTF-8?q?DEG-15=20[Fix]=20=EC=88=98=EB=A9=B4=20?= =?UTF-8?q?=ED=96=89=EB=8F=99=20=EC=B2=98=EB=A6=AC=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameConstants.cs | 20 ++++--- Assets/KSH/GameManager.cs | 2 +- Assets/KSH/PlayerStats.cs | 106 +++++++++++++++++++++++++++++------- Assets/KSH/ValueByAction.cs | 7 ++- 4 files changed, 104 insertions(+), 31 deletions(-) diff --git a/Assets/KSH/GameConstants.cs b/Assets/KSH/GameConstants.cs index 065d0426..d42c6808 100644 --- a/Assets/KSH/GameConstants.cs +++ b/Assets/KSH/GameConstants.cs @@ -5,15 +5,12 @@ using UnityEngine; // 행동 타입 public enum ActionType { - NotSleep, // 5시간 미만 취침 - LessSleep, // 5시간 취침 - SleepWell, // 8시간 취침 - ForcedSleep, // 강제 수면(10시간) - Sleep, + Sleep, // 8시 기상 + OverSlept, // 결근-늦잠 + ForcedSleep, // 탈진(체력 0) Eat, Work, Dungeon, - // 보너스 스테이지 제외 Housework, // 집안일 OvertimeWork, // 야근 TeamDinner, // 회식 @@ -32,7 +29,16 @@ public class GameConstants public float maxTime = 24f; public float maxReputation = 10f; - // 강제 값 + // 체력 회복 한계 값 + public float limitRecover = 8.0f; + + // 기상 시간 + public float wakeUpTime = 8.0f; + + // 오전 8시 기상 값 + public float wakeUpAtEight = 888f; + + // 강제 값 (탈진, 결근-늦잠) public float forcedValue = 999f; // 날짜 한계 값 diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs index 2281a049..8082bc57 100644 --- a/Assets/KSH/GameManager.cs +++ b/Assets/KSH/GameManager.cs @@ -15,7 +15,7 @@ public class GameManager : Singleton public int CurrentDay => currentDay; private int maxDays = GameConstants.maxDays; - // 날짜 변경 이벤트 + // 날짜 변경 이벤트, 추후에 UI 상의 날짜를 변경할 때 사용 public event Action OnDayChanged; private void Start() diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index ea693331..be92e15b 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using Random = UnityEngine.Random; public class PlayerStats : MonoBehaviour { @@ -13,6 +14,11 @@ public class PlayerStats : MonoBehaviour public float ReputationStat { get; private set; } public event Action OnDayEnded; + public event Action Exhaustion; // 탈진 + public event Action Overslept; // 결근(늦잠) + public event Action ZeroReputation; // 평판 0 이벤트 + + private float previousAddHealth = 0f; private void Start() { @@ -47,7 +53,7 @@ public class PlayerStats : MonoBehaviour ActionEffect effect = _valueByAction.GetActionEffect(actionType); // 스탯 변경 적용 - ModifyTime(effect.timeChange); + ModifyTime(effect.timeChange, actionType); ModifyHealth(effect.healthChange); ModifyReputation(effect.reputationChange); } @@ -62,48 +68,106 @@ public class PlayerStats : MonoBehaviour } // 하루 종료 처리 - private void EndDay(bool isForced) //bool isForced? 해서 true면 강제 수면이라 8시에 깨는 + private void EndDay(float time, ActionType actionType) //bool isForced? 해서 true면 강제 수면이라 8시에 깨는 { - // 하루 종료 이벤트 발생 - OnDayEnded?.Invoke(); - - // 시간 리셋 - if (isForced) + bool isDayEnded = false; + + // 수면 행동 처리 + if (actionType == ActionType.Sleep) // 다음 날 오전 8시 기상 { - TimeStat = _gameConstants.baseTime; // 강제 수면일 시 아침 8시 기상 고정 + // 다음 날 오전 8시 - 현재 시간 값 + float nowTime = TimeStat - time; + float remainTime = CalculateTimeToWakeUp(nowTime); + + TimeStat = _gameConstants.baseTime; // 아침 8시 기상 + + // 체력 회복 + ModifyHealth(remainTime); + + // 일반 수면의 경우, 시간이 8시 이후일 때만 하루가 종료된 것으로 판단 + isDayEnded = nowTime >= 8.0f; + + // 회복량이 8 이하면 늦잠 이벤트 발동 + if (remainTime < _gameConstants.limitRecover) + { + Debug.Log($"수면이 8시간 미만입니다. 수면 시간: {remainTime}"); + Overslept?.Invoke(); // 늦잠 이벤트 + } + } + else if (actionType == ActionType.OverSlept) // 늦잠, 오전 8시에 행동을 결정하기에 하루 지남 X + { + // 다음 날 오후 3~6시 사이 기상, 추가 체력 회복 + float randomWakeUpTime = Random.Range(15, 18); + TimeStat = randomWakeUpTime; + + // 추가 체력 회복 + float remainHealth = _gameConstants.limitRecover - previousAddHealth; // 체력 회복 총량 8 - 이전 회복 값 = 총 8회복 + ModifyHealth(remainHealth); + } + else if (actionType == ActionType.ForcedSleep) // 탈진 + { + // 오전 0~8시 사이에 잠들면 하루가 지나지 않은 것으로 처리 + float nowTime = TimeStat - time; + bool isEarlyMorning = nowTime >= 0 && nowTime < 8; + isDayEnded = !isEarlyMorning; + + // 다음 날 오후 3~6시 사이 기상 + float randomWakeUpTime = Random.Range(15, 18); + TimeStat = randomWakeUpTime; + } + else // 수면 이외의 행동 + { + isDayEnded = true; + TimeStat -= _gameConstants.maxTime; + } + + // 하루가 실제로 종료된 경우에만 이벤트 발생 + if (isDayEnded) + { + OnDayEnded?.Invoke(); + } + } + + public float CalculateTimeToWakeUp(float timeStat) + { + float wakeUpTime = _gameConstants.wakeUpTime; + if (timeStat < wakeUpTime) // 현재 시간이 0~7시 사이인 경우 + { + // 당일 오전 8시까지 남은 시간 + return wakeUpTime - timeStat; } else { - TimeStat -= _gameConstants.maxTime; + return ( wakeUpTime + 24f ) - timeStat; // 다음 날 오전 8시까지 남은 시간 } } // 행동에 따른 내부 스탯 변경 메서드 - public void ModifyTime(float time) + public void ModifyTime(float time, ActionType actionType) { TimeStat += time; if (TimeStat >= _gameConstants.maxTime) { - if (time == _gameConstants.forcedValue) - { - EndDay(true); - } - else - { - EndDay(false); - } + EndDay(time, actionType); } } public void ModifyHealth(float health) { + previousAddHealth = health; // 이전 회복량 저장 HealthStat += health; // 혹시 모를 음수 값 처리 - if (HealthStat < 0) + if (HealthStat <= 0) { HealthStat = 0.0f; + // 현재는 0 되자마자 발생하도록 처리하였는데 다른 방식으로의 처리가 필요하다면 말씀해주십시오. + // 동작 이후에 스탯을 깎는다는 기준하에 작성하였습니다. (동작 전에는 CanPerformByHealth()를 통해 행동 가능 여부 판단) + + // 탈진 이벤트 발생 + Debug.Log("탈진! 체력 0"); + Exhaustion?.Invoke(); } if (HealthStat > _gameConstants.maxHealth) @@ -116,8 +180,10 @@ public class PlayerStats : MonoBehaviour { ReputationStat += reputation; - if (ReputationStat < 0) + if (ReputationStat <= 0) { + Debug.Log("당신의 평판은 0입니다..;"); + ZeroReputation?.Invoke(); ReputationStat = 0.0f; } diff --git a/Assets/KSH/ValueByAction.cs b/Assets/KSH/ValueByAction.cs index 3d7796e3..7e66a79a 100644 --- a/Assets/KSH/ValueByAction.cs +++ b/Assets/KSH/ValueByAction.cs @@ -33,14 +33,15 @@ public class ValueByAction actionEffects = new Dictionary { // 기본 액션들, 효과(시간, 체력, 평판 순) - { ActionType.Sleep, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 8시 강제 기상 - { ActionType.ForcedSleep, new ActionEffect(+10.0f, +4.0f, 0) }, // 체력 0 + { ActionType.Sleep, new ActionEffect(_gameConstants.wakeUpAtEight, 0, 0) }, // 8시 강제 기상 + { ActionType.OverSlept, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 결근 (오후 3~6시 기상) + { ActionType.ForcedSleep, new ActionEffect(_gameConstants.forcedValue, 4, 0) }, // 탈진 { ActionType.Eat, new ActionEffect(+1.0f, +1.0f, 0) }, { ActionType.Work, new ActionEffect(+10.0f, -3.0f, +0.2f) }, // 8to6: 10시간 { ActionType.Dungeon, new ActionEffect(+3.0f, -3.0f, 0) }, { ActionType.Housework, new ActionEffect(+1.0f, -1.0f, +0.2f) }, { ActionType.OvertimeWork, new ActionEffect(+4.0f, -5.0f, +1.0f) }, - { ActionType.TeamDinner, new ActionEffect(_gameConstants.forcedValue, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 + { ActionType.TeamDinner, new ActionEffect(_gameConstants.wakeUpAtEight, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 { ActionType.Absence, new ActionEffect(0, 0, -3.0f) } }; } From ca8d769ab8e8908a2f7d0ca03e45591f2b4da37f Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Fri, 18 Apr 2025 13:21:10 +0900 Subject: [PATCH 8/9] =?UTF-8?q?DEG-15=20[Fix]=20=EC=86=8C=EC=88=98?= =?UTF-8?q?=EC=A0=90=20=EC=98=A4=EB=A5=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameConstants.cs | 5 +---- Assets/KSH/PlayerStats.cs | 5 +++-- Assets/KSH/ValueByAction.cs | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Assets/KSH/GameConstants.cs b/Assets/KSH/GameConstants.cs index d42c6808..2bd483bb 100644 --- a/Assets/KSH/GameConstants.cs +++ b/Assets/KSH/GameConstants.cs @@ -35,10 +35,7 @@ public class GameConstants // 기상 시간 public float wakeUpTime = 8.0f; - // 오전 8시 기상 값 - public float wakeUpAtEight = 888f; - - // 강제 값 (탈진, 결근-늦잠) + // 수면 이벤트 강제 값 public float forcedValue = 999f; // 날짜 한계 값 diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index be92e15b..68bde807 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -73,7 +73,7 @@ public class PlayerStats : MonoBehaviour bool isDayEnded = false; // 수면 행동 처리 - if (actionType == ActionType.Sleep) // 다음 날 오전 8시 기상 + if (actionType == ActionType.Sleep || actionType == ActionType.TeamDinner) // 다음 날 오전 8시 기상 { // 다음 날 오전 8시 - 현재 시간 값 float nowTime = TimeStat - time; @@ -178,7 +178,8 @@ public class PlayerStats : MonoBehaviour public void ModifyReputation(float reputation) { - ReputationStat += reputation; + // float 연산 시 계산 오차가 발생할 수도 있기에 소수점 두 번째에서 반올림하도록 처리 + ReputationStat = Mathf.Round((ReputationStat + reputation) * 100f) / 100f; if (ReputationStat <= 0) { diff --git a/Assets/KSH/ValueByAction.cs b/Assets/KSH/ValueByAction.cs index 7e66a79a..594f0b7f 100644 --- a/Assets/KSH/ValueByAction.cs +++ b/Assets/KSH/ValueByAction.cs @@ -33,7 +33,7 @@ public class ValueByAction actionEffects = new Dictionary { // 기본 액션들, 효과(시간, 체력, 평판 순) - { ActionType.Sleep, new ActionEffect(_gameConstants.wakeUpAtEight, 0, 0) }, // 8시 강제 기상 + { ActionType.Sleep, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 8시 강제 기상 { ActionType.OverSlept, new ActionEffect(_gameConstants.forcedValue, 0, 0) }, // 결근 (오후 3~6시 기상) { ActionType.ForcedSleep, new ActionEffect(_gameConstants.forcedValue, 4, 0) }, // 탈진 { ActionType.Eat, new ActionEffect(+1.0f, +1.0f, 0) }, @@ -41,7 +41,7 @@ public class ValueByAction { ActionType.Dungeon, new ActionEffect(+3.0f, -3.0f, 0) }, { ActionType.Housework, new ActionEffect(+1.0f, -1.0f, +0.2f) }, { ActionType.OvertimeWork, new ActionEffect(+4.0f, -5.0f, +1.0f) }, - { ActionType.TeamDinner, new ActionEffect(_gameConstants.wakeUpAtEight, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 + { ActionType.TeamDinner, new ActionEffect(_gameConstants.forcedValue, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 { ActionType.Absence, new ActionEffect(0, 0, -3.0f) } }; } From a10f257d1c276b8399ca81fadbd380c18abb87d5 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Fri, 18 Apr 2025 14:20:23 +0900 Subject: [PATCH 9/9] =?UTF-8?q?DEG-15=20[Fix]=20=ED=94=BC=EB=93=9C?= =?UTF-8?q?=EB=B0=B1=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KSH/GameManager.cs | 11 ++++++----- Assets/KSH/PlayerStats.cs | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/KSH/GameManager.cs b/Assets/KSH/GameManager.cs index 8082bc57..80b0725b 100644 --- a/Assets/KSH/GameManager.cs +++ b/Assets/KSH/GameManager.cs @@ -24,11 +24,12 @@ public class GameManager : Singleton if (playerStats == null) { playerStats = FindObjectOfType(); - if (playerStats == null) - { - Debug.LogError("PlayerStats 컴포넌트를 찾을 수 없습니다. 함께 추가해주세요."); - return; - } + } + + if (playerStats == null) + { + Debug.LogError("PlayerStats 컴포넌트를 찾을 수 없습니다."); + return; } playerStats.OnDayEnded += AdvanceDay; } diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index 68bde807..703c3a1f 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -97,7 +97,7 @@ public class PlayerStats : MonoBehaviour else if (actionType == ActionType.OverSlept) // 늦잠, 오전 8시에 행동을 결정하기에 하루 지남 X { // 다음 날 오후 3~6시 사이 기상, 추가 체력 회복 - float randomWakeUpTime = Random.Range(15, 18); + float randomWakeUpTime = Random.Range(15, 19); TimeStat = randomWakeUpTime; // 추가 체력 회복 @@ -112,7 +112,7 @@ public class PlayerStats : MonoBehaviour isDayEnded = !isEarlyMorning; // 다음 날 오후 3~6시 사이 기상 - float randomWakeUpTime = Random.Range(15, 18); + float randomWakeUpTime = Random.Range(15, 19); TimeStat = randomWakeUpTime; } else // 수면 이외의 행동