[Feat] 스탯관리 연동 완료

This commit is contained in:
HaeinLEE 2025-04-19 23:20:45 +09:00
parent 0c505bb617
commit eb7d01e4f6
9 changed files with 80 additions and 63 deletions

View File

@ -36,7 +36,7 @@ public class PlayerStats : MonoBehaviour
{ {
ActionEffect effect = _valueByAction.GetActionEffect(actionType); ActionEffect effect = _valueByAction.GetActionEffect(actionType);
if (HealthStat >= effect.healthChange) if (HealthStat >= (effect.healthChange*-1))
{ {
return true; return true;
} }

View File

@ -4,9 +4,9 @@ using UnityEngine;
public class DailyRoutineBed : DailyRoutine public class DailyRoutineBed : DailyRoutine
{ {
public override InteractionType RoutineEnter() public override ActionType RoutineEnter()
{ {
return InteractionType.Bed; return ActionType.Sleep;
} }
protected override void RoutineConfirm() protected override void RoutineConfirm()

View File

@ -3,7 +3,6 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
public enum InteractionType {Bed,Sink,Fridge,Work}
[RequireComponent(typeof(Rigidbody))] [RequireComponent(typeof(Rigidbody))]
public class DailyRoutineController : MonoBehaviour public class DailyRoutineController : MonoBehaviour
@ -13,53 +12,12 @@ public class DailyRoutineController : MonoBehaviour
[Header("UI 연동")] [Header("UI 연동")]
[SerializeField] HousingCanvasManager housingCanvasManager; [SerializeField] HousingCanvasManager housingCanvasManager;
private Canvas _canvas;
private void Start()
{
SetCanvas();
}
private void OnCollisionEnter(Collision other) private void OnCollisionEnter(Collision other)
{ {
if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer))) if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer)))
{ {
InteractionType interactionType = other.gameObject.GetComponent<DailyRoutine>().RoutineEnter(); ActionType interactionType = other.gameObject.GetComponent<DailyRoutine>().RoutineEnter();
PopActionOnScreen(interactionType);
switch (interactionType)
{
case InteractionType.Bed:
housingCanvasManager.ShowInteractionButton("침대에서 잘까?","숙면으로 시간 당 체력 1을 회복한다.", () =>
{
//TODO: 숙면 할 때 할 일 작성
Debug.Log("숙면 행동을 시작합니다");
});
break;
case InteractionType.Sink:
housingCanvasManager.ShowInteractionButton("밀린 집안일을 처리할까?","체력 1을 사용하고 좋은일이 일어날지도 모른다", () =>
{
//TODO: 집안일수행, 랜덤 강화 작성
Debug.Log("집안일을 시작합니다");
Debug.Log(
playerStats.CanPerformByHealth(ActionType.Housework));
});
break;
case InteractionType.Fridge:
housingCanvasManager.ShowInteractionButton("던전에 입장할까?","체력 3을 사용하고 3시간이 흐른다.", () =>
{
//TODO: 던전 입장
Debug.Log("던전으로 이동 합니다.. 씬전환");
});
break;
case InteractionType.Work:
housingCanvasManager.ShowInteractionButton("출근한다.","체력 3을 사용하고 저녁 6시에나 돌아오겠지..", () =>
{
//TODO: 던전 입장
Debug.Log("출근 후 컷씬 연출");
});
break;
}
} }
} }
@ -70,12 +28,68 @@ public class DailyRoutineController : MonoBehaviour
housingCanvasManager.HideInteractionButton(); housingCanvasManager.HideInteractionButton();
} }
} }
private void PopActionOnScreen(ActionType interactionType)
private void SetCanvas()
{ {
if (_canvas == null) switch (interactionType)
{ {
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>(); case ActionType.Sleep:
housingCanvasManager.ShowInteractionButton("침대에서 잘까?","숙면으로 시간 당 체력 1을 회복한다.", () =>
{
if (playerStats.CanPerformByHealth(ActionType.Sleep))
{
playerStats.PerformAction(ActionType.Sleep);
}
else
{
housingCanvasManager.SetActionText("지금 체력으로 잘 수 없다..");
housingCanvasManager.SetDescriptionText();
}
});
break;
case ActionType.Housework:
housingCanvasManager.ShowInteractionButton("밀린 집안일을 처리할까?","체력 1을 사용하고 좋은일이 일어날지도 모른다", () =>
{
if (playerStats.CanPerformByHealth(ActionType.Housework))
{
playerStats.PerformAction(ActionType.Housework);
//TODO: 집안일 후 랜덤 강화 효과 적용
}
else
{
housingCanvasManager.SetActionText("집안일 할 체력이 남아있지 않다..");
housingCanvasManager.SetDescriptionText();
}
});
break;
case ActionType.Dungeon:
housingCanvasManager.ShowInteractionButton("던전에 입장할까?","체력 3을 사용하고 3시간이 흐른다.", () =>
{
if (playerStats.CanPerformByHealth(ActionType.Dungeon))
{
playerStats.PerformAction(ActionType.Dungeon);
}
else
{
housingCanvasManager.SetActionText("던전에 갈 체력이 되지 않아..");
housingCanvasManager.SetDescriptionText();
}
});
break;
case ActionType.Work:
housingCanvasManager.ShowInteractionButton("출근한다.","체력 3을 사용하고 저녁 6시에나 돌아오겠지..", () =>
{
if (playerStats.CanPerformByHealth(ActionType.Work))
{
playerStats.PerformAction(ActionType.Work);
Debug.Log("출근");
}
else
{
housingCanvasManager.SetActionText("도저히 출근할 체력이 안되는걸..?");
housingCanvasManager.SetDescriptionText();
}
});
break;
} }
} }
} }

