少年修仙传客户端代码仓库
hch
2023-06-14 f23c81d21c9cc4c9f06e8bed3ebb7ddbe7e15ac3
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, April 16, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
 
namespace Snxxz.UI
{
 
    public class TipPetMountSkillWidget : MonoBehaviour
    {
        [SerializeField] ScrollerController m_Scroll;
 
        public void Display(PetMountTipWin.ShowType showType, int itemId)
        {
            var skillInfos = new List<SkillInfo>();
 
            switch (showType)
            {
                case PetMountTipWin.ShowType.Pet:
                    var petId = PetInfoConfig.GetItemUnLockPet(itemId);
                    var petConfig = PetInfoConfig.Get(petId);
 
                    var min = Mathf.Min(petConfig.SkillID.Length, petConfig.SkillUnLock.Length);
                    for (var i = 0; i < min; i++)
                    {
                        var skillId = petConfig.SkillID[i];
                        var unlockLevel = petConfig.SkillUnLock[i];
                        skillInfos.Add(new SkillInfo() { skillId = skillId, unlockLevel = unlockLevel });
                    }
                    break;
                case PetMountTipWin.ShowType.Mount:
                    var horseId = HorseConfig.GetItemUnLockHorse(itemId);
                    var horseUpConfigs = HorseUpConfig.GetMountlistById(horseId);
                    foreach (var config in horseUpConfigs)
                    {
                        foreach (var skill in config.SkillID)
                        {
                            if (skill > 0)
                            {
                                skillInfos.Add(new SkillInfo() { skillId = skill, unlockLevel = config.LV });
                            }
                        }
                    }
                    break;
            }
            m_Scroll.OnRefreshCell -= OnRefreshCell;
            m_Scroll.OnRefreshCell += OnRefreshCell;
 
            //m_Scroll.Init(skillInfos);
            m_Scroll.Refresh();
            foreach (var skillinfo in skillInfos)
            {
                CellInfo info = new CellInfo();
                info.infoInt1 = skillinfo.unlockLevel;
                m_Scroll.AddCell(ScrollerDataType.Header, skillinfo.skillId, info);
            }
            m_Scroll.Restart();
        }
 
        void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            var _cell = cell as TipPetMountSkillBehaviour;
            _cell.Display(cell.index, cell.info.Value.infoInt1);
        }
 
        public struct SkillInfo
        {
            public int skillId;
            public int unlockLevel;
        }
 
    }
 
}