Merge pull request 'DEG-168 [FEAT] 돌발이벤트 후 강제숙면, 생활 능력치 업그레이드' (!61) from DEG-168-돌발이벤트-후-강제숙면-생활-능력치-업그레이드 into main

Reviewed-on: #61
Reviewed-by: 99jamin <rhwk341@naver.com>
Reviewed-by: Sehyeon <sehyeon1837@gmail.com>
This commit is contained in:
jay 2025-05-14 09:06:39 +00:00
commit 6403dc74e9
5 changed files with 72 additions and 14 deletions

View File

@ -39,6 +39,11 @@ public class PlayerStats : MonoBehaviour,ISaveable
public static PlayerStats Instance; public static PlayerStats Instance;
private float additionalMaxHealth = 0f;
public float MaxHealth => _gameConstants.maxHealth + additionalMaxHealth;
public ActionType LastAction { get; private set; }
// 결근 이벤트 관련 변수 // 결근 이벤트 관련 변수
private bool _hasWorkedToday = false; private bool _hasWorkedToday = false;
public bool HasWorkedToday => _hasWorkedToday; public bool HasWorkedToday => _hasWorkedToday;
@ -211,16 +216,22 @@ public class PlayerStats : MonoBehaviour,ISaveable
{ {
// 액션에 따른 스탯 소모 값 가져오기 // 액션에 따른 스탯 소모 값 가져오기
ActionEffect effect = _valueByAction.GetActionEffect(actionType); ActionEffect effect = _valueByAction.GetActionEffect(actionType);
LastAction = actionType;
// 선 처리: 특수 보상 먼저 (야근, 회식)
if (actionType == ActionType.TeamDinner)
{
additionalMaxHealth += 1f;
}
// 스탯 변경 적용 // 순수 스탯 변경 적용
ModifyTime(effect.timeChange, actionType); ModifyTime(effect.timeChange, actionType);
ModifyHealth(effect.healthChange); ModifyHealth(effect.healthChange);
ModifyReputation(effect.reputationChange); ModifyReputation(effect.reputationChange);
// 스탯 변경 이벤트 (UI 업데이트용) // UI 업데이트용
OnStatsChanged?.Invoke(new StatsChangeData(TimeStat, HealthStat, ReputationStat)); OnStatsChanged?.Invoke(new StatsChangeData(TimeStat, HealthStat, ReputationStat));
// 스탯 - 시간이 변경된 이후 퇴근 이벤트 발생 // 출근 후 퇴근 이벤트 발생
if (actionType == ActionType.Work) if (actionType == ActionType.Work)
{ {
_hasWorkedToday = true; _hasWorkedToday = true;
@ -233,6 +244,7 @@ public class PlayerStats : MonoBehaviour,ISaveable
} }
} }
public bool CanEat() public bool CanEat()
{ {
return _mealCount < MAX_MEAL_COUNT; // 식사 횟수 0,1 일 때만 true return _mealCount < MAX_MEAL_COUNT; // 식사 횟수 0,1 일 때만 true
@ -253,7 +265,7 @@ public class PlayerStats : MonoBehaviour,ISaveable
bool isDayEnded = false; bool isDayEnded = false;
// 수면 행동 처리 // 수면 행동 처리
if (actionType == ActionType.Sleep || actionType == ActionType.TeamDinner) // 다음 날 오전 8시 기상 if (actionType == ActionType.Sleep || actionType == ActionType.TeamDinner || actionType == ActionType.OvertimeWork) // 다음 날 오전 8시 기상
{ {
// 다음 날 오전 8시 - 현재 시간 값 // 다음 날 오전 8시 - 현재 시간 값
float nowTime = TimeStat - time; float nowTime = TimeStat - time;
@ -364,9 +376,9 @@ public class PlayerStats : MonoBehaviour,ISaveable
Exhaustion?.Invoke(); Exhaustion?.Invoke();
} }
if (HealthStat > _gameConstants.maxHealth) if (HealthStat > MaxHealth)
{ {
HealthStat = _gameConstants.maxHealth; HealthStat = MaxHealth;
} }
} }

View File

@ -54,8 +54,8 @@ public class StatPanelController : MonoBehaviour
private void SetStat(float time, float reputation, float health) private void SetStat(float time, float reputation, float health)
{ {
healthBarImage.fillAmount = health / _gameConstants.maxHealth; healthBarImage.fillAmount = health / PlayerStats.Instance.MaxHealth;
healthText.text = $"{health}/{_gameConstants.maxHealth}"; healthText.text = $"{health}/{PlayerStats.Instance.MaxHealth}";
reputationBarImage.fillAmount = reputation / _gameConstants.maxReputation; reputationBarImage.fillAmount = reputation / _gameConstants.maxReputation;
reputationText.text = $"{reputation}/{_gameConstants.maxReputation}"; reputationText.text = $"{reputation}/{_gameConstants.maxReputation}";

View File

@ -139,8 +139,16 @@ public class InteractionController : MonoBehaviour
PlayerStats.Instance.PerformAction(ActionType.TeamDinner); PlayerStats.Instance.PerformAction(ActionType.TeamDinner);
} }
housingCanvasController.ShowSuddenEventImage(afterWorkEventType);
GameManager.Instance.PlaySuddenEventSound(afterWorkEventType); GameManager.Instance.PlaySuddenEventSound(afterWorkEventType);
// 야근 or 회식 돌발 이벤트 실행 시
housingCanvasController.ShowSuddenEventImageWithCallback(afterWorkEventType, () =>
{
// 이미지 다 보여진 후 실행
interactionAnimationPanelController.ShowAnimationPanel(
ActionType.Sleep,
"너무 피곤해서 그대로 잠들어 버렸다..."
);
});
}); });
} }

View File

@ -113,6 +113,43 @@ public class HousingCanvasController : MonoBehaviour
_autoHideCoroutine = StartCoroutine(AutoHideSuddenImage(afterWorkEventType)); _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() public void HideSuddenEventImage()
{ {
foreach (var image in suddenEventImages) foreach (var image in suddenEventImages)

View File

@ -33,8 +33,9 @@ public class InteractionAnimationPanelController : MonoBehaviour
public void ShowAnimationPanel(ActionType actionType, string animationText) public void ShowAnimationPanel(ActionType actionType, string animationText)
{ {
PlayerStats.Instance.HideBubble(); 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; _isAbsenceToday = true;
} }