少年修仙传客户端代码仓库
client_Wu Xijin
2018-10-26 82931aabaaa3e479bc04e11630a77cd9c9dd5fe3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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);
        }
    }
}