DEG-168 [FEAT] 돌발이벤트 후 강제숙면, 생활 능력치 업그레이드 #61

Merged
jay merged 6 commits from DEG-168-돌발이벤트-후-강제숙면-생활-능력치-업그레이드 into main 2025-05-14 09:06:39 +00:00
6 changed files with 73 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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}";

View File

@ -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) },
Review

이전 PR에서는 OvertimeWork의 시간 값이 _gameConstants.forcedValue 였던 것 같은데 충돌 처리 때문에 이전으로 잠시 돌리신 건가용?

이전 PR에서는 OvertimeWork의 시간 값이 _gameConstants.forcedValue 였던 것 같은데 충돌 처리 때문에 이전으로 잠시 돌리신 건가용?
Review

맞습니다!

맞습니다!
{ 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) }
};
}

View File

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

View File

@ -126,6 +126,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()
{
foreach (var image in suddenEventImages)

View File

@ -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) // 결근
Review

TeamDinner나 OvertimeWork는 다음날로 자동으로 넘어가기 때문에 이렇게 추가하신 건가요?

TeamDinner나 OvertimeWork는 다음날로 자동으로 넘어가기 때문에 이렇게 추가하신 건가요?
Review

해당 부분으로 막지 않으면 돌발 이벤트 때 결근 메서드가 호출됩니다. 그래서 두번 돌발이벤트 뜨면 해고 엔딩 나오길래 막기 위해 추가했습니다.

해당 부분으로 막지 않으면 돌발 이벤트 때 결근 메서드가 호출됩니다. 그래서 두번 돌발이벤트 뜨면 해고 엔딩 나오길래 막기 위해 추가했습니다.
{
_isAbsenceToday = true;
}