-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainForm.cs
351 lines (333 loc) · 14.1 KB
/
MainForm.cs
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace YunDingCombination
{
public partial class MainForm : Form
{
List<SelectedCombination> m_listCombination = new List<SelectedCombination>();
List<IHero> m_listHero = new List<IHero>();
List<NeedHeros> m_listAllHeros = new List<NeedHeros>();
List<Control> m_listAttribute = new List<Control>();
public MainForm()
{
InitializeComponent();
AddHeros();
AddControl();
for (int i = 0; i < m_listAttribute.Count; i++)
{
m_listAttribute[i].BackColor= Color.FromArgb(85, 255, 255, 255);
}
}
private void AddControl()
{
m_listAttribute.Add(groupBox1);
m_listAttribute.Add(groupBox2);
m_listAttribute.Add(groupBox3);
m_listAttribute.Add(groupBox4);
m_listAttribute.Add(groupBox5);
m_listAttribute.Add(groupBox6);
m_listAttribute.Add(groupBox7);
m_listAttribute.Add(groupBox8);
m_listAttribute.Add(groupBox9);
m_listAttribute.Add(groupBox10);
m_listAttribute.Add(groupBox11);
m_listAttribute.Add(groupBox12);
m_listAttribute.Add(groupBox13);
m_listAttribute.Add(groupBox14);
m_listAttribute.Add(groupBox15);
m_listAttribute.Add(groupBox16);
m_listAttribute.Add(groupBox17);
m_listAttribute.Add(groupBox18);
m_listAttribute.Add(groupBox19);
m_listAttribute.Add(groupBox20);
m_listAttribute.Add(groupBox21);
m_listAttribute.Add(groupBox22);
m_listAttribute.Add(groupBox23);
m_listAttribute.Add(groupBox24);
m_listAttribute.Add(label1);
m_listAttribute.Add(label2);
m_listAttribute.Add(label3);
m_listAttribute.Add(linkLabel1);
m_listAttribute.Add(linkLabel2);
}
private void AddHeros()
{
m_listHero.Add(new 暗影猎手());
m_listHero.Add(new 傲之追猎者());
m_listHero.Add(new 北地之怒());
m_listHero.Add(new 冰晶凤凰());
m_listHero.Add(new 冰霜女巫());
m_listHero.Add(new 不详之刃());
m_listHero.Add(new 惩戒之箭());
m_listHero.Add(new 崔斯特());
m_listHero.Add(new 德玛西亚之力());
m_listHero.Add(new 堕落天使());
m_listHero.Add(new 法外狂徒());
m_listHero.Add(new 弗雷尔卓德之心());
m_listHero.Add(new 复仇焰魂());
m_listHero.Add(new 海洋之灾());
m_listHero.Add(new 寒冰射手());
m_listHero.Add(new 疾风剑豪());
m_listHero.Add(new 暗裔剑魔());
m_listHero.Add(new 九尾妖狐());
m_listHero.Add(new 狂暴之心());
m_listHero.Add(new 狂野女猎手());
m_listHero.Add(new 雷霆咆哮());
m_listHero.Add(new 离群之刺());
m_listHero.Add(new 龙血武姬());
m_listHero.Add(new 麦林炮手());
m_listHero.Add(new 迷失之牙());
m_listHero.Add(new 暮光之眼());
m_listHero.Add(new 诺克萨斯统领());
m_listHero.Add(new 诺克萨斯之手());
m_listHero.Add(new 荣耀行刑官());
m_listHero.Add(new 赏金猎人());
m_listHero.Add(new 圣锤之毅());
m_listHero.Add(new 圣枪游侠());
m_listHero.Add(new 曙光女神());
m_listHero.Add(new 死亡歌颂者());
m_listHero.Add(new 铁铠冥魂());
m_listHero.Add(new 痛苦之拥());
m_listHero.Add(new 无双剑姬());
m_listHero.Add(new 仙灵女巫());
m_listHero.Add(new 邪恶小法师());
m_listHero.Add(new 虚空遁地兽());
m_listHero.Add(new 虚空行者());
m_listHero.Add(new 虚空恐惧());
m_listHero.Add(new 虚空掠夺者());
m_listHero.Add(new 血港魅影());
m_listHero.Add(new 影流之主());
m_listHero.Add(new 永猎双子());
m_listHero.Add(new 蒸汽机器人());
m_listHero.Add(new 正义天使());
m_listHero.Add(new 蜘蛛女皇());
m_listHero.Add(new 铸星龙王());
m_listHero.Add(new 祖安怒兽());
m_listHero.Add(new 卡蜜尔());
m_listHero.Add(new 杰斯());
m_listHero.Add(new 蔚());
m_listHero.Add(new 金克丝());
m_listHero.Add(new 潘森());
m_listHero.Add(new 卡莎());
}
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
m_listCombination.Clear();
foreach (Control ctl in this.Controls)
{
if (ctl is GroupBox)
{
foreach (Control ctli in ((GroupBox)ctl).Controls)
{
if (ctli is CheckBox)
{
if (((CheckBox)ctli).Checked)
{
string name = ((CheckBox)ctli).Text;
string count = name.Substring(0, 1);
string type = name.Substring(1, name.Length - 1);
SelectedCombination sc = new SelectedCombination();
sc.ct = (CombinationType)System.Enum.Parse(typeof(CombinationType), type);
sc.nCount = Convert.ToInt32(count);
m_listCombination.Add(sc);
break;
}
}
}
}
}
RefreshSelectedCombination();
}
private void RefreshSelectedCombination()
{
richTextBox1.Clear();
for (int i = 0; i < m_listCombination.Count; i++)
{
richTextBox1.AppendText(m_listCombination[i].nCount.ToString() + m_listCombination[i].ct.ToString() + "\r\n");
richTextBox1.AppendText(TriggerEffect.effect[m_listCombination[i].nCount.ToString() + m_listCombination[i].ct.ToString()] + "\r\n");
}
}
private void RefreshNeedCombination()
{
panel1.Controls.Clear();
for (int i = 0; i < m_listAllHeros.Count; i++)
{
GroupBox gb = new GroupBox();
gb.Dock = DockStyle.Top;
gb.Size = new Size(376, 138);
gb.Text = m_listAllHeros[i].ct.ToString();
gb.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
flp.AutoScroll = true;
gb.Controls.Add(flp);
for (int j = 0; j < m_listAllHeros[i].m_listNeedHeros.Count; j++)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(60, 60);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.Image = m_listAllHeros[i].m_listNeedHeros[j].image;
flp.Controls.Add(pb);
}
panel1.Controls.Add(gb);
}
GenerateMinCombination();
}
private void GenerateMinCombination()
{
panel2.Controls.Clear();
if (m_listAllHeros.Count != 0)
{
//去除重复的英雄
List<IHero> m_listUniqueHeros = new List<IHero>();
for (int i = 0; i < m_listAllHeros.Count; i++)
{
for (int j = 0; j < m_listAllHeros[i].m_listNeedHeros.Count; j++)
{
if (m_listUniqueHeros.IndexOf(m_listAllHeros[i].m_listNeedHeros[j]) == -1)
{
m_listUniqueHeros.Add(m_listAllHeros[i].m_listNeedHeros[j]);
}
}
}
//选取符合多属性的英雄
List<IHero> m_listDoubleAttribute = new List<IHero>();
for (int i = 0; i < m_listUniqueHeros.Count; i++)
{
int[] judge = new int[m_listCombination.Count];
for (int j = 0; j < m_listCombination.Count; j++)
{
if ((m_listUniqueHeros[i].ct & m_listCombination[j].ct) == m_listCombination[j].ct)
{
judge[j] = 1;
}
}
int AttributeCount = 0;
for (int k = 0; k < judge.Length; k++)
{
if (judge[k] == 1)
{
AttributeCount++;
}
}
if (AttributeCount >= 2)
{
m_listDoubleAttribute.Add(m_listUniqueHeros[i]);
}
}
//移除符合多属性的英雄,减少选取数量
for (int i = 0; i < m_listDoubleAttribute.Count; i++)
{
for (int j = 0; j < m_listCombination.Count; j++)
{
if ((m_listDoubleAttribute[i].ct & m_listCombination[j].ct) == m_listCombination[j].ct)
{
m_listCombination[j].nCount--;
}
}
m_listUniqueHeros.Remove(m_listDoubleAttribute[i]);
}
List<IHero> m_listMinHeros = m_listDoubleAttribute;
for (int i = 0; i < m_listUniqueHeros.Count; i++)
{
int[] judge = new int[m_listCombination.Count];
for (int j = 0; j < m_listCombination.Count; j++)
{
if ((m_listUniqueHeros[i].ct & m_listCombination[j].ct) == m_listCombination[j].ct)
{
if (m_listCombination[j].nCount > 0)
{
m_listCombination[j].nCount--;
judge[j] = 1;
}
}
}
if ((judge.ToList().IndexOf(1) != -1) && (m_listMinHeros.IndexOf(m_listUniqueHeros[i]) == -1))
{
m_listMinHeros.Add(m_listUniqueHeros[i]);
}
}
GroupBox gb = new GroupBox();
gb.Dock = DockStyle.Fill;
gb.Size = new Size(376, 138);
gb.Text = "";
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
flp.AutoScroll = true;
gb.Controls.Add(flp);
for (int j = 0; j < m_listMinHeros.Count; j++)
{
PictureBox pb = new PictureBox();
pb.Size = new Size(60, 60);
pb.SizeMode = PictureBoxSizeMode.Zoom;
pb.Image = m_listMinHeros[j].image;
flp.Controls.Add(pb);
}
panel2.Controls.Add(gb);
}
}
private void panel3_Click(object sender, EventArgs e)
{
checkBox_CheckedChanged(null, new EventArgs());
if (m_listCombination.Count > 0)
{
panel1.BackColor = Color.Ivory;
panel2.BackColor = Color.Ivory;
}
else
{
panel1.BackColor = Color.Transparent;
panel2.BackColor = Color.Transparent;
}
//选取所有需要的英雄
m_listAllHeros.Clear();
for (int i = 0; i < m_listCombination.Count; i++)
{
NeedHeros nh = new NeedHeros();
nh.ct = m_listCombination[i].ct;
for (int j = 0; j < m_listHero.Count; j++)
{
if ((m_listHero[j].ct & m_listCombination[i].ct) == m_listCombination[i].ct)
{
nh.m_listNeedHeros.Add(m_listHero[j]);
}
}
m_listAllHeros.Add(nh);
}
RefreshNeedCombination();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
EquipmentListForm el = new EquipmentListForm();
el.Show();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
HerosListForm hl = new HerosListForm(m_listHero);
hl.Show();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
foreach (Control ctl in this.Controls)
{
if (ctl is GroupBox)
{
foreach (Control ctli in ((GroupBox)ctl).Controls)
{
if (ctli is CheckBox)
{
((CheckBox)ctli).Checked = false;
}
}
}
}
panel3_Click(null, new EventArgs());
}
}
}