Merge pull request #8 from Degulleo/DEG-75-일상-활동별-함수-작성
사물 상호작용 구현, 플레이어 스탯과 연동
This commit is contained in:
commit
5582fa7ab4
@ -36,14 +36,7 @@ public class PlayerStats : MonoBehaviour
|
||||
{
|
||||
ActionEffect effect = _valueByAction.GetActionEffect(actionType);
|
||||
|
||||
if (HealthStat >= effect.healthChange)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (HealthStat >= (effect.healthChange * -1));
|
||||
}
|
||||
|
||||
// 행동 처리 메서드
|
||||
|
8
Assets/LIN.meta
Normal file
8
Assets/LIN.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f8deeb0bf097f645aaa23fd62feca52
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/LIN/DailyRoutine.meta
Normal file
8
Assets/LIN/DailyRoutine.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f483f83ac9776d34c9bbbc1b84f32c27
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
100
Assets/LIN/DailyRoutine/InteractionController.cs
Normal file
100
Assets/LIN/DailyRoutine/InteractionController.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class InteractionController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] PlayerStats playerStats;
|
||||
[SerializeField] LayerMask interactionLayerMask;
|
||||
[FormerlySerializedAs("housingCanvasManager")]
|
||||
[Header("UI 연동")]
|
||||
[SerializeField] HousingCanvasController housingCanvasController;
|
||||
|
||||
// 상호작용 가능한 사물 범위에 들어올 때
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer)))
|
||||
{
|
||||
ActionType interactionType = other.gameObject.GetComponent<InteractionProp>().RoutineEnter();
|
||||
if( interactionType != null )
|
||||
{
|
||||
PopActionOnScreen(interactionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 사물에서 벗어날 때 UI 정리
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (interactionLayerMask == (interactionLayerMask | (1 << other.gameObject.layer)))
|
||||
{
|
||||
housingCanvasController.HideInteractionButton();
|
||||
}
|
||||
}
|
||||
|
||||
// ActionType 별로 화면에 상호작용 내용 표시, 상호작용 버튼에 이벤트 작성
|
||||
private void PopActionOnScreen(ActionType interactionType)
|
||||
{
|
||||
switch (interactionType)
|
||||
{
|
||||
case ActionType.Sleep:
|
||||
housingCanvasController.ShowInteractionButton("침대에서 잘까?","숙면으로 시간 당 체력 1을 회복한다.", () =>
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Sleep);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
//TODO: 화면 전환 효과와 UI 업데이트 작업
|
||||
});
|
||||
break;
|
||||
case ActionType.Housework:
|
||||
housingCanvasController.ShowInteractionButton("밀린 집안일을 처리할까?","체력 1을 사용하고 좋은일이 일어날지도 모른다", () =>
|
||||
{
|
||||
if (playerStats.CanPerformByHealth(ActionType.Housework))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Housework);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
//TODO: 집안일 후 랜덤 강화 효과 적용
|
||||
}
|
||||
else
|
||||
{
|
||||
housingCanvasController.SetActionText("힘들어서 못해..");
|
||||
housingCanvasController.SetDescriptionText();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ActionType.Dungeon:
|
||||
housingCanvasController.ShowInteractionButton("던전에 입장할까?","체력 3을 사용하고 3시간이 흐른다.", () =>
|
||||
{
|
||||
if (playerStats.CanPerformByHealth(ActionType.Dungeon))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Dungeon);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
housingCanvasController.SetActionText("던전에 갈 체력이 되지 않아..");
|
||||
housingCanvasController.SetDescriptionText();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ActionType.Work:
|
||||
housingCanvasController.ShowInteractionButton("출근한다.","체력 3을 사용하고 저녁 6시에나 돌아오겠지..", () =>
|
||||
{
|
||||
if (playerStats.CanPerformByHealth(ActionType.Work))
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Work);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
housingCanvasController.SetActionText("도저히 출근할 체력이 안되는걸..?");
|
||||
housingCanvasController.SetDescriptionText();
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/InteractionController.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/InteractionController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4ff6298b8d45e44493da75e053196c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
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();
|
||||
}
|
3
Assets/LIN/DailyRoutine/InteractionProp.cs.meta
Normal file
3
Assets/LIN/DailyRoutine/InteractionProp.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb3b1f8a97cd4befaf14a41276d31292
|
||||
timeCreated: 1744822822
|
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;
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/InteractionPropBed.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropBed.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61f97dc6faa89de409ce2414a02c4f40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/LIN/DailyRoutine/InteractionPropFridge.cs
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropFridge.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InteractionPropFridge : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Dungeon;
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/InteractionPropFridge.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropFridge.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c8e3fe029f4fca43a82d71cd49837ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/LIN/DailyRoutine/InteractionPropSink.cs
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropSink.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InteractionPropSink : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Housework;
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/InteractionPropSink.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropSink.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61d920882ed2121428f4e61450f51ef1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/LIN/DailyRoutine/InteractionPropWork.cs
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropWork.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InteractionPropWork : InteractionProp
|
||||
{
|
||||
public override ActionType RoutineEnter()
|
||||
{
|
||||
return ActionType.Work;
|
||||
}
|
||||
}
|
11
Assets/LIN/DailyRoutine/InteractionPropWork.cs.meta
Normal file
11
Assets/LIN/DailyRoutine/InteractionPropWork.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:
|
BIN
Assets/LIN/Housing Copy.unity
(Stored with Git LFS)
Normal file
BIN
Assets/LIN/Housing Copy.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
7
Assets/LIN/Housing Copy.unity.meta
Normal file
7
Assets/LIN/Housing Copy.unity.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86c6ebc5f9b48c345bd9d6f402bdc848
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
Assets/LIN/HousingCanvasController.cs
Normal file
66
Assets/LIN/HousingCanvasController.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class HousingCanvasController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject interactionButton;
|
||||
[SerializeField] TMP_Text actionText;
|
||||
[SerializeField] TMP_Text descriptionText;
|
||||
|
||||
public Action OnInteractionButtonPressed;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
InitTexts();
|
||||
interactionButton.SetActive(false);
|
||||
}
|
||||
|
||||
//사물 이름 세팅
|
||||
public void SetActionText(string text = "")
|
||||
{
|
||||
actionText.text = text;
|
||||
}
|
||||
//사물 상호작용 내용 설명
|
||||
public void SetDescriptionText(string text = "")
|
||||
{
|
||||
descriptionText.text = text;
|
||||
}
|
||||
|
||||
private void InitTexts()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
}
|
||||
|
||||
// 상호작용 가능한 사물에 가까이 갔을 때 화면에 텍스트, 버튼 표시
|
||||
public void ShowInteractionButton(string actText, string descText,Action onInteractionButtonPressed)
|
||||
{
|
||||
SetActionText(actText);
|
||||
SetDescriptionText(descText);
|
||||
interactionButton.SetActive(true);
|
||||
|
||||
//각 행동 별로 실행되어야 할 이벤트 구독
|
||||
OnInteractionButtonPressed = onInteractionButtonPressed;
|
||||
}
|
||||
|
||||
//범위에서 벗어나면 상호작용 버튼 off
|
||||
public void HideInteractionButton()
|
||||
{
|
||||
SetActionText();
|
||||
SetDescriptionText();
|
||||
interactionButton.SetActive(false);
|
||||
|
||||
//구독해놓은 이벤트 해제
|
||||
OnInteractionButtonPressed = null;
|
||||
}
|
||||
|
||||
//상호작용 버튼 눌렀을 때
|
||||
public void OnClickInteractionButton()
|
||||
{
|
||||
OnInteractionButtonPressed?.Invoke();
|
||||
}
|
||||
}
|
11
Assets/LIN/HousingCanvasController.cs.meta
Normal file
11
Assets/LIN/HousingCanvasController.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/Canvas.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/LIN/Prefabs/Canvas.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
7
Assets/LIN/Prefabs/Canvas.prefab.meta
Normal file
7
Assets/LIN/Prefabs/Canvas.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5664f5a156d8a0449b8b9a6deebd122
|
||||
PrefabImporter:
|
||||
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:
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,12 +3,13 @@
|
||||
--- !u!78 &1
|
||||
TagManager:
|
||||
serializedVersion: 2
|
||||
tags: []
|
||||
tags:
|
||||
- FxTemporaire
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
- Ignore Raycast
|
||||
-
|
||||
- Interaction
|
||||
- Water
|
||||
- UI
|
||||
-
|
||||
|
Loading…
x
Reference in New Issue
Block a user