View File

@ -4,9 +4,9 @@ using UnityEngine;
public class DailyRoutineFridge : DailyRoutine public class DailyRoutineFridge : DailyRoutine
{ {
public override InteractionType RoutineEnter() public override ActionType RoutineEnter()
{ {
return InteractionType.Fridge; return ActionType.Dungeon;
} }
protected override void RoutineConfirm() protected override void RoutineConfirm()

View File

@ -4,9 +4,9 @@ using UnityEngine;
public class DailyRoutineSink : DailyRoutine public class DailyRoutineSink : DailyRoutine
{ {
public override InteractionType RoutineEnter() public override ActionType RoutineEnter()
{ {
return InteractionType.Sink; return ActionType.Housework;
} }
protected override void RoutineConfirm() protected override void RoutineConfirm()

View File

@ -4,9 +4,9 @@ using UnityEngine;
public class DailyRoutineWork : DailyRoutine public class DailyRoutineWork : DailyRoutine
{ {
public override InteractionType RoutineEnter() public override ActionType RoutineEnter()
{ {
return InteractionType.Work; return ActionType.Work;
} }
protected override void RoutineConfirm() protected override void RoutineConfirm()

View File

@ -4,7 +4,7 @@ using UnityEngine;
public abstract class DailyRoutine: MonoBehaviour public abstract class DailyRoutine: MonoBehaviour
{ {
public abstract InteractionType RoutineEnter(); public abstract ActionType RoutineEnter();
protected abstract void RoutineConfirm(); protected abstract void RoutineConfirm();

BIN
Assets/LIN/Housing Copy.unity (Stored with Git LFS)

Binary file not shown.

View File

@ -19,12 +19,13 @@ public class HousingCanvasManager : MonoBehaviour
SetDescriptionText(); SetDescriptionText();
interactionButton.SetActive(false); interactionButton.SetActive(false);
} }
//사물 이름 세팅
//사물 이름 세팅
public void SetActionText(string text = "") public void SetActionText(string text = "")
{ {
actionText.text = text; actionText.text = text;
} }
//사물 상호작용 내용 설명 //사물 상호작용 내용 설명
public void SetDescriptionText(string text = "") public void SetDescriptionText(string text = "")
{ {
descriptionText.text = text; descriptionText.text = text;
@ -39,7 +40,8 @@ public class HousingCanvasManager : MonoBehaviour
//각 행동 별로 실행되어야 할 이벤트 구독 //각 행동 별로 실행되어야 할 이벤트 구독
OnInteractionButtonPressed = onInteractionButtonPressed; OnInteractionButtonPressed = onInteractionButtonPressed;
} }
//범위에서 벗어나면 상호작용 버튼 off
public void HideInteractionButton() public void HideInteractionButton()
{ {
SetActionText(); SetActionText();
@ -50,6 +52,7 @@ public class HousingCanvasManager : MonoBehaviour
OnInteractionButtonPressed = null; OnInteractionButtonPressed = null;
} }
//상호작용 버튼 눌렀을 때
public void OnClickInteractionButton() public void OnClickInteractionButton()
{ {
OnInteractionButtonPressed?.Invoke(); OnInteractionButtonPressed?.Invoke();