少年修仙传客户端代码仓库
client_linchunjie
2019-03-21 0780d6f78efd25030fdbb0701a14d43d73a0ebe2
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, February 28, 2019
//--------------------------------------------------------
using System;
using System.Collections.Generic;
using Snxxz.UI;
using System.Linq;
 
namespace Snxxz.UI
{
    [XLua.LuaCallCSharp]
    public class AuctionConfigClass
    {
        public int JobEntry;//选择职业条目
        public int TypeEntry;//类型条目
        public bool JobTipBool;//选择职业条目是否显示
        public bool TypeTipBool;//类型条目是否显示
        public AuctionConfig Config;
    }
    public class AuctionHelpModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        public List<AuctionConfig> FullServiceAuctionList = new List<AuctionConfig>();//全服拍卖列表
        public Dictionary<int, AuctionConfigClass> FullServiceAuctionDic = new Dictionary<int, AuctionConfigClass>();//全服拍卖选择记录
        public List<AuctionItemConfig> AuctionItemList = new List<AuctionItemConfig>();//拍卖物品表
        AuctionInquiryModel model { get { return ModelCenter.Instance.GetModel<AuctionInquiryModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        public int AuctionTaxrate1 = 0;//全服拍品税率
        public int AuctionTaxrate2 = 0;//仙盟拍品税率
        public int AuctionTaxrate3 = 0;//仙盟拍品个人税率
        private int selectedGenreNow = 0;
        public int SelectedGenreNow//当前选择的页签
        {
            get { return selectedGenreNow; }
            set { selectedGenreNow = value; }
        }
        private ItemModel itemModel;//当前选择想要上架的物品
        public ItemModel ItemModel
        {
            get { return itemModel; }
            set { itemModel = value; }
        }
        private bool wait = true;
        public bool Wait
        {
            get { return wait; }
            set { wait = value; }
        }
        public bool isOpenPanel = true;
        public bool IsOpenPanel
        {
            get { return isOpenPanel; }
            set { isOpenPanel = value; }
        }
        public override void Init()
        {
            var AuctionTaxrateConfig = FuncConfigConfig.Get("AuctionTaxrate");
            AuctionTaxrate1 = int.Parse(AuctionTaxrateConfig.Numerical1);
            AuctionTaxrate2 = int.Parse(AuctionTaxrateConfig.Numerical2);
            AuctionTaxrate3 = int.Parse(AuctionTaxrateConfig.Numerical3);
            GetAuctionList();
            AuctionItemList = AuctionItemConfig.GetValues();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            GlobalTimeEvent.Instance.secondEvent -= secondEvent;
        }
 
        public void OnPlayerLoginOk()
        {
            wait = true;
            GlobalTimeEvent.Instance.secondEvent += secondEvent;
        }
 
 
 
        public override void UnInit()
        {
 
        }
 
        private void secondEvent()
        {
            if (!wait)
            {
                wait = true;
            }
        }
 
        private void GetAuctionList()//全服获取拍卖列表
        {
            FullServiceAuctionDic.Clear();
            var config = AuctionConfig.GetValues();
            foreach (var value in config)
            {
                FullServiceAuctionList.Add(value);
                if (!FullServiceAuctionDic.ContainsKey(value.Id))
                {
                    AuctionConfigClass AuctionConfig = new AuctionConfigClass();
                    AuctionConfig.JobEntry = 0;
                    AuctionConfig.TypeEntry = 0;
                    AuctionConfig.JobTipBool = value.ChooseItem1 != null && value.ChooseItem1.Length > 0;
                    AuctionConfig.TypeTipBool = value.ChooseItem2 != null && value.ChooseItem2.Length > 0;
                    AuctionConfig.Config = value;
                    FullServiceAuctionDic.Add(value.Id, AuctionConfig);
                }
            }
 
        }
 
        public List<AuctionItemConfig> GetAuctionItemList(int index)//获取关注列表
        {
            List<AuctionItemConfig> auctionItemList = new List<AuctionItemConfig>();
            for (int i = 0; i < AuctionItemList.Count; i++)
            {
                var auctionItem = AuctionItemList[i];
                if (auctionItem.ItemType == index)
                {
                    auctionItemList.Add(auctionItem);
                }
            }
            auctionItemList.Sort(Compare);
            return auctionItemList;
        }
 
        int Compare(AuctionItemConfig x, AuctionItemConfig y)//数组排列
        {
            bool havex = IsConcernedAbout(x.ItemID);
            bool havey = IsConcernedAbout(y.ItemID);
            if (havex.CompareTo(havey) != 0)
            {
                return -havex.CompareTo(havey);
            }
            if (x.Sortpriority.CompareTo(y.Sortpriority) != 0)
            {
                return x.Sortpriority.CompareTo(y.Sortpriority);
            }
            var itemConfigX = ItemConfig.Get(x.ItemID);
            var itemConfigY = ItemConfig.Get(y.ItemID);
            if (itemConfigX != null && itemConfigY != null)
            {
                if (itemConfigX.EquipPlace.CompareTo(itemConfigY.EquipPlace) != 0)//优先装备
                {
                    return itemConfigX.EquipPlace.CompareTo(itemConfigY.EquipPlace);
                }
                if (itemConfigX.ItemColor.CompareTo(itemConfigY.ItemColor) != 0)//品阶
                {
                    return itemConfigX.ItemColor.CompareTo(itemConfigY.ItemColor);
                }
                if (itemConfigX.Type.CompareTo(itemConfigY.Type) != 0)//类型
                {
                    return itemConfigX.Type.CompareTo(itemConfigY.Type);
                }
                if (itemConfigX.JobLimit.CompareTo(itemConfigY.JobLimit) != 0)//职业
                {
                    return itemConfigX.JobLimit.CompareTo(itemConfigY.JobLimit);
                }
            }
            return 1;
        }
 
        private bool IsConcernedAbout(int itemID)
        {
            bool isBool = false;
            if (model.AttentionAuctionItemIDdic.ContainsKey(itemID))
            {
                isBool = true;
            }
            return isBool;
        }
 
        public int GetEquipScore(int equipLevel, int equipPlace)//获取部位的装备评分
        {
            int score = -1;
            string equipGuid = string.Empty;
            var equipSet = equipModel.GetEquipSet(equipLevel);
            equipGuid = equipSet.GetEquip(equipPlace);
            var equiped = !string.IsNullOrEmpty(equipGuid);
            if (equiped)
            {
                var item = packModel.GetItemByGuid(equipGuid);
                score = item.score;
            }
            return score;
        }
 
        public bool WhetherEquipped(int equipLevel, int equipPlace)//是否装备
        {
            bool isBool = false;
            string equipGuid = string.Empty;
            var equipSet = equipModel.GetEquipSet(equipLevel);
            if (equipSet == null)
            {
                return false;
            }
            equipGuid = equipSet.GetEquip(equipPlace);
            isBool = !string.IsNullOrEmpty(equipGuid);
            return isBool;
        }
    }
 
}