少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, September 06, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using Snxxz.UI;
 
namespace Snxxz.UI
{
 
    public class LocalMapEventPointToggle : ScrollItem
    {
        [SerializeField] RectTransform m_LayoutLeft;
        [SerializeField] ButtonEx m_Button;
        [SerializeField] TextEx m_Title;
        [SerializeField] Text m_Description;
        [SerializeField] Transform m_Selected;
        [SerializeField] Button m_FlyBoot;
        [SerializeField] Image m_MonsterType;
        [SerializeField] FontColorSizeConfig m_FontColor;
 
        int m_EventId;
 
        MapModel model { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        public override void Display(object _data)
        {
            base.Display(_data);
 
            m_EventId = (int)_data;
            var mapConfig = MapConfig.Get(PlayerDatas.Instance.baseData.MapID);
            m_LayoutLeft.gameObject.SetActive(mapConfig.MapFBType == (int)MapType.OpenCountry);
 
            DisplayEventInfo();
            OnSelected(model.selectedMapEventPoint);
            model.selectMapEventPointEvent += OnSelected;
        }
 
        public override void Dispose()
        {
            base.Dispose();
            model.selectMapEventPointEvent -= OnSelected;
        }
 
        private void Awake()
        {
            this.m_Button.SetListener(SelectEventPoint);
            this.m_FlyBoot.SetListener(FlyToEventPoint);
        }
 
        private void DisplayEventInfo()
        {
            var config = MapEventPointConfig.Get(this.m_EventId);
            var npcConfig = NPCConfig.Get(config.NPCID);
            this.m_Title.text = npcConfig != null ? npcConfig.charName : "";
 
            if (npcConfig.NPCType == 0)
            {
                this.m_Description.text = config.NpcDescription;
                this.m_MonsterType.gameObject.SetActive(true);
            }
            else
            {
                if (config.LowLV == config.HighestLV)
                {
                    this.m_Description.text = Language.Get("Z1024", config.LowLV);
                }
                else
                {
                    this.m_Description.text = StringUtility.Contact(Language.Get("Z1024", config.LowLV), "-", config.HighestLV);
                }
 
                this.m_MonsterType.gameObject.SetActive(false);
                this.m_MonsterType.SetSprite(StringUtility.Contact("MapNPC_Colour_", config.Colour));
            }
 
        }
 
        private void FlyToEventPoint()
        {
            var free = ModelCenter.Instance.GetModel<VipModel>().GetVipPrivilegeCnt(VipPrivilegeType.FreeTransfer) > 0;
            if (free)
            {
                MoveToNpc();
                return;
            }
 
            var hasFlyBoot = playerPack.GetItemCountByID(PackType.Item, GeneralDefine.flyBootItemId) > 0;
            if (hasFlyBoot)
            {
                MoveToNpc();
                return;
            }
 
            FlyShoseConfirmwin.useEnvironment = FlyShoseConfirmwin.UseEnvironment.LocalMap;
            FlyShoseConfirmwin.confirmCallBack = MoveToNpc;
            WindowCenter.Instance.Open<FlyShoseConfirmwin>();
        }
 
        private void MoveToNpc()
        {
            var config = MapEventPointConfig.Get(m_EventId);
            MapTransferUtility.Instance.MissionFlyTo(PlayerDatas.Instance.baseData.MapID, config.NPCID);
 
            WindowCenter.Instance.Close<WorldMapWin>();
            WindowCenter.Instance.Close<LocalMapWin>();
            WindowCenter.Instance.Open<MainInterfaceWin>();
        }
 
        private void SelectEventPoint()
        {
            model.selectedMapEventPoint = m_EventId;
        }
 
        private void OnSelected(int _event)
        {
            var selected = _event == m_EventId;
            m_Selected.gameObject.SetActive(selected);
            this.m_Title.color = this.m_Description.color = m_FontColor.GetColorSize(selected ? "Selected" : "Normal").color;
        }
 
    }
 
}