[Feat] 돌발 이벤트 함수 작성중
This commit is contained in:
parent
7e256010d5
commit
1b43e105c2
@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class InteractionController : MonoBehaviour
|
||||
@ -12,6 +13,30 @@ public class InteractionController : MonoBehaviour
|
||||
[FormerlySerializedAs("housingCanvasManager")]
|
||||
[Header("UI 연동")]
|
||||
[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)
|
||||
@ -85,6 +110,7 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Work);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
playerStats.OnWorked += SuddenEventHappen();
|
||||
}
|
||||
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.
@ -9,9 +9,13 @@ public class HousingCanvasController : MonoBehaviour
|
||||
[SerializeField] GameObject interactionButton;
|
||||
[SerializeField] TMP_Text actionText;
|
||||
[SerializeField] TMP_Text descriptionText;
|
||||
|
||||
[Header("돌발 이벤트")]
|
||||
[SerializeField] private GameObject suddenPanel;
|
||||
[SerializeField] private TMP_Text suddenText;
|
||||
|
||||
public Action OnInteractionButtonPressed;
|
||||
|
||||
public Action OnSuddenButtonPressed;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -46,7 +50,24 @@ public class HousingCanvasController : MonoBehaviour
|
||||
//각 행동 별로 실행되어야 할 이벤트 구독
|
||||
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
|
||||
public void HideInteractionButton()
|
||||
{
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user