using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class FairyFeastBehaviour : MonoBehaviour
|
{
|
[SerializeField] Button m_GotoFeast;
|
|
bool nearNpc = false;
|
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
FairyModel model { get { return ModelCenter.Instance.GetModel<FairyModel>(); } }
|
|
FairyFeastModel fairyFeastModel { get { return ModelCenter.Instance.GetModel<FairyFeastModel>(); } }
|
|
private void Awake()
|
{
|
m_GotoFeast.onClick.AddListener(OnGotoFeast);
|
}
|
|
public void Init()
|
{
|
nearNpc = false;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
dungeonModel.updateMissionEvent += UpdateMissionEvent;
|
GA_NpcCollect.OnArrive += OnArriveCollectNPC;
|
GA_NpcCollect.OnLeave += OnLeaveCollectNpc;
|
fairyFeastModel.selectTransmit += SelectTransmit;
|
Display();
|
}
|
|
public void UnInit()
|
{
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
|
dungeonModel.updateMissionEvent -= UpdateMissionEvent;
|
GA_NpcCollect.OnArrive -= OnArriveCollectNPC;
|
GA_NpcCollect.OnLeave -= OnLeaveCollectNpc;
|
fairyFeastModel.selectTransmit -= SelectTransmit;
|
}
|
|
private void SelectTransmit()
|
{
|
Display();
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
{
|
if (refreshType == PlayerDataRefresh.MapID)
|
{
|
Display();
|
}
|
}
|
|
private void UpdateMissionEvent()
|
{
|
var mapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
if (mapId == 31230)
|
{
|
Display();
|
}
|
}
|
|
private void Display()
|
{
|
var mapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
var collected = dungeonModel.mission.hasCollect;
|
m_GotoFeast.gameObject.SetActive(mapId == 31230 && collected != 1 && !nearNpc && !fairyFeastModel.allowTransmit);
|
}
|
|
private void OnArriveCollectNPC(uint arg0, int _npcId)
|
{
|
if (_npcId == model.fairyFeastDeskNpc)
|
{
|
nearNpc = true;
|
Display();
|
}
|
}
|
|
private void OnLeaveCollectNpc(uint arg0, int _npcId)
|
{
|
if (_npcId == model.fairyFeastDeskNpc)
|
{
|
nearNpc = false;
|
Display();
|
}
|
}
|
|
private void OnGotoFeast()
|
{
|
var mapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
if (mapId == 31230)
|
{
|
SnxxzGame.Instance.StartCoroutine(Co_HeroMoveToActor(model.fairyFeastDeskNpc));
|
}
|
}
|
|
IEnumerator Co_HeroMoveToActor(int _npcId)
|
{
|
var _hero = PlayerDatas.Instance.hero;
|
while (_hero.SkillMgr.CurCastSkill != null &&
|
_hero.SkillMgr.CurCastSkill.SkillCompelete == false)
|
{
|
yield return null;
|
}
|
MapTransferUtility.Instance.MoveToNPC(_npcId);
|
}
|
}
|
}
|