DEG-152 [Feat] 행동 체크와 말풍선 수정
This commit is contained in:
parent
d74872d7a1
commit
5b6414274d
@ -10,9 +10,9 @@ public class DungeonPanelController : MonoBehaviour
|
|||||||
[SerializeField] private Image[] _playerHealthImages; // color 값 white / black 로 조정
|
[SerializeField] private Image[] _playerHealthImages; // color 값 white / black 로 조정
|
||||||
private int _countHealth = 0;
|
private int _countHealth = 0;
|
||||||
|
|
||||||
public void SetBossHealthBar(float hp) // hp: 0~100
|
public void SetBossHealthBar(float hp) // hp: 0~300
|
||||||
{
|
{
|
||||||
float normalizedHp = hp / 100f; // 0~1 사이 값으로 조정
|
float normalizedHp = hp / 300f; // 0~1 사이 값으로 조정
|
||||||
_bossHealthBar.value = normalizedHp;
|
_bossHealthBar.value = normalizedHp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +41,19 @@ public class PlayerStats : MonoBehaviour
|
|||||||
|
|
||||||
// 결근 이벤트 관련 변수
|
// 결근 이벤트 관련 변수
|
||||||
private bool _hasWorkedToday = false;
|
private bool _hasWorkedToday = false;
|
||||||
|
public bool HasWorkedToday => _hasWorkedToday;
|
||||||
private bool _hasCheckedAbsenceToday = false; // 결근 체크, 하루에 결근 여러 번 체크 안하기 위함
|
private bool _hasCheckedAbsenceToday = false; // 결근 체크, 하루에 결근 여러 번 체크 안하기 위함
|
||||||
public event Action OnAbsent; // 결근
|
public event Action OnAbsent; // 결근
|
||||||
|
|
||||||
// 말풍선
|
// 말풍선
|
||||||
private GameObject messagePanelInstance;
|
private GameObject _messagePanelInstance;
|
||||||
private SpeechBubbleFollower speechBubbleFollower;
|
private SpeechBubbleFollower _speechBubbleFollower;
|
||||||
private bool isActiveBubble;
|
private bool _isActiveBubble;
|
||||||
private bool hasShownBubbleToday; // 하루에 말풍선 하나만 표시하기
|
private bool _hasShownBubbleToday; // 하루에 말풍선 하나만 표시하기
|
||||||
|
|
||||||
|
private int _mealCount;
|
||||||
|
public int MealCount => _mealCount;
|
||||||
|
private const int MAX_MEAL_COUNT = 2; // 하루 2회 제한
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@ -77,6 +82,7 @@ public class PlayerStats : MonoBehaviour
|
|||||||
CheckBubble();
|
CheckBubble();
|
||||||
|
|
||||||
SceneManager.sceneLoaded += OnSceneLoaded; // 씬 전환 이벤트
|
SceneManager.sceneLoaded += OnSceneLoaded; // 씬 전환 이벤트
|
||||||
|
_mealCount = 0; // 식사 횟수 0회
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 말풍선(Bubble) 관련
|
#region 말풍선(Bubble) 관련
|
||||||
@ -96,10 +102,10 @@ public class PlayerStats : MonoBehaviour
|
|||||||
|
|
||||||
private void LoadMessagePanel()
|
private void LoadMessagePanel()
|
||||||
{
|
{
|
||||||
if (messagePanelInstance != null) // 기존 패널 파괴
|
if (_messagePanelInstance != null) // 기존 패널 파괴
|
||||||
{
|
{
|
||||||
Destroy(messagePanelInstance);
|
Destroy(_messagePanelInstance);
|
||||||
messagePanelInstance = null;
|
_messagePanelInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject messagePanelPrefab = Resources.Load<GameObject>("Prefabs/MessagePanel");
|
GameObject messagePanelPrefab = Resources.Load<GameObject>("Prefabs/MessagePanel");
|
||||||
@ -108,49 +114,57 @@ public class PlayerStats : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Canvas canvas = FindObjectOfType<Canvas>();
|
Canvas canvas = FindObjectOfType<Canvas>();
|
||||||
|
|
||||||
messagePanelInstance = Instantiate(messagePanelPrefab, canvas.transform);
|
_messagePanelInstance = Instantiate(messagePanelPrefab, canvas.transform);
|
||||||
speechBubbleFollower = messagePanelInstance.GetComponent<SpeechBubbleFollower>();
|
_speechBubbleFollower = _messagePanelInstance.GetComponent<SpeechBubbleFollower>();
|
||||||
speechBubbleFollower.SetPlayerTransform();
|
_speechBubbleFollower.SetPlayerTransform();
|
||||||
|
|
||||||
if (speechBubbleFollower != null)
|
if (_speechBubbleFollower != null)
|
||||||
{
|
{
|
||||||
isActiveBubble = false;
|
_isActiveBubble = false;
|
||||||
hasShownBubbleToday = false;
|
_hasShownBubbleToday = false;
|
||||||
speechBubbleFollower.HideMessage();
|
_speechBubbleFollower.HideMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckBubble()
|
private void CheckBubble()
|
||||||
{
|
{
|
||||||
if (isActiveBubble)
|
if (_isActiveBubble)
|
||||||
{
|
{
|
||||||
isActiveBubble = false;
|
_isActiveBubble = false;
|
||||||
HideBubble();
|
HideBubble();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TimeStat >= 8.0f && TimeStat < 9.0f && !isActiveBubble && !hasShownBubbleToday)
|
if (TimeStat >= 8.0f && TimeStat < 9.0f && !_isActiveBubble && !_hasShownBubbleToday)
|
||||||
{
|
{
|
||||||
hasShownBubbleToday = true;
|
_hasShownBubbleToday = true;
|
||||||
isActiveBubble = true;
|
_isActiveBubble = true;
|
||||||
ShowBubble();
|
ShowBubble();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InteractionAnimationPanelController _interactionAnimation;
|
||||||
|
public void SetInteractionPanelController(InteractionAnimationPanelController panelController)
|
||||||
|
{
|
||||||
|
_interactionAnimation = panelController;
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowBubble()
|
public void ShowBubble()
|
||||||
{
|
{
|
||||||
if(isActiveBubble)
|
if (_interactionAnimation.IsPanelActive()) return;
|
||||||
speechBubbleFollower.ShowMessage();
|
|
||||||
|
if(_isActiveBubble)
|
||||||
|
_speechBubbleFollower.ShowMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideBubble()
|
public void HideBubble()
|
||||||
{
|
{
|
||||||
speechBubbleFollower.HideMessage();
|
_speechBubbleFollower.HideMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowAndHideBubble(string text)
|
public void ShowAndHideBubble(string text)
|
||||||
{
|
{
|
||||||
speechBubbleFollower.ShowAndHide(text);
|
_speechBubbleFollower.ShowAndHide(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -172,13 +186,17 @@ public class PlayerStats : MonoBehaviour
|
|||||||
// 9시가 지났는데 출근하지 않은 경우
|
// 9시가 지났는데 출근하지 않은 경우
|
||||||
if (TimeStat >= 9.0f && !_hasWorkedToday)
|
if (TimeStat >= 9.0f && !_hasWorkedToday)
|
||||||
{
|
{
|
||||||
_hasCheckedAbsenceToday = true; // 결근 체크 완료 표시
|
PerformAbsent();
|
||||||
OnAbsent?.Invoke();
|
|
||||||
|
|
||||||
PerformAction(ActionType.Absence); // 평판 -3
|
|
||||||
Debug.Log("결근 처리: 평판 감소" + ReputationStat);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PerformAbsent() // 강제 결근 이벤트
|
||||||
|
{
|
||||||
|
_hasCheckedAbsenceToday = true; // 결근 체크 완료 표시
|
||||||
|
OnAbsent?.Invoke();
|
||||||
|
|
||||||
|
PerformAction(ActionType.Absence); // 평판 -3
|
||||||
|
}
|
||||||
|
|
||||||
// 행동 처리 메서드
|
// 행동 처리 메서드
|
||||||
public void PerformAction(ActionType actionType)
|
public void PerformAction(ActionType actionType)
|
||||||
@ -200,6 +218,16 @@ public class PlayerStats : MonoBehaviour
|
|||||||
_hasWorkedToday = true;
|
_hasWorkedToday = true;
|
||||||
OnWorked?.Invoke();
|
OnWorked?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actionType == ActionType.Eat)
|
||||||
|
{
|
||||||
|
_mealCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanEat()
|
||||||
|
{
|
||||||
|
return _mealCount < MAX_MEAL_COUNT; // 식사 횟수 0,1 일 때만 true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 출근 가능 여부 확인 메서드
|
// 출근 가능 여부 확인 메서드
|
||||||
@ -271,7 +299,10 @@ public class PlayerStats : MonoBehaviour
|
|||||||
// 결근 관련 변수 초기화
|
// 결근 관련 변수 초기화
|
||||||
_hasWorkedToday = false;
|
_hasWorkedToday = false;
|
||||||
_hasCheckedAbsenceToday = false;
|
_hasCheckedAbsenceToday = false;
|
||||||
hasShownBubbleToday = false;
|
_hasShownBubbleToday = false;
|
||||||
|
|
||||||
|
// 식사 횟수 초기화
|
||||||
|
_mealCount = 0;
|
||||||
|
|
||||||
OnDayEnded?.Invoke();
|
OnDayEnded?.Invoke();
|
||||||
}
|
}
|
||||||
@ -302,7 +333,7 @@ public class PlayerStats : MonoBehaviour
|
|||||||
{
|
{
|
||||||
EndDay(time, actionType);
|
EndDay(time, actionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBubble();
|
CheckBubble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ public class InteractionController : MonoBehaviour
|
|||||||
|
|
||||||
[Header("UI 연동")]
|
[Header("UI 연동")]
|
||||||
[SerializeField] private HousingCanvasController housingCanvasController;
|
[SerializeField] private HousingCanvasController housingCanvasController;
|
||||||
|
|
||||||
[SerializeField] private InteractionAnimationPanelController interactionAnimationPanelController;
|
[SerializeField] private InteractionAnimationPanelController interactionAnimationPanelController;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
PlayerStats.Instance.OnWorked += SuddenAfterWorkEventHappen;
|
PlayerStats.Instance.OnWorked += SuddenAfterWorkEventHappen;
|
||||||
|
PlayerStats.Instance.SetInteractionPanelController(interactionAnimationPanelController);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 상호작용 가능한 사물 범위에 들어올 때
|
// 상호작용 가능한 사물 범위에 들어올 때
|
||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
@ -72,6 +72,12 @@ public class InteractionController : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (interactionType == ActionType.Eat && !PlayerStats.Instance.CanEat()) // 식사 횟수 제한 체크
|
||||||
|
{
|
||||||
|
PlayerStats.Instance.ShowAndHideBubble("배불러서 못 먹어");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (interactionType == ActionType.Dungeon)
|
if (interactionType == ActionType.Dungeon)
|
||||||
{
|
{
|
||||||
@ -117,6 +123,20 @@ public class InteractionController : MonoBehaviour
|
|||||||
|
|
||||||
housingCanvasController.ShowSuddenEventPanel(suddenEventText, () =>
|
housingCanvasController.ShowSuddenEventPanel(suddenEventText, () =>
|
||||||
{
|
{
|
||||||
|
if (afterWorkEventType == AfterWorkEventType.OvertimeWork)
|
||||||
|
{
|
||||||
|
if (!PlayerStats.Instance.CanPerformByHealth(ActionType.OvertimeWork))
|
||||||
|
{
|
||||||
|
PlayerStats.Instance.ShowAndHideBubble("체력이 없어...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlayerStats.Instance.PerformAction(ActionType.OvertimeWork);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlayerStats.Instance.PerformAction(ActionType.TeamDinner);
|
||||||
|
}
|
||||||
|
|
||||||
housingCanvasController.ShowSuddenEventImage(afterWorkEventType);
|
housingCanvasController.ShowSuddenEventImage(afterWorkEventType);
|
||||||
GameManager.Instance.PlaySuddenEventSound(afterWorkEventType);
|
GameManager.Instance.PlaySuddenEventSound(afterWorkEventType);
|
||||||
});
|
});
|
||||||
|
@ -17,15 +17,27 @@ public class InteractionAnimationPanelController : MonoBehaviour
|
|||||||
private Coroutine _textAnimCoroutine;
|
private Coroutine _textAnimCoroutine;
|
||||||
private Coroutine _autoHideCoroutine;
|
private Coroutine _autoHideCoroutine;
|
||||||
private Canvas _parentCanvas;
|
private Canvas _parentCanvas;
|
||||||
|
|
||||||
|
private bool _isAbsenceToday = false;
|
||||||
|
|
||||||
public void SetDoingText(string text)
|
public void SetDoingText(string text)
|
||||||
{
|
{
|
||||||
doingText.text = text;
|
doingText.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsPanelActive()
|
||||||
|
{
|
||||||
|
return panel.activeSelf;
|
||||||
|
}
|
||||||
|
|
||||||
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) // 결근
|
||||||
|
{
|
||||||
|
_isAbsenceToday = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 1) 패널 활성화
|
// 1) 패널 활성화
|
||||||
panel.SetActive(true);
|
panel.SetActive(true);
|
||||||
@ -110,6 +122,12 @@ public class InteractionAnimationPanelController : MonoBehaviour
|
|||||||
StopCoroutine(_autoHideCoroutine);
|
StopCoroutine(_autoHideCoroutine);
|
||||||
_autoHideCoroutine = null;
|
_autoHideCoroutine = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_isAbsenceToday) // 결근한 경우
|
||||||
|
{
|
||||||
|
PlayerStats.Instance.PerformAbsent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 패널 닫히고 결근 체크, 상호작용 패널과 결근 엔딩 채팅창이 겹치지 않기 위함
|
// 패널 닫히고 결근 체크, 상호작용 패널과 결근 엔딩 채팅창이 겹치지 않기 위함
|
||||||
PlayerStats.Instance.CheckAbsent();
|
PlayerStats.Instance.CheckAbsent();
|
||||||
|
BIN
Assets/Prefabs/ReHousing/Canvas.prefab
(Stored with Git LFS)
BIN
Assets/Prefabs/ReHousing/Canvas.prefab
(Stored with Git LFS)
Binary file not shown.
@ -7,7 +7,7 @@ public abstract class CharacterBase : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[Header("기본 능력치")]
|
[Header("기본 능력치")]
|
||||||
public string characterName; // 이름
|
public string characterName; // 이름
|
||||||
public int maxHP = 100; // 최대 체력
|
private int maxHP = 300; // 최대 체력
|
||||||
public int currentHP; // 현재 체력
|
public int currentHP; // 현재 체력
|
||||||
public float attackPower = 10f; // 공격력
|
public float attackPower = 10f; // 공격력
|
||||||
public float defensePower = 5f; // 방어력
|
public float defensePower = 5f; // 방어력
|
||||||
|
Loading…
x
Reference in New Issue
Block a user