[Feat] 출근 후 랜덤 이벤트 발생
This commit is contained in:
parent
1b43e105c2
commit
65b49145eb
@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
[RequireComponent(typeof(Rigidbody))]
|
||||
public class InteractionController : MonoBehaviour
|
||||
@ -16,24 +15,7 @@ public class InteractionController : MonoBehaviour
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
private SuddenEventController _suddenEventController = new SuddenEventController();
|
||||
|
||||
#endregion
|
||||
|
||||
@ -110,7 +92,13 @@ public class InteractionController : MonoBehaviour
|
||||
{
|
||||
playerStats.PerformAction(ActionType.Work);
|
||||
housingCanvasController.HideInteractionButton();
|
||||
playerStats.OnWorked += SuddenEventHappen();
|
||||
// playerStats.OnWorked += SuddenEventHappen();
|
||||
|
||||
//돌발 이벤트 랜덤 발생
|
||||
AfterWorkEvent afterWorkEvent = _suddenEventController.SuddenEventCalculator();
|
||||
if (afterWorkEvent == AfterWorkEvent.None)
|
||||
return;
|
||||
|
||||
}
|
||||
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.
14
Assets/LIN/HousingConstants.cs
Normal file
14
Assets/LIN/HousingConstants.cs
Normal file
@ -0,0 +1,14 @@
|
||||
//퇴근 후 발생할 수 있는 돌발 이벤트
|
||||
public enum AfterWorkEvent
|
||||
{
|
||||
None,
|
||||
TeamGathering,
|
||||
OvertimeWork
|
||||
}
|
||||
|
||||
public static class HousingConstants
|
||||
{
|
||||
//돌발 이벤트 확률 계산
|
||||
public static int SUDDEN_EVENT_DENOMINATOR = 5;
|
||||
public static int AFTER_WORK_DENOMINATOR = 4;
|
||||
}
|
3
Assets/LIN/HousingConstants.cs.meta
Normal file
3
Assets/LIN/HousingConstants.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0ce52df52334b1eaf37479fdda66f7a
|
||||
timeCreated: 1745303266
|
25
Assets/LIN/SuddenEventController.cs
Normal file
25
Assets/LIN/SuddenEventController.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class SuddenEventController
|
||||
{
|
||||
// 랜덤 값에 일치하는 함수를 리턴하기 위한 딕셔너리
|
||||
// AFTER_WORK_DENOMINATOR 값 확정 후에 키 값 수정 가능
|
||||
private Dictionary<int, AfterWorkEvent> afterWorkEvents = new Dictionary<int, AfterWorkEvent>();
|
||||
public SuddenEventController()
|
||||
{
|
||||
afterWorkEvents.Add(0, AfterWorkEvent.OvertimeWork);
|
||||
afterWorkEvents.Add(1, AfterWorkEvent.TeamGathering);
|
||||
}
|
||||
|
||||
//퇴근 후 돌발 이벤트
|
||||
public AfterWorkEvent SuddenEventCalculator()
|
||||
{
|
||||
var index = Random.Range(0,HousingConstants.AFTER_WORK_DENOMINATOR);
|
||||
Debug.Log(index);
|
||||
return afterWorkEvents.GetValueOrDefault(index, AfterWorkEvent.None);
|
||||
}
|
||||
|
||||
}
|
3
Assets/LIN/SuddenEventController.cs.meta
Normal file
3
Assets/LIN/SuddenEventController.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26ce8577425c4630903173b182839514
|
||||
timeCreated: 1745306651
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user