[Feat] 일상 활동과 UI 연결
This commit is contained in:
parent
47ebbcaaf7
commit
8aaa44484a
@ -4,10 +4,9 @@ using UnityEngine;
|
||||
|
||||
public class DailyRoutineBed : DailyRoutine
|
||||
{
|
||||
public void RoutineEnter()
|
||||
public override InteractionType RoutineEnter()
|
||||
{
|
||||
base.RoutineEnter();
|
||||
Debug.Log("Its a Bed");
|
||||
return InteractionType.Bed;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
|
@ -3,16 +3,75 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
public enum InteractionType {Bed,Sink,Fridge,Work}
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class DailyRoutineController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] HousingCanvasManager housingCanvasManager;
|
||||
[SerializeField] LayerMask furnitureLayerMask;
|
||||
|
||||
private Canvas _canvas;
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (furnitureLayerMask == (furnitureLayerMask | (1 << other.gameObject.layer)))
|
||||
{
|
||||
other.gameObject.GetComponent<DailyRoutine>().RoutineEnter();
|
||||
InteractionType interactionType = other.gameObject.GetComponent<DailyRoutine>().RoutineEnter();
|
||||
|
||||
switch (interactionType)
|
||||
{
|
||||
case InteractionType.Bed:
|
||||
housingCanvasManager.ShowInteractionButton("침대에서 잘까?","숙면으로 시간 당 체력 1을 회복한다.", () =>
|
||||
{
|
||||
//TODO: 숙면 할 때 할 일 작성
|
||||
Debug.Log("숙면 행동을 시작합니다");
|
||||
});
|
||||
break;
|
||||
case InteractionType.Sink:
|
||||
housingCanvasManager.ShowInteractionButton("밀린 집안일을 처리할까?","체력 1을 사용 좋은일이 일어날지도 모른다", () =>
|
||||
{
|
||||
//TODO: 집안일수행, 랜덤 강화 작성
|
||||
Debug.Log("집안일을 시작합니다");
|
||||
});
|
||||
break;
|
||||
case InteractionType.Fridge:
|
||||
housingCanvasManager.ShowInteractionButton("던전에 입장할까?","체력 3을 사용하고 3시간이 흐른다.", () =>
|
||||
{
|
||||
//TODO: 던전 입장
|
||||
Debug.Log("던전으로 이동 합니다.. 씬전환");
|
||||
});
|
||||
break;
|
||||
case InteractionType.Work:
|
||||
housingCanvasManager.ShowInteractionButton("출근한다.","체력 3을 소모하고 저녁 6시에나 돌아오겠지..", () =>
|
||||
{
|
||||
//TODO: 던전 입장
|
||||
Debug.Log("출근 후 컷씬 연출");
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit(Collision other)
|
||||
{
|
||||
if (furnitureLayerMask == (furnitureLayerMask | (1 << other.gameObject.layer)))
|
||||
{
|
||||
housingCanvasManager.HideInteractionButton();
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
SetCanvas();
|
||||
}
|
||||
|
||||
|
||||
void SetCanvas()
|
||||
{
|
||||
if (_canvas == null)
|
||||
{
|
||||
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,9 @@ using UnityEngine;
|
||||
|
||||
public class DailyRoutineFridge : DailyRoutine
|
||||
{
|
||||
public void RoutineEnter()
|
||||
public override InteractionType RoutineEnter()
|
||||
{
|
||||
base.RoutineEnter();
|
||||
Debug.Log("Its a Fridge");
|
||||
return InteractionType.Fridge;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
|
@ -4,10 +4,9 @@ using UnityEngine;
|
||||
|
||||
public class DailyRoutineSink : DailyRoutine
|
||||
{
|
||||
public void RoutineEnter()
|
||||
public override InteractionType RoutineEnter()
|
||||
{
|
||||
base.RoutineEnter();
|
||||
Debug.Log("Its a Sink");
|
||||
return InteractionType.Sink;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
|
15
Assets/LIN/DailyRoutine/DailyRoutineWork.cs
Normal file
15
Assets/LIN/DailyRoutine/DailyRoutineWork.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DailyRoutineWork : DailyRoutine
|
||||
{
|
||||
public override InteractionType RoutineEnter()
|
||||
{
|
||||
return InteractionType.Work;
|
||||
}
|
||||
|
||||
protected override void RoutineConfirm()
|
||||
{
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/DailyRoutineWork.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/DailyRoutineWork.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec766ebb2f69cb441af73a71172156f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -2,12 +2,10 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DailyRoutine:MonoBehaviour
|
||||
public abstract class DailyRoutine: MonoBehaviour
|
||||
{
|
||||
public void RoutineEnter()
|
||||
{
|
||||
//TODO: 플레이어 이동 방지, 팝업
|
||||
}
|
||||
public abstract InteractionType RoutineEnter();
|
||||
|
||||
|
||||
protected abstract void RoutineConfirm();
|
||||
}
|
57
Assets/LIN/HousingCanvasManager.cs
Normal file
57
Assets/LIN/HousingCanvasManager.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class HousingCanvasManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject interactionButton;
|
||||
[SerializeField] TMP_Text actionText;
|
||||
[SerializeField] TMP_Text descriptionText;
|
||||
|
||||
public Action OnInteractionButtonPressed;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
interactionButton.SetActive(false);
|
||||
}
|
||||
//사물 이름 세팅
|
||||
public void SetActionText(string text = "")
|
||||
{
|
||||
actionText.text = text;
|
||||
}
|
||||
//사물 상호작용 내용 설명
|
||||
public void SetDescriptionText(string text = "")
|
||||
{
|
||||
descriptionText.text = text;
|
||||
}
|
||||
|
||||
public void ShowInteractionButton(string actText, string descText,Action onInteractionButtonPressed)
|
||||
{
|
||||
SetActionText(actText);
|
||||
SetDescriptionText(descText);
|
||||
interactionButton.SetActive(true);
|
||||
|
||||
//각 행동 별로 실행되어야 할 이벤트 구독
|
||||
OnInteractionButtonPressed = onInteractionButtonPressed;
|
||||
}
|
||||
|
||||
public void HideInteractionButton()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
interactionButton.SetActive(false);
|
||||
|
||||
//구독해놓은 이벤트 해제
|
||||
OnInteractionButtonPressed = null;
|
||||
}
|
||||
|
||||
public void OnClickInteractionButton()
|
||||
{
|
||||
OnInteractionButtonPressed?.Invoke();
|
||||
}
|
||||
}
|
11
Assets/LIN/HousingCanvasManager.cs.meta
Normal file
11
Assets/LIN/HousingCanvasManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d899866e8f8b8a045aafba015e947a90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/LIN/Prefabs.meta
Normal file
8
Assets/LIN/Prefabs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da379c2d2ad76c144aae8b3eff50d355
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/LIN/Prefabs/HousingMainUIPanel_Copy.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/LIN/Prefabs/HousingMainUIPanel_Copy.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
7
Assets/LIN/Prefabs/HousingMainUIPanel_Copy.prefab.meta
Normal file
7
Assets/LIN/Prefabs/HousingMainUIPanel_Copy.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b14d6aa88de82f449e47d835ebf73c7
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user