少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, December 18, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class DungeonGatherSoulVictoryWin : DungeonVictoryWin
    {
        [SerializeField] ScrollerController m_ScrollerControl;
        [SerializeField] RectTransform m_ContainerItems;
        [SerializeField] GatherSoulResultItemCell[] m_ResultItems;
 
        DungeonModel model
        {
            get { return ModelCenter.Instance.GetModel<DungeonModel>(); }
        }
 
        List<ServerItem> itemList = new List<ServerItem>();
 
        protected override void AddListeners()
        {
            base.AddListeners();
            m_ScrollerControl.OnRefreshCell += OnRefreshCell;
        }
 
        protected override void Display()
        {
            m_ContainerPoivt.gameObject.SetActive(true);
            base.RequireDungeonExit();
            base.DrawPassTime();
            DisplayItems();
        }
 
        void DisplayItems()
        {
            itemList.Clear();
            var result = model.dungeonResult;
            if (result.itemInfo != null)
            {
                itemList.AddRange(result.itemInfo);
            }
            itemList.Sort(Compare);
            m_ScrollerControl.Refresh();
            m_ContainerItems.gameObject.SetActive(itemList.Count > 0 && itemList.Count <= 6);
            if (itemList.Count > 6)
            {
                for (int i = 0; i < itemList.Count; i++)
                {
                    m_ScrollerControl.AddCell(ScrollerDataType.Header, i);
                }
            }
            else
            {
                for (int i = 0; i < m_ResultItems.Length; i++)
                {
                    m_ResultItems[i].gameObject.SetActive(i < itemList.Count);
                    if (i < itemList.Count)
                    {
                        m_ResultItems[i].Display(itemList[i].ItemID, itemList[i].Count);
                    }
                }
            }
            m_ScrollerControl.Restart();
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            var resultCell = cell as GatherSoulResultItemCell;
            if (cell.index < itemList.Count)
            {
                var item = itemList[cell.index];
                resultCell.Display(item.ItemID, item.Count);
            }
        }
 
        int Compare(ServerItem lhs, ServerItem rhs)
        {
            var lhsConfig = ItemConfig.Get(lhs.ItemID);
            var rhsConfig = ItemConfig.Get(rhs.ItemID);
            var lhsEssence = lhsConfig.Type == GatheringSoulModel.GATHERSOUL_ESSENCE_TYPE;
            var rhsEssence = rhsConfig.Type == GatheringSoulModel.GATHERSOUL_ESSENCE_TYPE;
            if (lhsEssence != rhsEssence)
            {
                return lhsEssence.CompareTo(rhsEssence);
            }
            if (lhsConfig.ItemColor != rhsConfig.ItemColor)
            {
                return -lhsConfig.ItemColor.CompareTo(rhsConfig.ItemColor);
            }
            var lhsCore = lhsConfig.Type == GatheringSoulModel.GATHERSOUL_CORE_TYPE;
            var rhsCore = rhsConfig.Type == GatheringSoulModel.GATHERSOUL_CORE_TYPE;
            if (lhsCore != rhsCore)
            {
                return -lhsCore.CompareTo(rhsCore);
            }
            return 0;
        }
    }
 
}