少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
提交 | 用户 | age
126362 1 //--------------------------------------------------------
CX 2 //    [Author]:           第二世界
3 //    [  Date ]:           Tuesday, March 05, 2019
4 //--------------------------------------------------------
5 using System.Collections;
dbdbd5 6 using System.Collections.Generic;
126362 7 using UnityEngine;
CX 8 using UnityEngine.UI;
9
4465b6 10 namespace vnxbqy.UI
dbdbd5 11 {
CX 12     public class EquipStarLevelSelectBehaviour : MonoBehaviour
13     {
126362 14         [SerializeField] Button m_Select;
3d86df 15         [SerializeField] Image m_SelectImg;
dbdbd5 16         [SerializeField] Text m_Title;
a72128 17         [SerializeField] RedpointBehaviour m_Redpoint;
dbdbd5 18
2e37be 19         readonly List<EquipStarUpgradeCandidateSlot> slotBehaviours = new List<EquipStarUpgradeCandidateSlot>();
dbdbd5 20
CX 21         EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
22         EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
23
24         public int level { get; private set; }
25         public void Init(int level)
26         {
a72128 27             this.level = level;
CX 28             this.m_Redpoint.redpointId = 1720000 + this.level * 100;
29
2e37be 30             var equipSet = equipModel.GetEquipSet(level);
CX 31             var realmConfig = RealmConfig.Get(equipSet.realm);
3d86df 32             this.m_Title.text = realmConfig.Name;
2e37be 33
dbdbd5 34             m_Select.SetListener(Select);
CX 35         }
36
37         public void UnInit()
38         {
39             Dispose();
2e37be 40
dbdbd5 41             this.level = 0;
CX 42             this.m_Select.RemoveAllListeners();
43         }
44
45         public void Display()
46         {
ace1a4 47             var candidates = this.model.candidatePlaces.Fetch();
CX 48             for (var i = candidates.Count - 1; i >= 0; i--)
dbdbd5 49             {
CX 50                 var behaviour = EquipStarUpgradeCandidateSlotPool.Get();
ace1a4 51                 behaviour.Display(candidates[i]);
3d86df 52                 behaviour.transform.SetParentEx(this.transform.parent.parent.Find("Container_Candidate/ContentEquip"), Vector3.zero, Quaternion.identity, Vector3.one);
H 53                 behaviour.transform.SetSiblingIndex(0);
dbdbd5 54                 slotBehaviours.Add(behaviour);
CX 55             }
3d86df 56             m_SelectImg.SetActive(true);
H 57             this.m_Title.color = new Color32(255, 255, 255, 255);//"#ffffff";
dbdbd5 58         }
CX 59
60         public void Dispose()
61         {
62             for (var i = slotBehaviours.Count - 1; i >= 0; i--)
63             {
64                 EquipStarUpgradeCandidateSlotPool.Release(slotBehaviours[i]);
65             }
66
67             slotBehaviours.Clear();
3d86df 68             m_SelectImg.SetActive(false);
H 69             this.m_Title.color = new Color32(198, 181, 149, 255); //c6b595
dbdbd5 70         }
CX 71
72         private void Select()
73         {
3d6ff7 74             if (model.selectedLevel.value == this.level)
0f12ec 75             {
3d86df 76
0f12ec 77             }
CX 78             else
79             {
80                 model.SelectLevel(this.level);
d0b3f7 81
H 82                 var equipPosition = model.GetRecommendEquipPosition();
83                 if (this.level == equipPosition.x)
84                     model.SelectPlace(equipPosition);
0f12ec 85             }
dbdbd5 86         }
CX 87
126362 88     }
CX 89
90
91 }