少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, March 05, 2019
//--------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class EquipStarLevelSelectBehaviour : MonoBehaviour
    {
        [SerializeField] Button m_Select;
        [SerializeField] Image m_SelectImg;
        [SerializeField] Text m_Title;
        [SerializeField] RedpointBehaviour m_Redpoint;
 
        readonly List<EquipStarUpgradeCandidateSlot> slotBehaviours = new List<EquipStarUpgradeCandidateSlot>();
 
        EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
 
        public int level { get; private set; }
        public void Init(int level)
        {
            this.level = level;
            this.m_Redpoint.redpointId = 1720000 + this.level * 100;
 
            var equipSet = equipModel.GetEquipSet(level);
            var realmConfig = RealmConfig.Get(equipSet.realm);
            this.m_Title.text = realmConfig.Name;
 
            m_Select.SetListener(Select);
        }
 
        public void UnInit()
        {
            Dispose();
 
            this.level = 0;
            this.m_Select.RemoveAllListeners();
        }
 
        public void Display()
        {
            var candidates = this.model.candidatePlaces.Fetch();
            for (var i = candidates.Count - 1; i >= 0; i--)
            {
                var behaviour = EquipStarUpgradeCandidateSlotPool.Get();
                behaviour.Display(candidates[i]);
                behaviour.transform.SetParentEx(this.transform.parent.parent.Find("Container_Candidate/ContentEquip"), Vector3.zero, Quaternion.identity, Vector3.one);
                behaviour.transform.SetSiblingIndex(0);
                slotBehaviours.Add(behaviour);
            }
            m_SelectImg.SetActive(true);
            this.m_Title.color = new Color32(255, 255, 255, 255);//"#ffffff";
        }
 
        public void Dispose()
        {
            for (var i = slotBehaviours.Count - 1; i >= 0; i--)
            {
                EquipStarUpgradeCandidateSlotPool.Release(slotBehaviours[i]);
            }
 
            slotBehaviours.Clear();
            m_SelectImg.SetActive(false);
            this.m_Title.color = new Color32(198, 181, 149, 255); //c6b595
        }
 
        private void Select()
        {
            if (model.selectedLevel.value == this.level)
            {
 
            }
            else
            {
                model.SelectLevel(this.level);
 
                var equipPosition = model.GetRecommendEquipPosition();
                if (this.level == equipPosition.x)
                    model.SelectPlace(equipPosition);
            }
        }
 
    }
 
 
}