- Timestamp:
- 2013-06-14 12:53:03 (10 years ago)
- Location:
- 2013/24/AleksanteriV/Protokolla236/Protokolla236
- Files:
-
- 9 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/24/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.cs
r4133 r4168 7 7 using Jypeli.Widgets; 8 8 9 // apuva lista: | toinen pelaaja | portti kentästä toiseen ja takaisin |9 // apuva lista: 10 10 11 11 public class Protokolla236 : PhysicsGame … … 29 29 Image Block121 = LoadImage("Block121"); 30 30 private Image[] Blockanim = LoadImages("Block1.1", "Block1.2", "Block1.3", "Block1.2"); 31 private Image[] Block06anim = LoadImages("Block06", "Block061", "Block062", "Block063","Block064","Block063","Block062","Block063","Block061"); 31 32 32 33 private Image[] vihu1 = LoadImages("vihu01", "vihu02"); … … 40 41 SoundEffect raketti = LoadSoundEffect("raketti"); 41 42 List<Pelaaja> pelaajat = new List<Pelaaja>(); 43 Timer MessageDisplaynAjastin; 42 44 43 45 //AssaultRifle pelaajan1Ase; … … 55 57 public override void Begin() 56 58 { 57 59 MessageDisplay.Position += new Vector(Screen.Width / 2, 0); 60 61 MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 62 "yksinpeli tarina (1P)","selviytyminen (2P)", "Lopeta"); 63 Add(alkuValikko); 64 65 alkuValikko.AddItemHandler(0, AloitaPeli); 66 alkuValikko.AddItemHandler(1, selviytyminen); 67 alkuValikko.AddItemHandler(2, Exit); 68 MediaPlayer.Play(soitin[0]); 69 70 } 71 void AloitaPeli() 72 { 58 73 ClearAll(); 59 74 60 75 seuraavakentta(); 61 76 62 //lisaaohjaimet();63 64 65 66 MediaPlayer.Play(soitin[0]);67 77 MediaPlayer.IsRepeating = true; 68 78 … … 70 80 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null); 71 81 } 82 83 void selviytyminen() 84 { 85 MediaPlayer.Play(soitin[2]); 86 kenttaNro = 5; 87 AloitaPeli(); 88 } 89 72 90 void luokentta(string kenttakuva) 73 91 { 74 92 ColorTileMap ruudut = ColorTileMap.FromLevelAsset(kenttakuva); 75 // BD87FF93 //FFA8AC 76 94 ruudut.SetTileMethod(Color.FromHexCode("00FF00"), luopelaaja1); 77 95 ruudut.SetTileMethod(Color.FromHexCode("00FFC5"), luopelaaja2); … … 83 101 ruudut.SetTileMethod(Color.FromHexCode("D9FF93"), luotaso, (Animation)Blocklasi); 84 102 ruudut.SetTileMethod(Color.FromHexCode("FF42C0"), luotausta, new Animation(Blockanim)); 103 ruudut.SetTileMethod(Color.FromHexCode("B7FF9E"), luotausta, new Animation(Block06anim)); 85 104 ruudut.SetTileMethod(Color.FromHexCode("42B9FF"), luotausta, (Animation)BlockMusta); 86 105 ruudut.SetTileMethod(Color.FromHexCode("00FF90"), luotausta, (Animation)Block021); … … 91 110 ruudut.SetTileMethod(Color.FromHexCode("A860FF"), luoportti, new Animation(porttianim)); 92 111 ruudut.SetTileMethod(Color.FromHexCode("BD87FF"), luoportti2, new Animation(porttianim)); 112 ruudut.SetTileMethod(Color.FromHexCode("6DFF81"), luoportti3, new Animation(porttianim)); 113 ruudut.SetTileMethod(Color.FromHexCode("FFA8AC"), luoportti4, new Animation(porttianim)); 93 114 ruudut.Execute(50, 50); 94 115 95 116 Gravity = new Vector(0.0, -200.0); 96 117 Level.CreateBorders(0.5, true); 118 97 119 Camera.Follow(pelaajat.ToArray()); 98 120 } 121 122 123 99 124 void seuraavakentta() 100 125 { 101 126 ClearAll(); 102 103 if (kenttaNro == 1) luokentta("kentta121"); 104 else if (kenttaNro == 2) luokentta("kentta3"); 105 else if (kenttaNro == 3) luokentta("kenttatest03"); 106 else if (kenttaNro == 4) luokentta("kentta4"); 127 pelaajat.Clear(); 128 129 if (kenttaNro == 1) luokentta("kenttatest01"); 130 else if (kenttaNro == 2) luokentta("kenttatest11"); 131 else if (kenttaNro == 3) luokentta("kentta3"); 132 else if (kenttaNro == 4) luokentta("kentta5"); 107 133 else if (kenttaNro == 5) luokentta("kentta121"); 108 else if (kenttaNro > 5) Exit();134 else if (kenttaNro == 6) luokentta("kentta1"); 109 135 110 136 } … … 129 155 portti2.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 130 156 } 131 157 void luoportti3(Vector paikka, double leveys, double korkeus, Animation kuva) 158 { 159 PhysicsObject portti3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 160 portti3.Position = paikka; 161 portti3.Tag = "portti3"; 162 Add(portti3); 163 portti3.Animation = kuva; 164 portti3.Animation.Start(); 165 portti3.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 166 } 167 void luoportti4(Vector paikka, double leveys, double korkeus, Animation kuva) 168 { 169 PhysicsObject portti3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 170 portti3.Position = paikka; 171 portti3.Tag = "portti4"; 172 Add(portti3); 173 portti3.Animation = kuva; 174 portti3.Animation.Start(); 175 portti3.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 176 } 132 177 133 178 134 179 void portti(PhysicsObject pelaaja, PhysicsObject portti) 135 180 { 136 if (portti.Tag.Equals("portti 2"))137 { 138 kenttaNro = 3;181 if (portti.Tag.Equals("portti4")) 182 { 183 kenttaNro = 6; 139 184 seuraavakentta(); 140 185 } 141 else kenttaNro = 2; 186 187 else if (portti.Tag.Equals("portti3")) 188 { 189 kenttaNro = 4; 190 seuraavakentta(); 191 } 192 else if (portti.Tag.Equals("portti2")) 193 { 194 kenttaNro = 2; 195 seuraavakentta(); 196 } 197 else kenttaNro = 3; 142 198 seuraavakentta(); 143 199 … … 187 243 } 188 244 245 void TekstiaDisplaylle(string tekst) 246 { 247 MessageDisplay.Add(tekst); 248 MessageDisplaynAjastin = new Timer(); 249 MessageDisplaynAjastin.Timeout += delegate { MessageDisplay.Clear(); }; 250 MessageDisplaynAjastin.Interval = 5; 251 MessageDisplaynAjastin.Start(1); 252 } 253 254 189 255 void ElamaLoppui() 190 256 { 191 foreach (var item in pelaajat)192 {193 item.Destroy();194 }195 257 pelaajat.Clear(); 196 if (pelaajat.Count > 1) 197 { 198 seuraavakentta(); 199 } 200 MessageDisplay.Add("Kuolit!"); 258 259 TekstiaDisplaylle("Kuolit!"); 260 201 261 kenttaNro = 1; 202 262 seuraavakentta(); … … 204 264 205 265 266 void ElamaLoppuiSurvivalissa() 267 { 268 foreach (var item in pelaajat) 269 { 270 if (!item.IsDestroyed) 271 item.Destroy(); 272 } 273 pelaajat.Clear(); 274 TekstiaDisplaylle("Kuolitte!"); 275 seuraavakentta(); 276 277 278 } 279 280 206 281 Pelaaja alustaPelaaja(Vector paikka) 207 282 { 208 283 Pelaaja pelaaja = new Pelaaja(50, 50); 209 pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppui(); }; 284 if(kenttaNro == 5) 285 pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppuiSurvivalissa(); }; 286 else pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppui(); }; 210 287 pelaaja.Position = paikka; 211 288 pelaaja.CanRotate = false; … … 224 301 AddCollisionHandler(pelaaja, "portti", portti); 225 302 AddCollisionHandler(pelaaja, "portti2", portti); 303 AddCollisionHandler(pelaaja, "portti3", portti); 304 AddCollisionHandler(pelaaja, "portti4", portti); 226 305 AddCollisionHandler(pelaaja, "vihu", PelaajaOsuu); 227 306 AddCollisionHandler(pelaaja, "sikio", PelaajaOsuu); … … 286 365 Pelaaja pelaaja = luoPelaaja(paikka, leveys, korkeus); 287 366 LuoElamaLaskuri(pelaaja, Screen.Right - 150, Screen.Top - 20, Color.Blue); 288 //pelaaja.Image = LoadImage("pelaaja2.0");367 pelaaja.Image = LoadImage("pelaaja2.0"); 289 368 //-2-2-2-2-2-2-2--22-2-2-2-2-22-2-22-2-22-22-2-22-22--22-22-2-2-2-2-2-2-22-22-2---------- 290 369 Keyboard.Listen(Key.A, ButtonState.Down, kaannaPelaajaa, null, 5.0, pelaaja); 291 370 Keyboard.Listen(Key.D, ButtonState.Down, kaannaPelaajaa, null, -5.0, pelaaja); 292 371 Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, null, 900.0, pelaaja); 293 Keyboard.Listen(Key. Q, ButtonState.Down, AmmuAseella, null, pelaaja.Ase);372 Keyboard.Listen(Key.LeftControl, ButtonState.Down, AmmuAseella, null, pelaaja.Ase); 294 373 295 374 //----------------------------------------------------------------- … … 367 446 vihu.AngularDamping = 0.1; 368 447 vihu.IgnoresGravity = true; 448 369 449 370 450 Add(vihu, 1); -
2013/24/AleksanteriV/Protokolla236/Protokolla236/Protokolla236Content/Protokolla236Content.contentproj
r4133 r4168 447 447 </Compile> 448 448 </ItemGroup> 449 <ItemGroup> 450 <Compile Include="pelaaja2.0.png"> 451 <Name>pelaaja2.0</Name> 452 <Importer>TextureImporter</Importer> 453 <Processor>TextureProcessor</Processor> 454 </Compile> 455 </ItemGroup> 456 <ItemGroup> 457 <Compile Include="Block06.png"> 458 <Name>Block06</Name> 459 <Importer>TextureImporter</Importer> 460 <Processor>TextureProcessor</Processor> 461 </Compile> 462 <Compile Include="Block061.png"> 463 <Name>Block061</Name> 464 <Importer>TextureImporter</Importer> 465 <Processor>TextureProcessor</Processor> 466 </Compile> 467 <Compile Include="Block062.png"> 468 <Name>Block062</Name> 469 <Importer>TextureImporter</Importer> 470 <Processor>TextureProcessor</Processor> 471 </Compile> 472 <Compile Include="Block063.png"> 473 <Name>Block063</Name> 474 <Importer>TextureImporter</Importer> 475 <Processor>TextureProcessor</Processor> 476 </Compile> 477 <Compile Include="Block064.png"> 478 <Name>Block064</Name> 479 <Importer>TextureImporter</Importer> 480 <Processor>TextureProcessor</Processor> 481 </Compile> 482 </ItemGroup> 483 <ItemGroup> 484 <Compile Include="kenttatest11.png"> 485 <Name>kenttatest11</Name> 486 <Importer>TextureImporter</Importer> 487 <Processor>TextureProcessor</Processor> 488 </Compile> 489 </ItemGroup> 490 <ItemGroup> 491 <Compile Include="kentta5.png"> 492 <Name>kentta5</Name> 493 <Importer>TextureImporter</Importer> 494 <Processor>TextureProcessor</Processor> 495 </Compile> 496 </ItemGroup> 497 <ItemGroup> 498 <Compile Include="kentta5000.png"> 499 <Name>kentta5000</Name> 500 <Importer>TextureImporter</Importer> 501 <Processor>TextureProcessor</Processor> 502 </Compile> 503 </ItemGroup> 449 504 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 450 505 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.