-
Notifications
You must be signed in to change notification settings - Fork 0
/
FightingForm.cs
300 lines (262 loc) · 8.74 KB
/
FightingForm.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Space_Conqueror
{
public partial class FightingForm : Form
{
PlayingForm PF;
private int Tier;
private bool Fighting = false;
private int PlayerDam;
private int PlayerPlating;
private int EnemyDam;
private int EnemyPlating;
private int[] ExpToLevel = new int[46];
public FightingForm(PlayingForm pf)
{
InitializeComponent();
CenterFormToScreen();
PF = pf;
this.BackColor = PF.BackColor;
this.ForeColor = PF.ForeColor;
fft1b.BackColor = PF.pffb.BackColor;
fft2b.BackColor = PF.pffb.BackColor;
fft3b.BackColor = PF.pffb.BackColor;
fft4b.BackColor = PF.pffb.BackColor;
fft5b.BackColor = PF.pffb.BackColor;
fft6b.BackColor = PF.pffb.BackColor;
fft7b.BackColor = PF.pffb.BackColor;
fft8b.BackColor = PF.pffb.BackColor;
fft9b.BackColor = PF.pffb.BackColor;
fft10b.BackColor = PF.pffb.BackColor;
fffb.BackColor = PF.pffb.BackColor;
ffcb.BackColor = PF.pffb.BackColor;
int i;
ExpToLevel[0] = 0;
for(i = 1; i < 46; i++)
{
ExpToLevel[i] = i * 3 + ExpToLevel[i - 1];
}
}
protected void CenterFormToScreen()
{
Screen screen = Screen.FromControl(this);
Rectangle workingArea = screen.WorkingArea;
this.Location = new Point(
Math.Max(workingArea.X, workingArea.X + (workingArea.Width - this.Width) / 2),
Math.Max(workingArea.Y, workingArea.Y + (workingArea.Height - this.Height) / 2)
);
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
PF.UpdatePlayingFormLabels();
}
private void fft1b_Click(object sender, EventArgs e)
{
Tier = 1;
StartFight();
}
private void fft2b_Click(object sender, EventArgs e)
{
Tier = 2;
StartFight();
}
private void fft3b_Click(object sender, EventArgs e)
{
Tier = 3;
StartFight();
}
private void fft4b_Click(object sender, EventArgs e)
{
Tier = 4;
StartFight();
}
private void fft5b_Click(object sender, EventArgs e)
{
Tier = 5;
StartFight();
}
private void fft6b_Click(object sender, EventArgs e)
{
Tier = 6;
StartFight();
}
private void fft7b_Click(object sender, EventArgs e)
{
Tier = 7;
StartFight();
}
private void fft8b_Click(object sender, EventArgs e)
{
Tier = 8;
StartFight();
}
private void fft9b_Click(object sender, EventArgs e)
{
Tier = 9;
StartFight();
}
private void fft10b_Click(object sender, EventArgs e)
{
Tier = 10;
StartFight();
}
private void fffb_Click(object sender, EventArgs e)
{
Fight();
}
private void ffcb_Click(object sender, EventArgs e)
{
var r = new Random();
int R = r.Next(2);
if(R == 1)
{
Fighting = false;
ffppl.Visible = false;
fffb.Visible = false;
ffcb.Visible = false;
ffpprogb.Visible = false;
ffepl.Visible = false;
ffeprogb.Visible = false;
ffepb.Visible = false;
}
else
{
Fight();
}
}
private void StartFight()
{
if (PF.P.Level < ((Tier - 1) * 5) || Fighting == true)
{
if (Fighting == true)
{
this.Enabled = false;
MessageBox.Show("You are Already Fighting!");
this.Enabled = true;
}
else
{
this.Enabled = false;
MessageBox.Show($"Cannot face that Tier until Level {((Tier - 1) * 5)}");
this.Enabled = true;
}
}
else
{
ffvl.Visible = false;
Fighting = true;
PlayerDam = PF.P.PShip.DamBonus + PF.P.PShip.Arm.Dam;
PlayerPlating = PF.P.PShip.PlatingBonus + PF.P.PShip.Plate.Plating;
EnemyDam = Program.Ships[Tier - 1].DamBonus;
EnemyPlating = Program.Ships[Tier - 1].PlatingBonus;
ffepb.Image = Program.Ships[Tier - 1].PNG;
ffepb.Visible = true;
ffeprogb.Minimum = 0;
ffeprogb.Maximum = EnemyPlating;
ffeprogb.Value = EnemyPlating;
ffeprogb.Visible = true;
ffepl.Text = $"{EnemyPlating}";
ffepl.TextAlign = ContentAlignment.MiddleCenter;
ffepl.Visible = true;
ffpprogb.Minimum = 0;
ffpprogb.Maximum = PlayerPlating;
ffpprogb.Value = PlayerPlating;
ffpprogb.Visible = true;
ffppl.Text = $"{PlayerPlating}";
ffppl.TextAlign = ContentAlignment.MiddleCenter;
ffppl.Visible = true;
fffb.Visible = true;
ffcb.Visible = true;
}
}
private void Fight()
{
var r = new Random();
int R = r.Next(2);
bool PlayerWins = true;
EnemyPlating -= PlayerDam;
PlayerPlating -= EnemyDam;
if(PlayerPlating <= 0 && EnemyPlating <= 0 )
{
if (R == 1)
PlayerWins = true;
else
PlayerWins = false;
}
else if (PlayerPlating <= 0)
{
PlayerWins = false;
}
else if (EnemyPlating <= 0)
{
PlayerWins = true;
}
else
{
ffeprogb.Value = EnemyPlating;
ffepl.Text = $"{EnemyPlating}";
ffpprogb.Value = PlayerPlating;
ffppl.Text = $"{PlayerPlating}";
return;
}
if(PlayerWins == true)
{
int Dollars;
int Exp;
bool Leveled = false;
if (Tier > 1) {
R = r.Next(((Tier - 1) * 5) + 4);
Exp = ExpToLevel[R];
} else
{
R = r.Next(5);
Exp = ExpToLevel[R];
}
Dollars = Exp * 50;
PF.P.Dollars += Dollars;
if (PF.P.Level < 45)
{
PF.P.Exp += Exp;
while (ExpToLevel[PF.P.Level + 1] <= PF.P.Exp)
{
PF.P.Level += 1;
Leveled = true;
if (PF.P.Level >= 45)
break;
}
}
if (PF.P.Level >= 45)
ffvl.Text = $"Victory is yours!\nDollars: {Dollars}\nYou are already max level!";
else if (Leveled)
{
ffvl.Text = $"Victory is yours!\nDollars: {Dollars}\nExperience: {Exp}\nYou are now level {PF.P.Level}!";
}
else
{
ffvl.Text = $"Victory is yours!\nDollars: {Dollars}\nExperience: {Exp}";
}
}
else
{
ffvl.Text = $"You were defeated!";
}
ffvl.Visible = true;
Fighting = false;
ffppl.Visible = false;
fffb.Visible = false;
ffcb.Visible = false;
ffpprogb.Visible = false;
ffepl.Visible = false;
ffeprogb.Visible = false;
ffepb.Visible = false;
}
}
}