Changeset 8966 for 2017/27/OskariK/OK/OK/OK/OK.cs
- Timestamp:
- 2017-07-06 14:51:25 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/27/OskariK/OK/OK/OK/OK.cs
r8959 r8966 13 13 GameObject portrait; //ruutu, jossa pelihahmon HP ja kauniit kasvot 14 14 GameObject tappio; //ruutu, joka ilmaantuu pelaajan hävitessä 15 15 16 GameObject foe1; //ruutu, jossa pahis 1 16 17 GameObject foe2; //ruutu, jossa pahis 2 17 18 GameObject foe3; //ruutu, jossa pahis 3 19 18 20 double textheight = -220; 19 21 double textwidth = -750; 22 23 GameObject inventory; //ruutu, jossa kamasi näkyvät 24 20 25 GameObject transition; //ruutu, jolla peli menee eteenpäin 26 GameObject voitto; //ruutu, joka tulee kun voitat pelin 27 28 int vihollisNro = 1; 21 29 22 30 PhysicsObject Pointer; //jolla valitaan schaibaa 23 31 Timer ajastin; 32 24 33 bool pelaajatoiminut = false; //tarkistaa, että onko pelaaja käyttänyt vuoronsa, että hän ei pääse rikkomaan peliä 25 34 26 35 IntMeter goopHP; //ekan vihollisen hp 27 36 IntMeter skeleHP; //tokan vihollisen hp 37 IntMeter snekHP; //kolmannen vihollisen HP 28 38 IntMeter HP; //pelaajan hp 29 int playerdamage = 10; //pelaajan papu 39 40 int playerdamage = 10; //pelaajan tehot 30 41 int enemy1damage = 5; //ekan vihollisen tehot 31 42 int enemy2damage = 20; //tokan vihollisen tehot 43 int enemy3damage = 24; //kolmannen vihollisen tehot 32 44 33 45 Label foeHP; // eka vihu … … 63 75 command.Y = -330.00; 64 76 command.Image = LoadImage("Kökkö"); 65 Add(command );77 Add(command, 1); 66 78 67 79 feed = new GameObject(1000.00, 300.00); … … 161 173 162 174 163 164 //Keyboard.Listen(Key.Left, ButtonState.Pressed, AsetaNopeus, "liikkuu", Pointer, nopeusVasen);165 ///Keyboard.Listen(Key.Left, ButtonState.Released, AsetaNopeus, null, Pointer, Vector.Zero);166 167 //Keyboard.Listen(Key.Right, ButtonState.Pressed, AsetaNopeus, "liikkuu", Pointer, nopeusOikea);168 //Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, Pointer, Vector.Zero);169 170 175 Keyboard.Listen(Key.Z, ButtonState.Pressed, Valitse, null); 171 176 … … 177 182 178 183 { 184 179 185 if (pelaajatoiminut) return; 180 186 pelaajatoiminut = true; 181 187 if (Pointer.Y > command.Top - command.Height / 3) Attack(); 182 188 else if (Pointer.Y < command.Bottom + command.Height / 3) Exit(); 183 else Exit(); 189 else Items(); 190 } 191 192 void Items() 193 { 194 pelaajatoiminut = false; 195 inventory = new GameObject (450.0, 300.0); 196 command.Shape = Shape.Rectangle; 197 inventory.Color = Color.Black; 198 inventory.X = 370.00; 199 inventory.Y = -330.00; 200 inventory.Image = LoadImage("Items"); 201 Add(inventory); 202 command.Destroy(); 203 204 Keyboard.Listen(Key.X, ButtonState.Pressed, LuoAlue, null); 205 206 207 208 184 209 } 185 210 … … 188 213 if (goopHP.Value > 0) attackenemy1(); 189 214 else if (skeleHP.Value > 0) attackenemy2(); 215 else if (snekHP.Value > 0) attackenemy3(); 190 216 } 191 217 … … 244 270 } 245 271 272 void attackenemy3() 273 { 274 snekHP.Value -= playerdamage; 275 276 GameObject hit = new GameObject(100.00, 100.00); 277 hit.Shape = Shape.Star; 278 hit.Color = Color.OrangeRed; 279 hit.X = 0.00; 280 hit.Y = Screen.Top - 60.00; 281 Add(hit, 3); 282 hit.Image = LoadImage("hitanim2"); 283 hit.MaximumLifetime = new TimeSpan(0, 0, 0, 0, 50); 284 285 PlaySound("hit"); 286 287 GameObject hit2 = new GameObject(100.00, 100.00); 288 hit2.Shape = Shape.Star; 289 hit2.Color = Color.OrangeRed; 290 hit2.X = 0.00; 291 hit2.Y = Screen.Top - 60.00; 292 hit2.Image = LoadImage("hitanim"); 293 hit2.MaximumLifetime = new TimeSpan(0, 0, 0, 0, 100); 294 Add(hit2, 3); 295 296 Attackfeed(playerdamage); 297 } 298 246 299 void Attackfeed(double damage) //combat login tiedot päivittyy 247 300 { … … 251 304 feedtext.Y = textheight - feedtext.Height / 2; 252 305 253 if (goopHP == 0) Transition(); 254 255 if (goopHP == 0) return; 256 257 if (goopHP > 0) Timer.SingleShot(1.0, Enemy1attack); 258 259 else if (skeleHP > 0) Timer.SingleShot(1.0, Enemy2attack); 306 switch (vihollisNro) 307 { 308 case 1: 309 if (goopHP > 0) Timer.SingleShot(1.0, Enemy1attack); 310 else Transition(); 311 break; 312 313 case 2: 314 if (skeleHP > 0) Timer.SingleShot(1.0, Enemy2attack); 315 else Transition2(); 316 break; 317 318 case 3: 319 if (snekHP > 0) Timer.SingleShot(1.0, Enemy3attack); 320 else Voitit(); 321 break; 322 } 323 324 325 326 327 328 260 329 } 261 330 … … 278 347 } 279 348 280 void Enemy2attack() 349 void Enemy2attack() //tokan vihollisen AI 281 350 { 282 351 PlaySound("playertakesdamage"); … … 295 364 } 296 365 366 void Enemy3attack() //kolmannen vihollisen ai 367 { 368 PlaySound("playertakesdamage"); 369 HP.Value -= enemy3damage; 370 371 double y = feedtext.Y; 372 double x = feedtext.X; 373 374 feedtext.Text = "Received " + enemy3damage + " damage.\n" + feedtext.Text; 375 feedtext.Y = textheight - feedtext.Height / 2; 376 feedtext.X = textwidth; ; 377 378 pelaajatoiminut = false; 379 380 if (HP == 0) Lose(); 381 } 297 382 void Transition() //pelin siirtyminen eteenpäin, kun pahis voitettu 298 383 { 299 384 foeHP.Destroy(); 300 385 vihollisNro++; 301 386 transition = new GameObject(1800.00, 700.00); 302 387 transition.Shape = Shape.Rectangle; … … 310 395 } 311 396 397 void Transition2() //pelin siirtyminen eteenpäin, kun toinen pahis on voitettu 398 { 399 foeHP.Destroy(); 400 vihollisNro++; 401 transition = new GameObject(1800.00, 700.00); 402 transition.Shape = Shape.Rectangle; 403 transition.Color = Color.Aqua; 404 transition.X = -10.00; 405 transition.Y = 200.00; 406 transition.Image = LoadImage("transiitio"); 407 Add(transition, 3); 408 409 Timer.SingleShot(1.5, Lisaapahis3); 410 } 411 312 412 void Lisaapahis2() 313 413 { … … 337 437 } 338 438 439 void Lisaapahis3() 440 441 { 442 foe3 = new GameObject(1800.00, 700.00); 443 foe3.Shape = Shape.Rectangle; 444 foe3.Color = Color.Aqua; 445 foe3.X = -10.00; 446 foe3.Y = 200.00; 447 foe3.Image = LoadImage("snek"); 448 Add(foe3, 3); 449 450 pelaajatoiminut = false; 451 452 snekHP = new IntMeter(100); 453 454 foeHP = new Label(); 455 456 foeHP.X = 150.00; 457 foeHP.Y = Screen.Top - 40.00; 458 foeHP.TextColor = Color.Blue; 459 foeHP.Color = Color.Transparent; 460 Add(foeHP); 461 462 foeHP.BindTo(snekHP); 463 Add(foeHP, 2); 464 } 465 466 void Voitit() //kun pelaaja voittaa kaikki pahikset 467 { 468 pelaajatoiminut = true; 469 foeHP.Destroy(); 470 voitto = new GameObject(1800.00, 700.00); 471 voitto.Shape = Shape.Rectangle; 472 voitto.Color = Color.Aqua; 473 voitto.X = -10.00; 474 voitto.Y = 200.00; 475 voitto.Image = LoadImage("voitto"); 476 Add(voitto, 3); 477 478 Timer.SingleShot(10, Exit); 479 } 480 339 481 void Lose() //pelaajan häviö 340 482 { 341 483 pelaajatoiminut = true; 484 foeHP.Destroy(); 342 485 343 486 tappio = new GameObject(Screen.Width, Screen.Height);
Note: See TracChangeset
for help on using the changeset viewer.