1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | class player : PhysicsObject |
---|
10 | { |
---|
11 | public IntMeter health = new IntMeter(100, 0, 100); |
---|
12 | |
---|
13 | public player(double width, double height) |
---|
14 | : base(width, height) |
---|
15 | { |
---|
16 | health.LowerLimit += delegate { |
---|
17 | this.Destroy(); |
---|
18 | }; |
---|
19 | } |
---|
20 | } |
---|
21 | |
---|
22 | class enemy : PhysicsObject |
---|
23 | { |
---|
24 | public IntMeter health = new IntMeter(100, 0, 100); |
---|
25 | public IntMeter ScoreValue = new IntMeter(100, 0, int.MaxValue); |
---|
26 | public bool canShoot = new Boolean(); |
---|
27 | |
---|
28 | public enemy(double width, double height) |
---|
29 | : base(width, height) |
---|
30 | { |
---|
31 | health.LowerLimit += delegate { this.Destroy(); }; |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | class bullet : PhysicsObject |
---|
36 | { |
---|
37 | public int damage; |
---|
38 | |
---|
39 | public bullet(double width, double height) |
---|
40 | : base(width, height) { } |
---|
41 | } |
---|
42 | |
---|
43 | class Power : PhysicsObject |
---|
44 | { |
---|
45 | public int PowerValue; |
---|
46 | |
---|
47 | public Power(double width, double height) |
---|
48 | : base(width, height) { } |
---|
49 | } |
---|
50 | |
---|
51 | class enemyBoss : PhysicsObject |
---|
52 | { |
---|
53 | public IntMeter health = new IntMeter(100, 2, 100); |
---|
54 | public IntMeter ScoreValue = new IntMeter(100, 0, int.MaxValue); |
---|
55 | public bool canShoot = new Boolean(); |
---|
56 | |
---|
57 | public enemyBoss(double width, double height) |
---|
58 | : base(width, height) |
---|
59 | { |
---|
60 | health.LowerLimit += delegate { this.Destroy(); }; |
---|
61 | } |
---|
62 | } |
---|
63 | public class Storm : PhysicsGame |
---|
64 | { |
---|
65 | player player = new player(5, 5); |
---|
66 | IntMeter Score = new IntMeter(0, 0, int.MaxValue); |
---|
67 | IntMeter Power = new IntMeter(0, 0, 10000); |
---|
68 | IntMeter Graze = new IntMeter(0, 0, int.MaxValue); |
---|
69 | IntMeter Multiplier = new IntMeter(1, 1, 10); |
---|
70 | IntMeter toNextMultiplier = new IntMeter(0, 0, 100); |
---|
71 | |
---|
72 | Timer weapon1T = new Timer(); |
---|
73 | Timer weapon2T = new Timer(); |
---|
74 | Timer weapon3T = new Timer(); |
---|
75 | string currentLevel = "Stage1"; |
---|
76 | |
---|
77 | Vector stageSpeed; |
---|
78 | |
---|
79 | public override void Begin() |
---|
80 | { |
---|
81 | |
---|
82 | SetWindowSize(1280, 800, false); |
---|
83 | CreateLvL("Stage1"); |
---|
84 | } |
---|
85 | |
---|
86 | //Stage Creation |
---|
87 | void CreateLvL(string level) |
---|
88 | { |
---|
89 | Level.BackgroundColor = Color.Gray; |
---|
90 | stageSpeed = new Vector(-250, 0); |
---|
91 | Gravity = new Vector(-150, 0); |
---|
92 | |
---|
93 | TileMap stage = TileMap.FromLevelAsset(level); |
---|
94 | stage.SetTileMethod('_', border); |
---|
95 | stage.SetTileMethod('%', frontBorder); |
---|
96 | stage.SetTileMethod('&', backBorder); |
---|
97 | stage.SetTileMethod('P', AddPlayer); |
---|
98 | stage.SetTileMethod('1', enemy1); |
---|
99 | stage.SetTileMethod('2', enemy2); |
---|
100 | stage.SetTileMethod('B', levelboss); |
---|
101 | stage.Execute(40, 40); |
---|
102 | Level.CreateBorders(); |
---|
103 | |
---|
104 | controls(); |
---|
105 | |
---|
106 | AddHealthbar(); |
---|
107 | AddScore(); |
---|
108 | AddPower(); |
---|
109 | AddGraze(); |
---|
110 | AddMultiplier(); |
---|
111 | |
---|
112 | Camera.Position = player.Position; |
---|
113 | Camera.StayInLevel = true; |
---|
114 | } |
---|
115 | void border(Vector position, double width, double height) |
---|
116 | { |
---|
117 | PhysicsObject border = PhysicsObject.CreateStaticObject(width, height); |
---|
118 | border.Position = position; |
---|
119 | border.Restitution = 0; |
---|
120 | border.KineticFriction = 0; |
---|
121 | border.StaticFriction = 0; |
---|
122 | border.Color = Color.Lighter(Color.Black, 20); |
---|
123 | border.Tag = "border"; |
---|
124 | Add(border); |
---|
125 | } |
---|
126 | void frontBorder(Vector position, double width, double height) |
---|
127 | { |
---|
128 | PhysicsObject border = PhysicsObject.CreateStaticObject(width, height); |
---|
129 | border.Position = position; |
---|
130 | border.Color = Color.White; |
---|
131 | border.Restitution = 0; |
---|
132 | border.Tag = "border"; |
---|
133 | border.IgnoresCollisionResponse = true; |
---|
134 | AddCollisionHandler<PhysicsObject, player>(border, frontBorderCollision); |
---|
135 | AddCollisionHandler<PhysicsObject, enemy>(border, frontBorderCollisionEnemy); |
---|
136 | Add(border); |
---|
137 | } |
---|
138 | void backBorder(Vector position, double width, double height) |
---|
139 | { |
---|
140 | PhysicsObject border = PhysicsObject.CreateStaticObject(width, height); |
---|
141 | border.Position = position; |
---|
142 | border.Color = Color.White; |
---|
143 | border.Restitution = 0; |
---|
144 | border.Tag = "border"; |
---|
145 | border.IgnoresCollisionResponse = true; |
---|
146 | AddCollisionHandler<PhysicsObject, player>(border, backBorderCollision); |
---|
147 | AddCollisionHandler<PhysicsObject, enemy>(border, backBorderCollisionEnemy); |
---|
148 | Add(border); |
---|
149 | } |
---|
150 | void frontBorderCollision(PhysicsObject border, PhysicsObject target) |
---|
151 | { |
---|
152 | player.health.Value = player.health.Value - player.health.Value; |
---|
153 | } |
---|
154 | void frontBorderCollisionEnemy(PhysicsObject border, enemy enemy) |
---|
155 | { |
---|
156 | enemy.canShoot = true; |
---|
157 | } |
---|
158 | void backBorderCollision(PhysicsObject border, PhysicsObject target) |
---|
159 | { |
---|
160 | player.health.Value = player.health.Value - player.health.Value; |
---|
161 | } |
---|
162 | void backBorderCollisionEnemy(PhysicsObject border, enemy enemy) |
---|
163 | { |
---|
164 | enemy.Destroy(); |
---|
165 | } |
---|
166 | |
---|
167 | //Player |
---|
168 | void AddPlayer(Vector pos, double width, double height) |
---|
169 | { |
---|
170 | player.Shape = Shape.Circle; |
---|
171 | player.Restitution = 0; |
---|
172 | player.Mass = int.MaxValue; |
---|
173 | player.CanRotate = false; |
---|
174 | player.KineticFriction = 0; |
---|
175 | player.StaticFriction = 0; |
---|
176 | player.IgnoresGravity = true; |
---|
177 | player.Position = pos; |
---|
178 | Add(player); |
---|
179 | } |
---|
180 | void AddHealthbar() |
---|
181 | { |
---|
182 | ProgressBar healthBar = new ProgressBar(640, 10); |
---|
183 | healthBar.BorderColor = Color.Black; |
---|
184 | healthBar.Color = Color.Black; |
---|
185 | healthBar.BarColor = Color.Red; |
---|
186 | healthBar.BindTo(player.health); |
---|
187 | healthBar.Position = new Vector(Screen.Left + 340, Screen.Top - 20); |
---|
188 | Add(healthBar); |
---|
189 | } |
---|
190 | void AddScore() |
---|
191 | { |
---|
192 | Label ScoreMeter = new Label(320,1); |
---|
193 | ScoreMeter.TextColor = Color.Darker(Color.Lime, 10); |
---|
194 | ScoreMeter.Color = Color.Transparent; |
---|
195 | ScoreMeter.Title = "Score"; |
---|
196 | ScoreMeter.BindTo(Score); |
---|
197 | ScoreMeter.Position = new Vector(Screen.Left + 80, Screen.Top - 40); |
---|
198 | Add(ScoreMeter); |
---|
199 | } |
---|
200 | void AddPower() |
---|
201 | { |
---|
202 | Label PowerMeter = new Label(320, 1); |
---|
203 | PowerMeter.TextColor = Color.Red; |
---|
204 | PowerMeter.Title = "Power"; |
---|
205 | PowerMeter.BindTo(Power); |
---|
206 | PowerMeter.Position = new Vector(Screen.Left + 80, Screen.Top - 60); |
---|
207 | Add(PowerMeter); |
---|
208 | } |
---|
209 | void AddGraze() |
---|
210 | { |
---|
211 | Label GrazeMeter = new Label(320, 1); |
---|
212 | GrazeMeter.TextColor = Color.Cyan; |
---|
213 | GrazeMeter.Title = "Graze"; |
---|
214 | GrazeMeter.BindTo(Graze); |
---|
215 | GrazeMeter.Position = new Vector(Screen.Left + 275, Screen.Top - 40); |
---|
216 | Add(GrazeMeter); |
---|
217 | } |
---|
218 | void AddMultiplier() |
---|
219 | { |
---|
220 | Label MultiplierVal = new Label(320, 1); |
---|
221 | MultiplierVal.TextColor = Color.White; |
---|
222 | MultiplierVal.Title = "Multiplier"; |
---|
223 | MultiplierVal.BindTo(Multiplier); |
---|
224 | MultiplierVal.Position = new Vector(Screen.Left + 275, Screen.Top - 60); |
---|
225 | Add(MultiplierVal); |
---|
226 | } |
---|
227 | void controls() |
---|
228 | { |
---|
229 | ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, null); |
---|
230 | ControllerOne.ListenAnalog(AnalogControl.LeftStick, -0.1, move, null); |
---|
231 | ControllerOne.Listen(Button.B, ButtonState.Pressed, Shoot1, null); |
---|
232 | ControllerOne.Listen(Button.B, ButtonState.Released, stopTimers, null); |
---|
233 | ControllerOne.Listen(Button.A, ButtonState.Pressed, Shoot2, null); |
---|
234 | ControllerOne.Listen(Button.A, ButtonState.Released, stopTimers, null); |
---|
235 | ControllerOne.Listen(Button.Y, ButtonState.Pressed, Shoot3, null); |
---|
236 | ControllerOne.Listen(Button.Y, ButtonState.Released, stopTimers, null); |
---|
237 | |
---|
238 | } |
---|
239 | void move(AnalogState speed) |
---|
240 | { |
---|
241 | player.Velocity = speed.StateVector * 250; |
---|
242 | } |
---|
243 | void Grazing(PhysicsObject bullet, Timer graze) |
---|
244 | { |
---|
245 | if (bullet.IsDestroyed == true) graze.Stop(); |
---|
246 | if (player.X >= bullet.Left - 20 && player.X <= bullet.Right + 20 && player.Y <= bullet.Top + 20 && player.Y >= bullet.Bottom - 20) |
---|
247 | { |
---|
248 | Graze.Value++; |
---|
249 | Score.Value = Score.Value + 1 * Multiplier; |
---|
250 | toNextMultiplier.Value++; |
---|
251 | if (toNextMultiplier.Value >= 100) |
---|
252 | { |
---|
253 | Multiplier.Value++; |
---|
254 | toNextMultiplier.Value = 0; |
---|
255 | } |
---|
256 | } |
---|
257 | } |
---|
258 | void death() |
---|
259 | { |
---|
260 | //ControllerOne.Vibrate(1, 1, 10, 10, 0.6); |
---|
261 | ClearControls(); |
---|
262 | ClearTimers(); |
---|
263 | } |
---|
264 | |
---|
265 | //Weapons |
---|
266 | void Shoot1() |
---|
267 | { |
---|
268 | weapon1T.Stop(); |
---|
269 | weapon2T.Stop(); |
---|
270 | weapon3T.Stop(); |
---|
271 | weapon1T.Interval = 0.1; |
---|
272 | weapon1T.Timeout += Weapon1; |
---|
273 | weapon1T.Start(); |
---|
274 | } |
---|
275 | void Weapon1() |
---|
276 | { |
---|
277 | if (Power.Value < 1000) |
---|
278 | { |
---|
279 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
280 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
281 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
282 | } |
---|
283 | else if (Power.Value < 2000) |
---|
284 | { |
---|
285 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 20), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
286 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -20), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
287 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 10), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
288 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -10), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
289 | } |
---|
290 | else if (Power.Value < 3000) |
---|
291 | { |
---|
292 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
293 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
294 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
295 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
296 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
297 | } |
---|
298 | else if (Power.Value < 4000) |
---|
299 | { |
---|
300 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
301 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
302 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
303 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
304 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
305 | |
---|
306 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
307 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
308 | } |
---|
309 | else if (Power.Value < 5000) |
---|
310 | { |
---|
311 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
312 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(20, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
313 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
314 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
315 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
316 | |
---|
317 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
318 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
319 | } |
---|
320 | else if (Power.Value < 6000) |
---|
321 | { |
---|
322 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
323 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
324 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
325 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
326 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
327 | |
---|
328 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(20, 6), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
329 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(20, 6), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
330 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 160), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
331 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -160), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
332 | } |
---|
333 | else if (Power.Value < 7000) |
---|
334 | { |
---|
335 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
336 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(25, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
337 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(35, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
338 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(30, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
339 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(30, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
340 | |
---|
341 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
342 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
343 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 160), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
344 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -160), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
345 | } |
---|
346 | else if (Power.Value < 8000) |
---|
347 | { |
---|
348 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(30, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
349 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(30, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
350 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(40, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
351 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(35, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
352 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(35, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
353 | |
---|
354 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
355 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
356 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 160), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
357 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -160), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
358 | Projectile(player.Position + new Vector(5, 25), new Vector(600, 170), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
359 | Projectile(player.Position + new Vector(5, -25), new Vector(600, -170), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
360 | } |
---|
361 | else if (Power.Value < 9000) |
---|
362 | { |
---|
363 | Projectile(player.Position + new Vector(5, 10), new Vector(600, 60), new Vector(35, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
364 | Projectile(player.Position + new Vector(5, -10), new Vector(600, -60), new Vector(35, 6), 7, Color.LightBlue, "bullet", Shape.Diamond); |
---|
365 | Projectile(player.Position + new Vector(5, 0), new Vector(600, 0), new Vector(45, 6), 9, Color.LightBlue, "bullet", Shape.Diamond); |
---|
366 | Projectile(player.Position + new Vector(5, 5), new Vector(600, 50), new Vector(40, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
367 | Projectile(player.Position + new Vector(5, -5), new Vector(600, -50), new Vector(40, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
368 | |
---|
369 | Projectile(player.Position + new Vector(5, 15), new Vector(600, 150), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
370 | Projectile(player.Position + new Vector(5, -15), new Vector(600, -150), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
371 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 160), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
372 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -160), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
373 | Projectile(player.Position + new Vector(5, 25), new Vector(600, 170), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
374 | Projectile(player.Position + new Vector(5, -25), new Vector(600, -170), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
375 | } |
---|
376 | else if (Power.Value < 10000) |
---|
377 | { |
---|
378 | Projectile(player.Position + new Vector(10, 10), new Vector(600, 60), new Vector(35, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
379 | Projectile(player.Position + new Vector(10, -10), new Vector(600, -60), new Vector(35, 6), 8, Color.LightBlue, "bullet", Shape.Diamond); |
---|
380 | Projectile(player.Position + new Vector(10, 0), new Vector(600, 0), new Vector(45, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
381 | Projectile(player.Position + new Vector(10, 5), new Vector(600, 50), new Vector(40, 6), 9, Color.LightBlue, "bullet", Shape.Diamond); |
---|
382 | Projectile(player.Position + new Vector(10, -5), new Vector(600, -50), new Vector(40, 6), 9, Color.LightBlue, "bullet", Shape.Diamond); |
---|
383 | |
---|
384 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 150), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
385 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -150), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
386 | Projectile(player.Position + new Vector(5, 25), new Vector(600, 160), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
387 | Projectile(player.Position + new Vector(5, -25), new Vector(600, -160), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
388 | Projectile(player.Position + new Vector(5, 30), new Vector(600, 170), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
389 | Projectile(player.Position + new Vector(5, -30), new Vector(600, -170), new Vector(20, 4), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
390 | Projectile(player.Position + new Vector(5, 35), new Vector(600, 180), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
391 | Projectile(player.Position + new Vector(5, -35), new Vector(600, -180), new Vector(15, 4), 2, Color.LightBlue, "bullet", Shape.Diamond); |
---|
392 | } |
---|
393 | else if (Power.Value == 10000) |
---|
394 | { |
---|
395 | Projectile(player.Position + new Vector(10, 10), new Vector(600, 70), new Vector(50, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
396 | Projectile(player.Position + new Vector(10, -10), new Vector(600, -70), new Vector(50, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
397 | Projectile(player.Position + new Vector(10, 0), new Vector(600, 0), new Vector(50, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
398 | Projectile(player.Position + new Vector(10, 5), new Vector(600, 50), new Vector(50, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
399 | Projectile(player.Position + new Vector(10, -5), new Vector(600, -50), new Vector(50, 6), 10, Color.LightBlue, "bullet", Shape.Diamond); |
---|
400 | |
---|
401 | Projectile(player.Position + new Vector(5, 20), new Vector(600, 150), new Vector(35, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
402 | Projectile(player.Position + new Vector(5, -20), new Vector(600, -150), new Vector(35, 6), 6, Color.LightBlue, "bullet", Shape.Diamond); |
---|
403 | Projectile(player.Position + new Vector(5, 25), new Vector(600, 160), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
404 | Projectile(player.Position + new Vector(5, -25), new Vector(600, -160), new Vector(30, 6), 5, Color.LightBlue, "bullet", Shape.Diamond); |
---|
405 | Projectile(player.Position + new Vector(5, 30), new Vector(600, 170), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
406 | Projectile(player.Position + new Vector(5, -30), new Vector(600, -170), new Vector(25, 6), 4, Color.LightBlue, "bullet", Shape.Diamond); |
---|
407 | Projectile(player.Position + new Vector(5, 35), new Vector(600, 180), new Vector(20, 6), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
408 | Projectile(player.Position + new Vector(5, -35), new Vector(600, -180), new Vector(20, 6), 3, Color.LightBlue, "bullet", Shape.Diamond); |
---|
409 | } |
---|
410 | } |
---|
411 | void Shoot2() |
---|
412 | { |
---|
413 | weapon1T.Stop(); |
---|
414 | weapon2T.Stop(); |
---|
415 | weapon3T.Stop(); |
---|
416 | weapon2T.Interval = 0.1; |
---|
417 | weapon2T.Timeout += Weapon2; |
---|
418 | weapon2T.Start(); |
---|
419 | } |
---|
420 | void Weapon2() |
---|
421 | { |
---|
422 | if (Power.Value < 1000) |
---|
423 | { |
---|
424 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 5), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
425 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -5), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
426 | } |
---|
427 | else if (Power.Value < 2000) |
---|
428 | { |
---|
429 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
430 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
431 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(25, 6), 8, Color.LightYellow, "bullet", Shape.Diamond); |
---|
432 | } |
---|
433 | else if (Power.Value < 3000) |
---|
434 | { |
---|
435 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 20), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
436 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -20), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
437 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(30, 6), 9, Color.LightYellow, "bullet", Shape.Diamond); |
---|
438 | } |
---|
439 | else if (Power.Value < 4000) |
---|
440 | { |
---|
441 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 20), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
442 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -20), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
443 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
444 | } |
---|
445 | else if (Power.Value < 5000) |
---|
446 | { |
---|
447 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
448 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
449 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(30, 6), 8, Color.LightYellow, "bullet", Shape.Diamond); |
---|
450 | |
---|
451 | Projectile(player.Position + new Vector(5, 13), new Vector(500, 20), new Vector(20, 6), 6, Color.LightYellow, "bullet", Shape.Diamond); |
---|
452 | Projectile(player.Position + new Vector(5, -13), new Vector(500, -20), new Vector(20, 6), 6, Color.LightYellow, "bullet", Shape.Diamond); |
---|
453 | } |
---|
454 | else if (Power.Value < 6000) |
---|
455 | { |
---|
456 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
457 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(25, 6), 7, Color.LightYellow, "bullet", Shape.Diamond); |
---|
458 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
459 | |
---|
460 | Projectile(player.Position + new Vector(5, 13), new Vector(500, 20), new Vector(20, 6), 6, Color.LightYellow, "bullet", Shape.Diamond); |
---|
461 | Projectile(player.Position + new Vector(5, -13), new Vector(500, -20), new Vector(20, 6), 6, Color.LightYellow, "bullet", Shape.Diamond); |
---|
462 | } |
---|
463 | else if (Power.Value < 7000) |
---|
464 | { |
---|
465 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(30, 8), 9, Color.LightYellow, "bullet", Shape.Diamond); |
---|
466 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(30, 8), 9, Color.LightYellow, "bullet", Shape.Diamond); |
---|
467 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
468 | |
---|
469 | Projectile(player.Position + new Vector(5, 13), new Vector(500, 20), new Vector(25, 7), 8, Color.LightYellow, "bullet", Shape.Diamond); |
---|
470 | Projectile(player.Position + new Vector(5, -13), new Vector(500, -20), new Vector(25, 7), 8, Color.LightYellow, "bullet", Shape.Diamond); |
---|
471 | } |
---|
472 | else if (Power.Value < 8000) |
---|
473 | { |
---|
474 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
475 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
476 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
477 | |
---|
478 | Projectile(player.Position + new Vector(5, 13), new Vector(500, 20), new Vector(30, 7), 9, Color.LightYellow, "bullet", Shape.Diamond); |
---|
479 | Projectile(player.Position + new Vector(5, -13), new Vector(500, -20), new Vector(30, 7), 9, Color.LightYellow, "bullet", Shape.Diamond); |
---|
480 | } |
---|
481 | else if (Power.Value < 9000) |
---|
482 | { |
---|
483 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
484 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
485 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
486 | |
---|
487 | Projectile(player.Position + new Vector(5, 16), new Vector(500, 20), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
488 | Projectile(player.Position + new Vector(5, -16), new Vector(500, -20), new Vector(40, 8), 10, Color.LightYellow, "bullet", Shape.Diamond); |
---|
489 | } |
---|
490 | else if (Power.Value < 10000) |
---|
491 | { |
---|
492 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 10), new Vector(42, 10), 13, Color.LightYellow, "bullet", Shape.Diamond); |
---|
493 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -10), new Vector(42, 10), 13, Color.LightYellow, "bullet", Shape.Diamond); |
---|
494 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(42, 10), 13, Color.LightYellow, "bullet", Shape.Diamond); |
---|
495 | |
---|
496 | Projectile(player.Position + new Vector(5, 18), new Vector(500, 20), new Vector(42, 9), 11, Color.LightYellow, "bullet", Shape.Diamond); |
---|
497 | Projectile(player.Position + new Vector(5, -18), new Vector(500, -20), new Vector(42, 9), 11, Color.LightYellow, "bullet", Shape.Diamond); |
---|
498 | } |
---|
499 | else if (Power.Value == 10000) |
---|
500 | { |
---|
501 | Projectile(player.Position + new Vector(5, 8), new Vector(500, 20), new Vector(45, 10), 15, Color.LightYellow, "bullet", Shape.Diamond); |
---|
502 | Projectile(player.Position + new Vector(5, -8), new Vector(500, -20), new Vector(45, 10), 15, Color.LightYellow, "bullet", Shape.Diamond); |
---|
503 | Projectile(player.Position + new Vector(5, 0), new Vector(500, 0), new Vector(45, 10), 15, Color.LightYellow, "bullet", Shape.Diamond); |
---|
504 | |
---|
505 | Projectile(player.Position + new Vector(5, 20), new Vector(500, 30), new Vector(45, 10), 15, Color.LightYellow, "bullet", Shape.Diamond); |
---|
506 | Projectile(player.Position + new Vector(5, -20), new Vector(500, -30), new Vector(45, 10), 15, Color.LightYellow, "bullet", Shape.Diamond); |
---|
507 | } |
---|
508 | } |
---|
509 | void Shoot3() |
---|
510 | { |
---|
511 | weapon1T.Stop(); |
---|
512 | weapon2T.Stop(); |
---|
513 | weapon3T.Stop(); |
---|
514 | weapon3T.Interval = 0.01; |
---|
515 | weapon3T.Timeout += Weapon3; |
---|
516 | weapon3T.Start(); |
---|
517 | } |
---|
518 | void Weapon3() |
---|
519 | { |
---|
520 | if (Power.Value < 1000) |
---|
521 | { |
---|
522 | Projectile(player.Position + new Vector(25, 0), new Vector(600, 0), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
523 | } |
---|
524 | else if (Power.Value < 2000) |
---|
525 | { |
---|
526 | Projectile(player.Position + new Vector(25, 8), new Vector(600, 0), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
527 | Projectile(player.Position + new Vector(25, -8), new Vector(600, 0), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
528 | } |
---|
529 | else if (Power.Value < 3000) |
---|
530 | { |
---|
531 | Projectile(player.Position + new Vector(25, 0), new Vector(600, 0), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
532 | Projectile(player.Position + new Vector(25, 10), new Vector(600, 50), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
533 | Projectile(player.Position + new Vector(25, -10), new Vector(600, -50), new Vector(15, 3), 1, Color.Red, "laser", Shape.Rectangle); |
---|
534 | } |
---|
535 | |
---|
536 | } |
---|
537 | void Projectile(Vector pos, Vector vel, Vector size, int dmg, Color color, string type, Shape shape) |
---|
538 | { |
---|
539 | bullet projectile = new bullet(1,1); |
---|
540 | projectile.Size = size; |
---|
541 | projectile.Shape = shape; |
---|
542 | projectile.Color = color; |
---|
543 | projectile.IgnoresGravity = true; |
---|
544 | projectile.Position = pos; |
---|
545 | projectile.Tag = type; |
---|
546 | projectile.damage = dmg; |
---|
547 | projectile.IgnoresCollisionResponse = true; |
---|
548 | AddCollisionHandler<bullet, enemy>(projectile, damageEnemy); |
---|
549 | AddCollisionHandler<bullet, enemyBoss>(projectile, damageBoss); |
---|
550 | AddCollisionHandler(projectile,"border",destroy); |
---|
551 | Add(projectile, 1); |
---|
552 | projectile.Hit(vel); |
---|
553 | projectile.Angle = projectile.Velocity.Angle; |
---|
554 | } |
---|
555 | |
---|
556 | void stopTimers() |
---|
557 | { |
---|
558 | weapon1T.Stop(); |
---|
559 | weapon2T.Stop(); |
---|
560 | weapon3T.Stop(); |
---|
561 | weapon1T.Timeout -= Weapon1; |
---|
562 | weapon2T.Timeout -= Weapon2; |
---|
563 | weapon3T.Timeout -= Weapon3; |
---|
564 | } |
---|
565 | |
---|
566 | //Enemies |
---|
567 | void enemy1(Vector position, double width, double height) |
---|
568 | { |
---|
569 | enemy enemy = new enemy(20, 20); |
---|
570 | enemy.Shape = Shape.Circle; |
---|
571 | enemy.Color = Color.Black; |
---|
572 | enemy.Position = position; |
---|
573 | enemy.ScoreValue.Value = 15; |
---|
574 | enemy.health.Value = 30; |
---|
575 | enemy.canShoot = false; |
---|
576 | enemy.IgnoresGravity = true; |
---|
577 | enemy.IgnoresCollisionResponse = true; |
---|
578 | enemy.Hit(stageSpeed); |
---|
579 | AddCollisionHandler<PhysicsObject, player>(enemy, damagePlayer); |
---|
580 | Add(enemy); |
---|
581 | Timer shoot = new Timer(); |
---|
582 | shoot.Interval = 0.5; |
---|
583 | shoot.Timeout += delegate { enemy1AI(enemy, shoot); }; |
---|
584 | shoot.Start(); |
---|
585 | } |
---|
586 | void enemy1AI(enemy enemy, Timer shoot) |
---|
587 | { |
---|
588 | if (enemy.IsDestroyed == true) shoot.Stop(); |
---|
589 | if (enemy.canShoot == true) |
---|
590 | { |
---|
591 | Vector direction = (player.Position - enemy.Position).Normalize(); |
---|
592 | enemyBullet1(direction * 200, new Vector(20, 6), enemy.Position); |
---|
593 | } |
---|
594 | } |
---|
595 | void enemy2(Vector position, double width, double height) |
---|
596 | { |
---|
597 | enemy enemy = new enemy(21, 21); |
---|
598 | enemy.Shape = Shape.Circle; |
---|
599 | enemy.Color = Color.Black; |
---|
600 | enemy.Position = position; |
---|
601 | enemy.Velocity = stageSpeed; |
---|
602 | enemy.ScoreValue.Value = 25; |
---|
603 | enemy.health.Value = 50; |
---|
604 | enemy.canShoot = false; |
---|
605 | enemy.IgnoresGravity = true; |
---|
606 | enemy.IgnoresCollisionResponse = true; |
---|
607 | AddCollisionHandler<PhysicsObject, player>(enemy, damagePlayer); |
---|
608 | Add(enemy); |
---|
609 | Timer shoot = new Timer(); |
---|
610 | shoot.Interval = 0.7; |
---|
611 | shoot.Timeout += delegate { enemy2AI(enemy, shoot); }; |
---|
612 | shoot.Start(); |
---|
613 | } |
---|
614 | void enemy2AI(enemy enemy, Timer shoot) |
---|
615 | { |
---|
616 | if (enemy.IsDestroyed == true) shoot.Stop(); |
---|
617 | if (enemy.canShoot == true) |
---|
618 | { |
---|
619 | enemyBullet1(new Vector(300,300), new Vector(20,6),enemy.Position); |
---|
620 | enemyBullet1(new Vector(-300, -300), new Vector(20, 6), enemy.Position); |
---|
621 | enemyBullet1(new Vector(300, -300), new Vector(20, 6), enemy.Position); |
---|
622 | enemyBullet1(new Vector(-300, 300), new Vector(20, 6), enemy.Position); |
---|
623 | |
---|
624 | enemyBullet1(new Vector(450, 0), new Vector(20, 6), enemy.Position); |
---|
625 | enemyBullet1(new Vector(-450, 0), new Vector(20, 6), enemy.Position); |
---|
626 | enemyBullet1(new Vector(0, -450), new Vector(20, 6), enemy.Position); |
---|
627 | enemyBullet1(new Vector(0, 450), new Vector(20, 6), enemy.Position); |
---|
628 | |
---|
629 | enemyBullet1(new Vector(400, 162.5), new Vector(20, 6), enemy.Position); |
---|
630 | enemyBullet1(new Vector(-400, -162.5), new Vector(20, 6), enemy.Position); |
---|
631 | enemyBullet1(new Vector(400, -162.5), new Vector(20, 6), enemy.Position); |
---|
632 | enemyBullet1(new Vector(-400, 162.5), new Vector(20, 6), enemy.Position); |
---|
633 | |
---|
634 | enemyBullet1(new Vector(162.5, 400), new Vector(20, 6), enemy.Position); |
---|
635 | enemyBullet1(new Vector(-162.5, -400), new Vector(20, 6), enemy.Position); |
---|
636 | enemyBullet1(new Vector(162.5, -400), new Vector(20, 6), enemy.Position); |
---|
637 | enemyBullet1(new Vector(-162.5, 400), new Vector(20, 6), enemy.Position); |
---|
638 | } |
---|
639 | } |
---|
640 | void enemyBullet1(Vector direction, Vector size, Vector pos) |
---|
641 | { |
---|
642 | PhysicsObject bullet = new PhysicsObject(1,1); |
---|
643 | bullet.Shape = Shape.Diamond; |
---|
644 | bullet.Color = Color.Black; |
---|
645 | bullet.IgnoresGravity = true; |
---|
646 | bullet.Size = size; |
---|
647 | bullet.Tag = "bullet"; |
---|
648 | bullet.IgnoresCollisionResponse = true; |
---|
649 | bullet.Position = pos; |
---|
650 | Add(bullet); |
---|
651 | AddCollisionHandler<PhysicsObject, player>(bullet, damagePlayer); |
---|
652 | AddCollisionHandler(bullet, "border", destroy); |
---|
653 | bullet.Hit(direction); |
---|
654 | bullet.Angle = direction.Angle; |
---|
655 | bullet.IgnoresPhysicsLogics = true; |
---|
656 | |
---|
657 | Timer graze = new Timer(); |
---|
658 | graze.Interval = 0.001; |
---|
659 | graze.Timeout += delegate { Grazing(bullet, graze); }; |
---|
660 | graze.Start(); |
---|
661 | } |
---|
662 | |
---|
663 | //Bosses |
---|
664 | void levelboss(Vector position, double width, double height) |
---|
665 | { |
---|
666 | enemyBoss boss = new enemyBoss(20,20); |
---|
667 | boss.Destroyed +=new Action(finish); |
---|
668 | boss.Shape = Shape.Circle; |
---|
669 | boss.Color = Color.Black; |
---|
670 | boss.Position = position; |
---|
671 | boss.ScoreValue.Value = 15; |
---|
672 | boss.health.Value = 30; |
---|
673 | boss.canShoot = false; |
---|
674 | boss.IgnoresGravity = true; |
---|
675 | boss.IgnoresCollisionResponse = true; |
---|
676 | boss.Hit(stageSpeed); |
---|
677 | AddCollisionHandler<PhysicsObject, player>(boss, damagePlayer); |
---|
678 | Add(boss); |
---|
679 | } |
---|
680 | //Misc |
---|
681 | void CreatePowerValue(int Percent, enemy enemy) |
---|
682 | { |
---|
683 | if (Percent <= 100 + Multiplier.Value * 2) |
---|
684 | { |
---|
685 | int selectPower = RandomGen.NextInt(0, 100); |
---|
686 | if (selectPower <= 100 + Multiplier.Value) |
---|
687 | { |
---|
688 | int selectPower2 = RandomGen.NextInt(0, 100); |
---|
689 | if (selectPower2 <= 100) |
---|
690 | { |
---|
691 | CreatePower(new Vector(20, 20), 1000, enemy); |
---|
692 | } |
---|
693 | else CreatePower(new Vector(15, 15), 100, enemy); |
---|
694 | } |
---|
695 | else CreatePower(new Vector(10, 10), 10, enemy); |
---|
696 | } |
---|
697 | } |
---|
698 | void CreatePower(Vector size, int powerval, enemy enemy) |
---|
699 | { |
---|
700 | Power power = new Power(1, 1); |
---|
701 | power.Size = size; |
---|
702 | power.Shape = Shape.Rectangle; |
---|
703 | power.Position = enemy.Position; |
---|
704 | power.PowerValue = powerval; |
---|
705 | power.IgnoresCollisionResponse = true; |
---|
706 | Add(power); |
---|
707 | AddCollisionHandler<Power, player>(power, PowerCollision); |
---|
708 | AddCollisionHandler(power, "border", destroy); |
---|
709 | |
---|
710 | Timer timer = new Timer(); |
---|
711 | timer.Interval = 0.01; |
---|
712 | timer.Timeout += delegate { DirectedXAxis(power, timer); }; |
---|
713 | timer.Start(); |
---|
714 | } |
---|
715 | void PowerCollision(Power power, player player) |
---|
716 | { |
---|
717 | Power.Value = Power.Value + power.PowerValue; |
---|
718 | Score.Value = Score.Value + power.PowerValue / 10 * Multiplier; |
---|
719 | power.Destroy(); |
---|
720 | } |
---|
721 | void DirectedXAxis(PhysicsObject powerUp, Timer timer) |
---|
722 | { |
---|
723 | if (powerUp.IsDestroyed == true) timer.Stop(); |
---|
724 | Vector direction = (player.Position - powerUp.Position).Normalize(); |
---|
725 | powerUp.Velocity = new Vector(powerUp.Velocity.X, direction.Y * 300); |
---|
726 | } |
---|
727 | void damagePlayer(PhysicsObject bullet, player player) |
---|
728 | { |
---|
729 | player.health.Value = player.health.Value - 10; |
---|
730 | Multiplier.Value--; |
---|
731 | toNextMultiplier.Value = 0; |
---|
732 | ControllerOne.Vibrate(0.5, 0.5, 10, 10, 0.2); |
---|
733 | if (player.health.Value == 0) death(); |
---|
734 | } |
---|
735 | void damageEnemy(bullet projectile, enemy target) |
---|
736 | { |
---|
737 | target.health.Value = target.health.Value - projectile.damage; |
---|
738 | if (target.IsDestroying) |
---|
739 | { |
---|
740 | Score.Value = Score.Value + target.ScoreValue * Multiplier.Value; |
---|
741 | int Percent = RandomGen.NextInt(0, 100); |
---|
742 | CreatePowerValue(Percent, target); |
---|
743 | } |
---|
744 | if (projectile.Tag.ToString() == "bullet") projectile.Destroy(); |
---|
745 | } |
---|
746 | void damageBoss(bullet projectile, enemyBoss target) |
---|
747 | { |
---|
748 | target.health.Value = target.health.Value - projectile.damage; |
---|
749 | if (projectile.Tag.ToString() == "bullet") projectile.Destroy(); |
---|
750 | } |
---|
751 | void destroy(PhysicsObject projectile, PhysicsObject target) |
---|
752 | { |
---|
753 | projectile.Destroy(); |
---|
754 | } |
---|
755 | void finish() |
---|
756 | { |
---|
757 | ClearAll(); |
---|
758 | Timer.SingleShot(1, finish2); |
---|
759 | } |
---|
760 | void finish2() |
---|
761 | { |
---|
762 | if (currentLevel == "Stage1") |
---|
763 | { |
---|
764 | currentLevel = "Stage2"; |
---|
765 | CreateLvL(currentLevel); |
---|
766 | } |
---|
767 | else if (currentLevel == "Stage2") |
---|
768 | { |
---|
769 | currentLevel = "Stage3"; |
---|
770 | CreateLvL(currentLevel); |
---|
771 | } |
---|
772 | else if (currentLevel == "Stage3") |
---|
773 | { |
---|
774 | currentLevel = "Stage4"; |
---|
775 | CreateLvL(currentLevel); |
---|
776 | } |
---|
777 | else if (currentLevel == "Stage4") |
---|
778 | { |
---|
779 | currentLevel = "Stage5"; |
---|
780 | CreateLvL(currentLevel); |
---|
781 | } |
---|
782 | else if (currentLevel == "Stage5") |
---|
783 | { |
---|
784 | currentLevel = "Stage6"; |
---|
785 | CreateLvL(currentLevel); |
---|
786 | } |
---|
787 | else if (currentLevel == "Stage6") |
---|
788 | { |
---|
789 | currentLevel = "Stage7"; |
---|
790 | CreateLvL(currentLevel); |
---|
791 | } |
---|
792 | } |
---|
793 | } |
---|