- Timestamp:
- 2012-06-28 15:00:47 (9 years ago)
- Location:
- 2012/26/MikaL
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie Survival/Zombie_Survival.cs
r3283 r3322 7 7 using Jypeli.Widgets; 8 8 9 10 class Zombi : PhysicsObject 11 { 12 public IntMeter zhp = new IntMeter(3,0,3); 13 14 public Zombi(double leveys, double korkeus) 15 : base(leveys, korkeus) 16 { 17 zhp.LowerLimit += delegate { this.Destroy();}; 18 } 19 } 20 9 21 public class Zombie_Survival : PhysicsGame 10 22 { 23 ScoreList topLista = new ScoreList(10, false, 0); 24 11 25 PhysicsObject p1; 12 26 PhysicsObject p2; 13 PhysicsObject z1; 27 IntMeter p1_ammo; 28 IntMeter p1_lipas; 29 30 Label lataa; 31 14 32 IntMeter killLaskuri; 15 33 IntMeter rahaLaskuri; 16 17 AssaultRifle pistol1; 18 AssaultRifle pistol2; 34 IntMeter multiplayer; 35 36 37 AssaultRifle ak1; 38 AssaultRifle ak2; 19 39 20 40 … … 25 45 //Map 26 46 Image map = LoadImage("map"); 47 Image bg = LoadImage("bg"); 27 48 //Aseet 28 49 Image miniak = LoadImage("miniak47"); … … 39 60 { 40 61 SetWindowSize(1280, 1024, false); 41 //Valikko(); 62 if (DataStorage.Exists("pisteet.xml")) topLista = DataStorage.Load<ScoreList>(topLista, "scores.xml"); 63 64 multiplayer = new IntMeter(0); 65 Valikko(); 42 66 //player1(); 43 67 //player2(); 68 69 //ZombieSpawn(); 70 71 //PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 72 } 73 void StartGame() 74 { 75 ui(); 44 76 LuoMap(); 45 Zombie();46 77 controls(); 47 ui();78 48 79 LuoKillLaskuri(); 49 80 LuoRahalaskuri(); 50 //ZombieSpawn(); 51 52 //PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 53 } 81 } 82 void Start2Game() 83 { 84 multiplayer = new IntMeter(1); 85 ui(); 86 LuoMap(); 87 controls(); 88 LuoKillLaskuri(); 89 LuoRahalaskuri(); 90 } 91 void Valikko() 92 { 93 MultiSelectWindow alkuValikko = new MultiSelectWindow("Zombie Survival","Singleplayer", "2-player", "Scores", "Exit"); 94 Add(alkuValikko); 95 alkuValikko.ItemSelected += PainettiinValikonNappia; 96 } 97 void PainettiinValikonNappia(int valinta) 98 { 99 switch (valinta) 100 { 101 case 0: 102 StartGame(); 103 break; 104 case 1: 105 Start2Game(); 106 break; 107 case 2: 108 HighScores(); 109 break; 110 case 3: 111 Exit(); 112 break; 113 } 114 } 115 54 116 void LuoMap() 55 117 { … … 59 121 ruudut.SetTileMethod(Color.Red, TeeOvi); 60 122 ruudut.SetTileMethod(Color.Blue, TeeP1); 61 ruudut.SetTileMethod(Color.Yellow, TeeP2); 123 if(multiplayer == 1) ruudut.SetTileMethod(Color.Yellow, TeeP2); 124 ruudut.SetTileMethod(Color.Green, ZombieSpawn); 62 125 ruudut.Execute(20, 20); 63 126 Level.CreateBorders(false); 127 Image lol = Image.FromGradient(2048, 2048, Color.DarkGray, Color.DarkGray); 128 Level.Background.Image = lol; 64 129 Camera.ZoomToLevel(); 65 130 … … 81 146 ovi.Shape = Shape.Rectangle; 82 147 ovi.Color = Color.Red; 148 ovi.Tag = "ovi"; 83 149 Add(ovi); 84 150 } … … 91 157 p1.Restitution = 0; 92 158 p1.Position = paikka; 159 p1.Tag = "living"; 93 160 Add(p1); 94 pistol1 = new AssaultRifle(20, 20); 95 pistol1.Image = null; 96 pistol1.Color = Color.Transparent; 97 p1.Add(pistol1); 161 ak1 = new AssaultRifle(20, 20); 162 ak1.Image = null; 163 ak1.Color = Color.Transparent; 164 ak1.ProjectileCollision = AmmusOsui; 165 ak1.Ammo.Value = p1_lipas.Value; 166 p1.Add(ak1); 98 167 } 99 168 void TeeP2(Vector paikka, double leveys, double korkeus) … … 104 173 p2.CanRotate = false; 105 174 p2.Position = paikka; 175 p2.Tag = "living"; 106 176 p2.Restitution = 0; 107 177 Add(p2); 108 pistol2 = new AssaultRifle(20, 20);109 pistol2.Image = null;110 pistol2.Color = Color.Transparent;111 p2.Add( pistol2);178 ak2 = new AssaultRifle(20, 20); 179 ak2.Image = null; 180 ak2.Color = Color.Transparent; 181 p2.Add(ak2); 112 182 } 113 183 void ZombieSpawn(Vector paikka, double leveys, double korkeus) 114 184 { 115 185 Zombi z1 = new Zombi(45, 38); 186 z1.Position = paikka; 187 FollowerBrain zombinAivot = new FollowerBrain("living"); 188 z1.Shape = Shape.Circle; 189 z1.Image = zombie_skin; 190 z1.CanRotate = false; 191 z1.Restitution = 0; 192 z1.Brain = zombinAivot; 193 AddCollisionHandler(z1, ZombieHit); 194 z1.Tag = "zombitag"; 195 Add(z1); 116 196 } 117 197 //void player1() … … 133 213 // p2.Restitution = 0; 134 214 //} 135 void Zombie()136 {137 z1 = new PhysicsObject(45, 38);138 z1.X = 150;139 z1.Shape = Shape.Circle;140 z1.Image = zombie_skin;141 z1.CanRotate = false;142 z1.Restitution = 0;143 Add(z1);215 //void Zombie() 216 //{ 217 // z1 = new PhysicsObject(45, 38); 218 // z1.X = 150; 219 // z1.Shape = Shape.Circle; 220 // z1.Image = zombie_skin; 221 // z1.CanRotate = false; 222 // z1.Restitution = 0; 223 // Add(z1); 144 224 145 }225 //} 146 226 void controls() 147 227 { … … 160 240 Keyboard.Listen(Key.D, ButtonState.Released, AsetaNopeus, null, p1, Vector.Zero); 161 241 162 Keyboard.Listen(Key.Y, ButtonState.Pressed, Shoot, null); 163 164 //Keyboard.Listen(Key.R, ButtonState.Pressed, Reload, null, p1); 242 Keyboard.Listen(Key.Space, ButtonState.Pressed, AvaaOvi, null, p1); 243 Mouse.Listen(MouseButton.Left, ButtonState.Down, Shoot, null, p1); 244 245 Keyboard.Listen(Key.R, ButtonState.Pressed, Reload, null, p1); 246 165 247 166 248 ControllerOne.Listen(Button.Start, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); … … 178 260 ControllerOne.Listen(Button.DPadRight, ButtonState.Released, AsetaNopeus, null, p2, Vector.Zero); 179 261 180 //ControllerOne.Listen(Button.A, ButtonState.Released, AvaaOvi, null); 181 ControllerOne.Listen(Button.RightShoulder, ButtonState.Down, Shoot, null); 262 ControllerOne.Listen(Button.Y, ButtonState.Pressed, AvaaOvi, null, p2); 182 263 183 264 } … … 199 280 Add(p1_hpPalkki); 200 281 282 //p1_ammo 283 p1_ammo = new IntMeter(280); 284 p1_lipas = new IntMeter(30); 285 Label p1_ammo_label = new Label(); 286 Label vali = new Label("/"); 287 Label p1_ammo_lipas = new Label(); 288 p1_ammo_lipas.BindTo(p1_lipas); 289 p1_ammo_label.BindTo(p1_ammo); 290 p1_ammo_lipas.Y = Screen.Top - 60; 291 p1_ammo_lipas.X = - 35; 292 vali.Y = Screen.Top - 60; 293 vali.X = -20; 294 p1_ammo_label.Y = Screen.Top - 60; 295 p1_ammo_label.X = 5; 296 Add(p1_ammo_lipas); 297 Add(vali); 298 Add(p1_ammo_label); 299 300 //Ase 301 GameObject aseenkuva = new GameObject(90,27); 302 aseenkuva.Image = miniak; 303 aseenkuva.Y = Screen.Top - 15; 304 aseenkuva.X = -17; 305 Add(aseenkuva); 306 if (multiplayer == 0) return; 307 201 308 //p2_hp 202 309 DoubleMeter p2_hp = new DoubleMeter(100); … … 211 318 p2_hpPalkki.BarImage = LoadImage("fullbar"); 212 319 Add(p2_hpPalkki); 213 Add(player2); 214 215 //Ase ja ammo 216 217 218 219 220 320 Add(player2); 221 321 } 222 322 … … 238 338 void LuoRahalaskuri() 239 339 { 240 rahaLaskuri = new IntMeter( 500);340 rahaLaskuri = new IntMeter(1000); 241 341 Label rahaNaytto = new Label(); 242 342 Label Money = new Label("Money:"); … … 258 358 } 259 359 player.Angle = nopeus.Angle; 260 } 261 void Shoot() 262 { 263 //ase.Shoot(); 264 ControllerOne.Vibrate(0.2, 0.2, 1, 1, 0.2); 265 } 266 void ZombieHit() 267 { 268 //LOL 360 OvenLahella(player); 361 } 362 void Shoot(PhysicsObject pelaaja) 363 { 364 if (pelaaja == p1) 365 { 366 PhysicsObject ammus = ak1.Shoot(); 367 if(ammus != null) p1_lipas.Value--; 368 } 369 } 370 void ZombieHit(PhysicsObject zombi, PhysicsObject kohde) 371 { 372 269 373 } 270 374 void LuoAikaLaskuri() … … 279 383 Add(aikaNaytto); 280 384 } 281 void Aseet() 282 { 283 // = new AssaultRifle(20, 20); 284 } 285 385 void AvaaOvi(PhysicsObject pelaaja) 386 { 387 GameObject ovi = GetObjectAt(pelaaja.Position, "ovi", 35); 388 if (ovi == null) return; 389 else if (rahaLaskuri > 149) 390 { 391 ovi.Destroy(); 392 rahaLaskuri.Value -= 150; 393 } 394 else return; 395 } 396 void OvenLahella(PhysicsObject pelaaja) 397 { 398 GameObject ovi = GetObjectAt(pelaaja.Position, "ovi", 35); 399 Label hinta; 400 Label hinta2; 401 if (ovi == null) return; 402 if (multiplayer == 0) 403 { 404 hinta = new Label("Press Space to open one block of the door."); 405 hinta2 = new Label("$150 per block"); 406 hinta.X = -20; 407 hinta2.Y = -20; 408 Add(hinta); 409 Add(hinta2); 410 } 411 else 412 { 413 hinta = new Label("Press Space or Y to open one block of the door."); 414 hinta2 = new Label("$150 per block"); 415 hinta.X = -20; 416 hinta2.Y = -20; 417 Add(hinta); 418 Add(hinta2); 419 } 420 hinta.MaximumLifetime = TimeSpan.FromSeconds(1); 421 hinta2.MaximumLifetime = TimeSpan.FromSeconds(1); 422 423 } 424 void HighScores() 425 { 426 HighScoreWindow topIkkuna = new HighScoreWindow("Parhaat pisteet", topLista); 427 topIkkuna.Closed += MeneValikkoon; 428 Add(topIkkuna); 429 430 } 431 void MeneValikkoon(Window sender) 432 { 433 Valikko(); 434 } 435 void Reload(PhysicsObject pelaaja) 436 { 437 if (p1_ammo > 29 && p1_lipas == 0) 438 { 439 p1_ammo.Value -= 30; 440 p1_lipas.Value += 30; 441 ak1.Ammo.Value = p1_lipas.Value; 442 } 443 if (p1_lipas == 0) 444 { 445 lataa = new Label("Reload"); 446 lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 447 Add(lataa); 448 449 } 450 } 451 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 452 { 453 ammus.Destroy(); 454 Explosion rajahdys = new Explosion(10); 455 rajahdys.Position = ammus.Position; 456 Add(rajahdys); 457 if (kohde.Tag == "zombitag") 458 { 459 Zombi z1 = kohde as Zombi; 460 z1.zhp.Value--; 461 } 462 463 } 286 464 } -
2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie SurvivalContent/Zombie SurvivalContent.contentproj
r3283 r3322 50 50 <Processor>TextureProcessor</Processor> 51 51 </Compile> 52 </ItemGroup>53 <ItemGroup>54 52 <Compile Include="upbar.png"> 55 53 <Name>upbar</Name> 56 <Importer>TextureImporter</Importer>57 <Processor>TextureProcessor</Processor>58 </Compile>59 </ItemGroup>60 <ItemGroup>61 <Compile Include="bg.png">62 <Name>bg</Name>63 <Importer>TextureImporter</Importer>64 <Processor>TextureProcessor</Processor>65 </Compile>66 </ItemGroup>67 <ItemGroup>68 <Compile Include="p1_alas.png">69 <Name>p1_alas</Name>70 <Importer>TextureImporter</Importer>71 <Processor>TextureProcessor</Processor>72 </Compile>73 </ItemGroup>74 <ItemGroup>75 <Compile Include="p1_vasen.png">76 <Name>p1_vasen</Name>77 <Importer>TextureImporter</Importer>78 <Processor>TextureProcessor</Processor>79 </Compile>80 <Compile Include="p1_ylos.png">81 <Name>p1_ylos</Name>82 54 <Importer>TextureImporter</Importer> 83 55 <Processor>TextureProcessor</Processor> -
2012/26/MikaL/asd/asd/asd/asd.cs
r3283 r3322 11 11 public override void Begin() 12 12 { 13 IntMeter lol = new IntMeter(1); 13 DoubleMeter lol = new DoubleMeter(1); 14 15 14 16 while (lol < 999) 15 17 { 16 ControllerOne.Vibrate(1, 1, 2, 2, 5); 17 IntMeter++; 18 MessageDisplay.Add("LOL"); 19 ControllerOne.Vibrate(1, 1, 1, 1, 1000000); 20 lol.AddValue(1); 18 21 } 19 22 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Note: See TracChangeset
for help on using the changeset viewer.