[Feat] 돌발 이벤트 함수 작성중
This commit is contained in:
parent
7e256010d5
commit
1b43e105c2
@ -3,6 +3,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
[RequireComponent(typeof(Rigidbody))]
|
[RequireComponent(typeof(Rigidbody))]
|
||||||
public class InteractionController : MonoBehaviour
|
public class InteractionController : MonoBehaviour
|
||||||
@ -13,6 +14,30 @@ public class InteractionController : MonoBehaviour
|
|||||||
[Header("UI 연동")]
|
[Header("UI 연동")]
|
||||||
[SerializeField] HousingCanvasController housingCanvasController;
|
[SerializeField] HousingCanvasController housingCanvasController;
|
||||||
|
|
||||||
|
|
||||||
|
#region 돌발 이벤트
|
||||||
|
private bool SuddenEventCalculator()
|
||||||
|
{
|
||||||
|
//TODO: 돌발이벤트 Dictionary로 작성해서 숫자별 작동하기 혹은 스위치문
|
||||||
|
var rand = Random.Range(0,3);
|
||||||
|
return rand == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action SuddenEventHappen()
|
||||||
|
{
|
||||||
|
if (SuddenEventCalculator())
|
||||||
|
{
|
||||||
|
housingCanvasController.ShowSuddenEventPanel("갑자기 팀 회식이 잡혔다. 참석 해야 겠지?", () => { });
|
||||||
|
Debug.Log("SuddenEventHappen");
|
||||||
|
}
|
||||||
|
Debug.Log("퇴근 이벤트 호출됨");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
// 상호작용 가능한 사물 범위에 들어올 때
|
// 상호작용 가능한 사물 범위에 들어올 때
|
||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
@ -85,6 +110,7 @@ public class InteractionController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
playerStats.PerformAction(ActionType.Work);
|
playerStats.PerformAction(ActionType.Work);
|
||||||
housingCanvasController.HideInteractionButton();
|
housingCanvasController.HideInteractionButton();
|
||||||
|
playerStats.OnWorked += SuddenEventHappen();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
BIN
Assets/LIN/Housing Copy.unity
(Stored with Git LFS)
BIN
Assets/LIN/Housing Copy.unity
(Stored with Git LFS)
Binary file not shown.
@ -10,8 +10,12 @@ public class HousingCanvasController : MonoBehaviour
|
|||||||
[SerializeField] TMP_Text actionText;
|
[SerializeField] TMP_Text actionText;
|
||||||
[SerializeField] TMP_Text descriptionText;
|
[SerializeField] TMP_Text descriptionText;
|
||||||
|
|
||||||
public Action OnInteractionButtonPressed;
|
[Header("돌발 이벤트")]
|
||||||
|
[SerializeField] private GameObject suddenPanel;
|
||||||
|
[SerializeField] private TMP_Text suddenText;
|
||||||
|
|
||||||
|
public Action OnInteractionButtonPressed;
|
||||||
|
public Action OnSuddenButtonPressed;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
@ -47,6 +51,23 @@ public class HousingCanvasController : MonoBehaviour
|
|||||||
OnInteractionButtonPressed = onInteractionButtonPressed;
|
OnInteractionButtonPressed = onInteractionButtonPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowSuddenEventPanel(string actText, Action onSuddenButtonPressed)
|
||||||
|
{
|
||||||
|
suddenPanel.SetActive(true);
|
||||||
|
suddenText.text = actText;
|
||||||
|
OnSuddenButtonPressed += onSuddenButtonPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HideSuddenEventPanel()
|
||||||
|
{
|
||||||
|
suddenPanel.SetActive(false);
|
||||||
|
suddenText.text = "";
|
||||||
|
OnSuddenButtonPressed -= OnSuddenButtonPressed;
|
||||||
|
}
|
||||||
|
public void OnSuddenConfirmButton()
|
||||||
|
{
|
||||||
|
OnSuddenButtonPressed?.Invoke();
|
||||||
|
}
|
||||||
//범위에서 벗어나면 상호작용 버튼 off
|
//범위에서 벗어나면 상호작용 버튼 off
|
||||||
public void HideInteractionButton()
|
public void HideInteractionButton()
|
||||||
{
|
{
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user