lcy
4 天以前 f4d2e99c6041c0d0c933472dcbbeab3cbf4028ef
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
/// <summary>
/// 武将阵型激活界面
/// </summary>
public class HeroFormationWin : UIBase
{
    [SerializeField] Button closeBtn;
    [SerializeField] ScrollerController scroller;
    [SerializeField] Text totalAttrText;     
 
 
    protected override void InitComponent()
    {
        closeBtn.AddListener(CloseWindow);
    }
 
 
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        CreateScroller();
 
        // 优先检查混搭阵型
        HeroLineupHaloConfig activeConfig = null;
        if (HeroUIManager.Instance.isCustonHeroFormation)
        {
            activeConfig = HeroUIManager.Instance.GetMixedFormationConfig(HeroUIManager.Instance.custonTeamHeroes);
            if (activeConfig == null)
            {
                var result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.custonTeamHeroes);
                activeConfig = HeroLineupHaloConfig.GetConfig(result.x, result.y);
            }
        }
        else
        {
            activeConfig = HeroUIManager.Instance.GetMixedFormationConfig(HeroUIManager.Instance.selectTeamType, true);
            if (activeConfig == null)
            {
                var result = HeroUIManager.Instance.GetMaxCountHeroCountry(HeroUIManager.Instance.selectTeamType, true);
                activeConfig = HeroLineupHaloConfig.GetConfig(result.x, result.y);
            }
        }
 
        if (activeConfig == null)
        {
            totalAttrText.text = "";
        }
        else
        {
            string lineText = string.Empty;
 
            for (int i = 0; i < activeConfig.AttrIDList.Length; i++)
            {
                string format = "{0}+" + UIHelper.AppendColor(TextColType.Green, "{1}");
                lineText += " " + PlayerPropertyConfig.GetFullDescription(activeConfig.AttrIDList[i], activeConfig.AttrValueList[i], format);
            }
            totalAttrText.text = Language.Get("herocard36") + lineText.Trim();
        }
    }
 
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
    }
 
 
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as HeroFormationCell;
        _cell.Display(cell.index);
    }
 
    void CreateScroller()
    {
        scroller.Refresh();
        for (int i = 0; i < 4; i++)
        {
            scroller.AddCell(ScrollerDataType.Header, i);
        }
        // 第5个为混搭阵型格子(显示在最后)
        scroller.AddCell(ScrollerDataType.Header, 4);
        scroller.Restart();
    }
 
}