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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
/// <summary>
/// 武将皮肤形象选择
/// </summary>
public class HeroSkinChooseWin : UIBase
{
    [SerializeField] Button closeBtn;
    [SerializeField] Button okBtn;
    [SerializeField] ScrollerController skinScroller;
 
    public static int selectIndex;
    public static List<int> activeIndexList = new List<int>();
    HeroConfig heroConfig;
 
    protected override void InitComponent()
    {
        closeBtn.AddListener(() =>
        {
            CloseWindow();
        });
        okBtn.AddListener(() =>
        {
            var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuid);
            HeroUIManager.Instance.SendSkinOP(hero.heroId, heroConfig.SkinIDList[selectIndex], 2, hero.itemHero.gridIndex);
            CloseWindow();
        });
 
    }
 
    protected override void OnPreOpen()
    {
        var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectHeroGuid);
        heroConfig = hero.heroConfig;
        skinScroller.OnRefreshCell += OnRefreshCell;
        selectIndex = hero.SkinIndex;
        activeIndexList = new List<int>();
        for (int i = 0; i < heroConfig.SkinIDList.Length; i++)
        {
            if (HeroUIManager.Instance.IsHeroSkinActive(hero.heroId, heroConfig.SkinIDList[i]))
            {
                activeIndexList.Add(i);
            }
        }
        CreateScroller();
    }
 
    protected override void OnPreClose()
    {
        skinScroller.OnRefreshCell -= OnRefreshCell;
        heroConfig = null;
    }
 
    void CreateScroller()
    {
 
        skinScroller.Refresh();
        for (int i = 0; i < activeIndexList.Count; i++)
        {
            if (i % 4 == 0)
            {
                skinScroller.AddCell(ScrollerDataType.Header, i);
            }
        }
        skinScroller.Restart();
 
    }
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as HeroSkinRoleLineCell;
        _cell.Display(heroConfig, cell.index);
    }
 
    public void SetSelectIndex(int index)
    {
        selectIndex = index;
        skinScroller.m_Scorller.RefreshActiveCellViews();
    }
}