[Style] Interaction 용어 통일, 주석 추가
This commit is contained in:
parent
faef0b4124
commit
f1ca9d0252
@ -1,16 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyRoutineBed : DailyRoutine
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Sleep;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
{
|
||||
//숙면: 시간 계산, 8시간 이상시 체력 완충, 미만시 강제기상 체력 회복
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DailyRoutine: MonoBehaviour
|
||||
{
|
||||
public abstract ActionType RoutineEnter();
|
||||
|
||||
|
||||
protected abstract void RoutineConfirm();
|
||||
}
|
@ -5,22 +5,24 @@ using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class DailyRoutineController : MonoBehaviour
|
||||
public class InteractionController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] PlayerStats playerStats;
|
||||
[SerializeField] LayerMask interactionLayerMask;
|
||||
[Header("UI 연동")]
|
||||
[SerializeField] HousingCanvasManager housingCanvasManager;
|
||||
|
||||
// 상호작용 가능한 사물 범위에 들어올 때
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer)))
|
||||
{
|
||||
ActionType interactionType = other.gameObject.GetComponent<DailyRoutine>().RoutineEnter();
|
||||
ActionType interactionType = other.gameObject.GetComponent<InteractionProp>().RoutineEnter();
|
||||
PopActionOnScreen(interactionType);
|
||||
}
|
||||
}
|
||||
|
||||
// 사물에서 벗어날 때 UI 정리
|
||||
private void OnCollisionExit(Collision other)
|
||||
{
|
||||
if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer)))
|
||||
@ -28,6 +30,8 @@ public class DailyRoutineController : MonoBehaviour
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
}
|
||||
}
|
||||
|
||||
// ActionType 별로 화면에 상호작용 내용 표시, 상호작용 버튼에 이벤트 작성
|
||||
private void PopActionOnScreen(ActionType interactionType)
|
||||
{
|
||||
switch (interactionType)
|
||||
@ -38,6 +42,8 @@ public class DailyRoutineController : MonoBehaviour
|
||||
if (playerStats.CanPerformByHealth(ActionType.Sleep))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Sleep);
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
//TODO: 화면 전환 효과와 UI 업데이트 작업
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -52,11 +58,12 @@ public class DailyRoutineController : MonoBehaviour
|
||||
if (playerStats.CanPerformByHealth(ActionType.Housework))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Housework);
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
//TODO: 집안일 후 랜덤 강화 효과 적용
|
||||
}
|
||||
else
|
||||
{
|
||||
housingCanvasManager.SetActionText("집안일 할 체력이 남아있지 않다..");
|
||||
housingCanvasManager.SetActionText("힘들어서 못해..");
|
||||
housingCanvasManager.SetDescriptionText();
|
||||
}
|
||||
});
|
||||
@ -67,6 +74,7 @@ public class DailyRoutineController : MonoBehaviour
|
||||
if (playerStats.CanPerformByHealth(ActionType.Dungeon))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Dungeon);
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -81,7 +89,7 @@ public class DailyRoutineController : MonoBehaviour
|
||||
if (playerStats.CanPerformByHealth(ActionType.Work))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Work);
|
||||
Debug.Log("출근");
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
}
|
||||
else
|
||||
{
|
8
Assets/LIN/DailyRoutine/InteractionProp.cs
Normal file
8
Assets/LIN/DailyRoutine/InteractionProp.cs
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class InteractionProp: MonoBehaviour
|
||||
{
|
||||
public abstract ActionType RoutineEnter();
|
||||
}
|
10
Assets/LIN/DailyRoutine/InteractionPropBed.cs
Normal file
10
Assets/LIN/DailyRoutine/InteractionPropBed.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InteractionPropBed : InteractionProp
|
||||
{ public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Sleep;
|
||||
}
|
||||
}
|
@ -2,15 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyRoutineFridge : DailyRoutine
|
||||
public class InteractionPropFridge : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Dungeon;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
{
|
||||
// 던전입장 : 시간3, 체력3 소모 후 씬 전환
|
||||
}
|
||||
}
|
@ -2,15 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyRoutineSink : DailyRoutine
|
||||
public class InteractionPropSink : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Housework;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
{
|
||||
//식사: 1시간 소모 1체력 회복
|
||||
}
|
||||
}
|
@ -2,14 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyRoutineWork : DailyRoutine
|
||||
public class InteractionPropWork : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Work;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
{
|
||||
}
|
||||
}
|
@ -15,8 +15,7 @@ public class HousingCanvasManager : MonoBehaviour
|
||||
|
||||
void Awake()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
InitTexts();
|
||||
interactionButton.SetActive(false);
|
||||
}
|
||||
|
||||
@ -31,6 +30,13 @@ public class HousingCanvasManager : MonoBehaviour
|
||||
descriptionText.text = text;
|
||||
}
|
||||
|
||||
private void InitTexts()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
}
|
||||
|
||||
// 상호작용 가능한 사물에 가까이 갔을 때 화면에 텍스트, 버튼 표시
|
||||
public void ShowInteractionButton(string actText, string descText,Action onInteractionButtonPressed)
|
||||
{
|
||||
SetActionText(actText);
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user