Repository navigation
UIEventIcon
김광수 edited this page Oct 11, 2023
·
1 revision
UIButton을 상속받은 UIEventIcon 클래스 입니다.
EventIcon을 눌렀을때 EventType에 따라서 UIEventWindow를 업데이트 합니다.
-
info
- LocationInfo를 저장
-
eventInfoSO
- EventInfoSo를 저장
-
Check
- 선택시 활성화 될 오브젝트
-
Awake()
- event Onclick에 CheckIndex() 메서드를 연걸
-
CheckIndex()
- UIEventIcon이 현재 갈수있는지 없는지를 판단
- 갈 수 있다면 EnterEvent()메서드를 호출
-
EnterEvent()
- UIEventWindow를 열고 Init()메서드로 초기화한다
using UnityEngine;
public class UIEventIcon : UIButton
{
public LocationInfo info;
public EventInfoSO eventInfoSO;
public GameObject Check;
private void Awake()
{
OnClick += CheckIndex;
}
public void CheckIndex()
{
LocationInfo currentInfo = GameManager.Instance.CurrentLocationInfo;
if (currentInfo == null)
{
if (info.Floor == 0)
{
EnterEvent();
}
}
else if (currentInfo.Floor + 1 == info.Floor)
{
int difference = currentInfo.Index - info.Index;
difference = difference > 0 ? difference : -difference;
if(difference < 2)
{
EnterEvent();
}
}
}
public void EnterEvent()
{
GameManager.Instance.CurrentLocationInfo = info;
GameObject go = UIManager.Instance.OpenUI(UIName.UIEventWindow);
Check.SetActive(true);
go.GetComponent<UIEventWindow>().Init(eventInfoSO);
}
}