少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, September 06, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System;
 
namespace vnxbqy.UI
{
 
    public class WorldMapAreaBehaviour : MonoBehaviour
    {
        [SerializeField] GameObject m_Conainter;
        public GameObject container {
            get { return m_Conainter; }
        }
 
        [SerializeField] BoundedDrag m_BoundedDrag;
        [SerializeField] PointerDownUp m_MapButton;
        [SerializeField] ScaleTween m_ScaleTween;
        [SerializeField] Image m_MapBackGround;
        [SerializeField] Text m_AreaName;
        [SerializeField] Text m_AreaLevel;
        [SerializeField] Text m_AreaCamp;
        [SerializeField] Transform m_Locked;
        [SerializeField] Transform m_PlayerHead;
        [SerializeField] MaterialsContainer m_Materials;
        [SerializeField] PressTip m_PressTip;
        [SerializeField] WorldMapUnLockTip m_UnLockTip;
        [SerializeField] Transform m_NewUnLockArrowPoint;
        [SerializeField] RectTransform m_NewUnLockTip;
 
        public Transform newUnLockArrowPoint {
            get { return m_NewUnLockArrowPoint; }
        }
 
        public Transform playerHead { get { return m_PlayerHead; } }
 
        WorldMapArea m_MapArea;
        float downTime = 0f;
 
        MapAssetDownLoadProgress mapAssetDownLoadProgress;
        MapModel model { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
 
        private void Awake()
        {
            m_MapButton.AddPointerDownListener(OnPointerDown);
            m_MapButton.AddPointerUpListener(OnPointerUp);
            m_MapButton.AddPointerClickListener(OnPointerClick);
        }
 
        public void Init(WorldMapArea _area)
        {
            m_MapArea = _area;
            m_ScaleTween.SetStartState();
            DrawArea();
            m_PressTip.enabled = !model.IsMapUnlocked(m_MapArea.id);
 
            if (m_NewUnLockTip != null)
            {
                m_NewUnLockTip.SetActive(m_MapArea.id != model.newUnlockedMap && model.newUnlockMapTip == m_MapArea.id);
            }
 
            CheckAchievementGuide();
        }
 
        public void SetMaterial(string _materialName)
        {
            m_MapBackGround.material = m_Materials.GetMaterial(_materialName);
        }
 
        public void BeginUnLockShow()
        {
            StartCoroutine("Co_UnLockShow");
        }
 
        private void DrawArea()
        {
            try
            {
                var unLocked = model.IsMapUnlocked(m_MapArea.id);
                var mapConfig = MapConfig.Get(m_MapArea.id);
                m_AreaName.text = mapConfig.Name;
                m_AreaLevel.text = mapConfig.LV.ToString();
                m_Locked.SetActive(!unLocked);
                m_MapBackGround.material = unLocked ? m_Materials.GetMaterial("Normal") : m_Materials.GetMaterial("Gray");
            }
            catch (Exception ex)
            {
                DebugEx.Log(ex);
            }
        }
 
        private void OnDisable()
        {
            if (mapAssetDownLoadProgress != null)
            {
                mapAssetDownLoadProgress.OnComplete(null);
                InGameDownLoad.Instance.RegisterMapAssetDownLoadOk(this.m_MapArea.id, () =>
                {
                    var config = MapConfig.Get(this.m_MapArea.id);
                    ConfirmCancel.ShowPopConfirm(
                        Language.Get("Mail101"),
                        Language.Get("LoadMap1", config.Name),
                        () => { model.RequestMapTransport(this.m_MapArea.id); }
                        );
                });
            }
 
            StopAllCoroutines();
        }
 
        private void OnPointerDown()
        {
            m_ScaleTween.Play(false);
            downTime = Time.time;
            var mapId = m_MapArea.id;
            if (!model.IsMapUnlocked(mapId))
            {
                m_UnLockTip.Display(mapId);
            }
        }
 
        private void OnPointerUp()
        {
            m_ScaleTween.Play(true);
        }
 
        private void OnPointerClick()
        {
            var isUnLocked = model.IsMapUnlocked(m_MapArea.id);
            if (isUnLocked || Time.time - downTime < 0.3f)
            {
                if (isUnLocked)
                {
                    if (m_MapArea.id == PlayerDatas.Instance.baseData.MapID)
                    {
                        SysNotifyMgr.Instance.ShowTip("NowWorldMap");
                    }
                    else
                    {
                        if (PlayerDatas.Instance.hero != null)
                        {
                            PlayerDatas.Instance.hero.StopAll();
                        }
 
                        MapTransferUtility.Instance.Clear();
 
                        var assetDownLoadProgress = InGameDownLoad.Instance.GetMapAssetDownLoadProgress(m_MapArea.id);
                        if (assetDownLoadProgress < 1f)
                        {
                            if (mapAssetDownLoadProgress == null)
                            {
                                var behaviour = UIUtility.CreateWidget("MapAssetDownLoadProgress", "MapAssetDownLoadProgress");
                                mapAssetDownLoadProgress = behaviour.GetComponent<MapAssetDownLoadProgress>();
                                behaviour.transform.SetParentEx(m_Conainter.transform, Vector3.zero, Vector3.zero, Vector3.one);
                            }
 
                            InGameDownLoad.Instance.UnRegisterMapAssetDownLoadOk();
                            mapAssetDownLoadProgress.mapId = m_MapArea.id;
                            mapAssetDownLoadProgress.OnComplete(() =>
                            {
                                model.RequestMapTransport(m_MapArea.id);
                            });
 
                            if (InGameDownLoad.Instance.state == InGameDownLoad.State.DownLoad)
                            {
                                SysNotifyMgr.Instance.ShowTip("MapAssetDowning");
                            }
                            else
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                            }
                        }
                        else
                        {
                            model.RequestMapTransport(m_MapArea.id);
                        }
                    }
                }
            }
        }
 
        IEnumerator Co_UnLockShow()
        {
            m_MapBackGround.material = m_Materials.GetMaterial("Lerp");
            var timer = 0f;
            while (timer < 1f)
            {
                timer += Time.deltaTime;
                var t = Mathf.Clamp01(timer);
                m_MapBackGround.material.SetFloat("_GrayScale", t);
                yield return null;
            }
 
            m_MapBackGround.material = m_Materials.GetMaterial("Normal");
        }
 
        private void CheckAchievementGuide()
        {
            if (AchievementGoto.guideAchievementId != 0)
            {
                var config = SuccessConfig.Get(AchievementGoto.guideAchievementId);
                if (config.Type == 37 && config.Condition[0] == m_MapArea.id)
                {
                    var guideEffect = AchievementGuideEffectPool.Require(4);
                    guideEffect.transform.SetParentEx(m_MapButton.transform, Vector3.zero, Vector3.zero, Vector3.one);
                }
            }
        }
 
    }
 
}