diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index b3690490..42192c68 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -39,6 +39,11 @@ public class PlayerStats : MonoBehaviour,ISaveable public static PlayerStats Instance; + private float additionalMaxHealth = 0f; + public float MaxHealth => _gameConstants.maxHealth + additionalMaxHealth; + + public ActionType LastAction { get; private set; } + // 결근 이벤트 관련 변수 private bool _hasWorkedToday = false; public bool HasWorkedToday => _hasWorkedToday; @@ -203,16 +208,22 @@ public class PlayerStats : MonoBehaviour,ISaveable { // 액션에 따른 스탯 소모 값 가져오기 ActionEffect effect = _valueByAction.GetActionEffect(actionType); - - // 스탯 변경 적용 + LastAction = actionType; + // 선 처리: 특수 보상 먼저 (야근, 회식) + if (actionType == ActionType.TeamDinner) + { + additionalMaxHealth += 1f; + } + + // 순수 스탯 변경 적용 ModifyTime(effect.timeChange, actionType); ModifyHealth(effect.healthChange); ModifyReputation(effect.reputationChange); - - // 스탯 변경 이벤트 (UI 업데이트용) + + // UI 업데이트용 OnStatsChanged?.Invoke(new StatsChangeData(TimeStat, HealthStat, ReputationStat)); - // 스탯 - 시간이 변경된 이후 퇴근 이벤트 발생 + // 출근 후 퇴근 이벤트 발생 if (actionType == ActionType.Work) { _hasWorkedToday = true; @@ -225,6 +236,7 @@ public class PlayerStats : MonoBehaviour,ISaveable } } + public bool CanEat() { return _mealCount < MAX_MEAL_COUNT; // 식사 횟수 0,1 일 때만 true @@ -245,7 +257,7 @@ public class PlayerStats : MonoBehaviour,ISaveable bool isDayEnded = false; // 수면 행동 처리 - if (actionType == ActionType.Sleep || actionType == ActionType.TeamDinner) // 다음 날 오전 8시 기상 + if (actionType == ActionType.Sleep || actionType == ActionType.TeamDinner || actionType == ActionType.OvertimeWork) // 다음 날 오전 8시 기상 { // 다음 날 오전 8시 - 현재 시간 값 float nowTime = TimeStat - time; @@ -356,9 +368,9 @@ public class PlayerStats : MonoBehaviour,ISaveable Exhaustion?.Invoke(); } - if (HealthStat > _gameConstants.maxHealth) + if (HealthStat > MaxHealth) { - HealthStat = _gameConstants.maxHealth; + HealthStat = MaxHealth; } } diff --git a/Assets/KSH/StatPanelController.cs b/Assets/KSH/StatPanelController.cs index 74e93fbb..a9e5586a 100644 --- a/Assets/KSH/StatPanelController.cs +++ b/Assets/KSH/StatPanelController.cs @@ -54,8 +54,8 @@ public class StatPanelController : MonoBehaviour private void SetStat(float time, float reputation, float health) { - healthBarImage.fillAmount = health / _gameConstants.maxHealth; - healthText.text = $"{health}/{_gameConstants.maxHealth}"; + healthBarImage.fillAmount = health / PlayerStats.Instance.MaxHealth; + healthText.text = $"{health}/{PlayerStats.Instance.MaxHealth}"; reputationBarImage.fillAmount = reputation / _gameConstants.maxReputation; reputationText.text = $"{reputation}/{_gameConstants.maxReputation}"; diff --git a/Assets/KSH/ValueByAction.cs b/Assets/KSH/ValueByAction.cs index 594f0b7f..ac6d84fb 100644 --- a/Assets/KSH/ValueByAction.cs +++ b/Assets/KSH/ValueByAction.cs @@ -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.forcedValue, _gameConstants.forcedValue, 0) }, // 수면 강제(8시 기상) 후 최대 체력 + { ActionType.TeamDinner, new ActionEffect(_gameConstants.forcedValue, +8.0f, 0) }, // 수면 강제(8시 기상) 후 최대 체력 { ActionType.Absence, new ActionEffect(0, 0, -3.0f) } }; } diff --git a/Assets/LIN/Scripts/DailyRoutine/InteractionController.cs b/Assets/LIN/Scripts/DailyRoutine/InteractionController.cs index 951ad303..bcb349ea 100644 --- a/Assets/LIN/Scripts/DailyRoutine/InteractionController.cs +++ b/Assets/LIN/Scripts/DailyRoutine/InteractionController.cs @@ -137,11 +137,19 @@ public class InteractionController : MonoBehaviour PlayerStats.Instance.PerformAction(ActionType.TeamDinner); } - housingCanvasController.ShowSuddenEventImage(afterWorkEventType); GameManager.Instance.PlaySuddenEventSound(afterWorkEventType); + // 야근 or 회식 돌발 이벤트 실행 시 + housingCanvasController.ShowSuddenEventImageWithCallback(afterWorkEventType, () => + { + // 이미지 다 보여진 후 실행 + interactionAnimationPanelController.ShowAnimationPanel( + ActionType.Sleep, + "너무 피곤해서 그대로 잠들어 버렸다..." + ); + }); }); } - + #endregion } diff --git a/Assets/LIN/Scripts/UI/HousingCanvasController.cs b/Assets/LIN/Scripts/UI/HousingCanvasController.cs index 1839b0ef..c5f82a6e 100644 --- a/Assets/LIN/Scripts/UI/HousingCanvasController.cs +++ b/Assets/LIN/Scripts/UI/HousingCanvasController.cs @@ -125,6 +125,43 @@ public class HousingCanvasController : MonoBehaviour _autoHideCoroutine = StartCoroutine(AutoHideSuddenImage(afterWorkEventType)); } + + public void ShowSuddenEventImageWithCallback(AfterWorkEventType afterWorkEventType, Action onComplete) + { + if (_autoHideCoroutine != null) + StopCoroutine(_autoHideCoroutine); + + switch (afterWorkEventType) + { + case AfterWorkEventType.OvertimeWork: + suddenEventImages[0].SetActive(true); + break; + case AfterWorkEventType.TeamGathering: + suddenEventImages[1].SetActive(true); + break; + } + + _autoHideCoroutine = StartCoroutine(AutoHideSuddenImageWithCallback(afterWorkEventType, onComplete)); + } + + private IEnumerator AutoHideSuddenImageWithCallback(AfterWorkEventType type, Action onComplete) + { + float startTime = Time.time; + while (Time.time - startTime < HousingConstants.SUDDENEVENT_IAMGE_SHOW_TIME) + { + if (Input.touchCount > 0 || Input.GetMouseButtonDown(0)) + break; + + yield return null; + } + + HideSuddenEventImage(); + HideSuddenEventPanel(); + GameManager.Instance.StopSuddenEventSound(type); + + _autoHideCoroutine = null; + onComplete?.Invoke(); + } public void HideSuddenEventImage() { diff --git a/Assets/LIN/Scripts/UI/InteractionAnimationPanelController.cs b/Assets/LIN/Scripts/UI/InteractionAnimationPanelController.cs index 9f999c8e..4f627b56 100644 --- a/Assets/LIN/Scripts/UI/InteractionAnimationPanelController.cs +++ b/Assets/LIN/Scripts/UI/InteractionAnimationPanelController.cs @@ -33,8 +33,9 @@ public class InteractionAnimationPanelController : MonoBehaviour public void ShowAnimationPanel(ActionType actionType, string animationText) { PlayerStats.Instance.HideBubble(); - - if (actionType == ActionType.Sleep && !PlayerStats.Instance.HasWorkedToday) // 결근 + if (actionType == ActionType.Sleep && !PlayerStats.Instance.HasWorkedToday + && PlayerStats.Instance.LastAction != ActionType.TeamDinner + && PlayerStats.Instance.LastAction != ActionType.OvertimeWork) // 결근 { _isAbsenceToday = true; }