- Timestamp:
- 2015-06-04 23:21:37 (8 years ago)
- Location:
- 2015/23/HenriK/dungeoncrawlar/dungeoncrawlar
- Files:
-
- 22 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/23/HenriK/dungeoncrawlar/dungeoncrawlar/dungeoncrawlar/dungeoncrawlar.cs
r5865 r5872 6 6 using Jypeli.Effects; 7 7 using Jypeli.Widgets; 8 class Pelihahmo : PhysicsObject 9 { 10 private IntMeter elamaLaskuri; 11 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 12 13 public Pelihahmo(double leveys, double korkeus, int elämät) 14 : base(leveys, korkeus) 15 { 16 elamaLaskuri = new IntMeter(elämät, 0, elämät); 17 18 } 19 } 8 20 9 21 public class dungeoncrawlar : PhysicsGame 10 22 { 11 23 PhysicsObject ovi; 12 P hysicsObjectplayer;24 Pelihahmo player; 13 25 PhysicsObject ammus; 26 PhysicsObject miekka; 14 27 PhysicsObject avain; 15 PhysicsObject vihollinen; 28 PhysicsObject l96wallbuy; 29 PhysicsObject wallbuymp5; 30 PhysicsObject m1911; 31 PhysicsObject thecharacterpistol; 16 32 PhysicsObject ase96; 33 PhysicsObject staminup; 17 34 18 35 Listener aseNyt; 36 Image[] lattiatext = LoadImages("blackwhitegorund bloody1", "blackwhitegorund bloody2", "blackwhitegorund"); 37 38 Image[] ruumisvihu = LoadImages("zombi1","zombi2","zombi3", "zombi4", "zombi5", "zombi6", "zombi7"); 19 39 20 40 int avaintenLkm; 21 41 int l96 = 0; 22 int kilpi; 23 24 //Surface alaReuna, vasenReuna, oikeaReuna, yläReuna; 25 26 //PhysicsObject alaReuna, vasenReuna, oikeaReuna, yläReuna; 42 int kilpi = 0; 43 44 45 27 46 28 47 public override void Begin() 29 48 { 30 49 SmoothTextures = false; 31 50 luohuone(1); 32 51 … … 54 73 void PoimiAse(PhysicsObject tormaaja, PhysicsObject tormatty) 55 74 { 56 ase96.Destroy();75 57 76 l96 += 1; 58 77 aseet(); 59 78 } 79 void luoruumis(Vector paikka,Image kuva) 80 { 81 GameObject ruumis = new GameObject(60*1.5, 60*1.5); 82 ruumis.Image = kuva; 83 ruumis.Position = paikka; 84 Add(ruumis, -1); 85 ruumis.MaximumLifetime = TimeSpan.FromSeconds(200); 86 ruumis.Animation = new Animation(ruumisvihu); 87 ruumis.Animation.FPS = 7; 88 ruumis.Animation.Start(); 89 } 60 90 void Vihu(Vector paikka, double leveys, double korkeus) 61 91 { 62 PhysicsObject vihu = new PhysicsObject(20, 20); 63 vihu.Position = RandomGen.NextVector(0, 500); 92 arvotext(paikka, leveys, korkeus); 93 Pelihahmo vihu = new Pelihahmo(50, 50, 20); 94 vihu.Position = paikka; 64 95 vihu.LinearDamping = 0.5; 65 96 Add(vihu); 66 Image c = LoadImage("morko"); 97 98 99 Image c = LoadImage("zombi"); 67 100 vihu.Shape = Shape.FromImage(c); 68 101 vihu.Image = c; 102 vihu.ElamaLaskuri.LowerLimit += delegate 103 104 { 105 vihu.Destroy(); 106 luoruumis(vihu.Position, ruumisvihu[0]); 107 }; 69 108 70 109 FollowerBrain aivo = new FollowerBrain(player); 71 aivo.Speed = 300;110 aivo.Speed = 200; 72 111 vihu.Brain = aivo; 112 vihu.Tag = "vihu"; 113 aivo.TurnWhileMoving = true; 114 AddCollisionHandler(vihu, "player", vahinko); 73 115 74 116 Timer ajastin = new Timer(); … … 112 154 Keyboard.Listen(Key.D2, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 2); 113 155 Keyboard.Listen(Key.D3, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 3); 156 Keyboard.Listen(Key.D4, ButtonState.Pressed, aseenVaihto, "aseen vaihto", 4); 157 114 158 115 159 … … 133 177 aseNyt = Mouse.Listen(MouseButton.Left, ButtonState.Down, block, "pum pum"); 134 178 break; 179 case 4: 180 aseNyt = Mouse.Listen(MouseButton.Left, ButtonState.Pressed, ammupistol, "pum pum"); 181 break; 135 182 } 136 183 } … … 161 208 player.Image = c; 162 209 163 ammus = new PhysicsObject(100.0, 10.0); 164 ammus.Shape = Shape.Circle; 165 ammus.Color = Color.Gray; 166 ammus.Position = player.Position; 167 ammus.CollisionIgnoreGroup = 1; 168 ammus.Angle = player.Angle; 169 Add(ammus); 170 Vector impulssi = Vector.FromLengthAndAngle(500, player.Angle); 171 ammus.Hit(impulssi); 172 ammus.MaximumLifetime = new TimeSpan(2000000); 210 miekka = new PhysicsObject(50.0, 5.0); 211 miekka.Shape = Shape.Circle; 212 miekka.Color = Color.Gray; 213 Image y = LoadImage("sword"); 214 miekka.Image = y; 215 miekka.Position = player.Position + (player.Angle + Angle.FromDegrees(90)).GetVector()*-20 + player.Angle.GetVector()*10; 216 miekka.CollisionIgnoreGroup = 1; 217 miekka.Angle = player.Angle + Angle.FromDegrees(45); 218 219 Add(miekka); 220 Vector impulssi = Vector.FromLengthAndAngle(50, player.Angle + Angle.FromDegrees(45)); 221 miekka.Hit(impulssi); 222 miekka.MaximumLifetime = new TimeSpan(2000000); 223 AddCollisionHandler(miekka, "vihu", vahinko); 173 224 174 225 } … … 181 232 182 233 234 235 ammus = new PhysicsObject(5.0, 5.0); 236 ammus.Shape = Shape.Circle; 237 ammus.Color = Color.Gold; 238 ammus.Position = player.Position; 239 ammus.CollisionIgnoreGroup = 1; 240 Image d = LoadImage("bullet"); 241 ammus.Shape = Shape.FromImage(d); 242 ammus.Image = d; 243 ammus.Angle = player.Angle; 244 ammus.Tag = "ammus"; 245 Add(ammus); 246 247 Vector impulssi = Vector.FromLengthAndAngle(2500, player.Angle); 248 ammus.Hit(impulssi); 249 ammus.MaximumLifetime = new TimeSpan(20000000); 250 251 AddCollisionHandler(ammus, "vihu", vahinko); 252 253 } 254 void ammupistol() 255 { 256 257 Image i = LoadImage("thecharacterpistol"); 258 player.Shape = Shape.FromImage(i); 259 player.Image = i; 260 261 183 262 184 263 ammus = new PhysicsObject(10.0, 10.0); … … 197 276 ammus.Hit(impulssi); 198 277 ammus.MaximumLifetime = new TimeSpan(20000000); 199 200 } 201 202 278 AddCollisionHandler(ammus, "vihu", vahinko); 279 280 } 281 void vahinko(PhysicsObject ammus,PhysicsObject vihu ) 282 { 283 Pelihahmo hahmo = vihu as Pelihahmo; 284 if(hahmo != null) 285 { 286 hahmo.ElamaLaskuri.Value -= 10; 287 } 288 289 } 290 203 291 void luohuone(int huoneNumero) 204 292 { 205 Window.Width = 1350;206 Window.Height = 8 50;293 Window.Width = 800; 294 Window.Height = 800; 207 295 Camera.Zoom(0.5); 208 Image b = LoadImage("blackwhitegorund"); 209 210 211 212 213 TileMap ruudut = TileMap.FromLevelAsset("mapeasy lol"); 214 296 297 298 //Level.Background.Image = lattiatext[0]; 299 //Level.Background.TileToLevel(); 300 301 302 303 304 TileMap ruudut = TileMap.FromLevelAsset("huone" + huoneNumero); 305 TileMap ruudut2 = TileMap.FromLevelAsset("huone" + huoneNumero); 306 307 308 309 310 //3. Execute luo kentän 311 // Parametreina leveys ja korkeus 312 215 313 216 314 ruudut.SetTileMethod('p', LuoPelaaja); 217 315 ruudut.SetTileMethod('w', LuoTaso); 218 ruudut.SetTileMethod('h', LuoOvi, Angle.FromDegrees(0));219 ruudut.SetTileMethod('u', LuoOvi, Angle.FromDegrees(90));220 316 ruudut.SetTileMethod('k', LuoOvi, Angle.FromDegrees(180)); 221 ruudut.SetTileMethod('m', LuoOvi, Angle.FromDegrees(270)); 317 ruudut.SetTileMethod('u', LuoOvi, Angle.FromDegrees(180)); 318 ruudut.SetTileMethod('h', LuoOvi, Angle.FromDegrees(180)); 319 ruudut.SetTileMethod('m', LuoOvi, Angle.FromDegrees(180)); 222 320 ruudut.SetTileMethod('r', luoAvain); 223 321 ruudut.SetTileMethod('t', LuoL96wallbuy); 322 ruudut.SetTileMethod('y', luowallbuymp5); 323 //ruudut.SetTileMethod('i', luom1911); 324 ruudut.SetTileMethod('s', Staminup); 325 ruudut.SetTileMethod('_', arvotext); 326 224 327 ruudut.SetTileMethod('a', LuoAse96); 225 226 //3. Execute luo kentän 227 // Parametreina leveys ja korkeus 328 ruudut2.SetTileMethod('v', Vihu); 228 329 ruudut.Execute(64, 64); 229 230 TileMap ruudut2 = TileMap.FromLevelAsset("mapeasy lol");231 ruudut2.SetTileMethod('v', Vihu);232 330 ruudut2.Execute(64, 64); 233 Level.Background.Image = b;234 Level.Background.TileToLevel();235 331 Random r = new Random(345356346); 332 r.NextDouble(); 333 r.NextDouble(); 236 334 237 335 Camera.StayInLevel = true; … … 262 360 263 361 } 362 363 void arvotext(Vector paikka, double leveys, double korkeus) 364 { 365 GameObject taso = new GameObject(leveys, korkeus); 366 taso.Position = paikka; 367 //taso.CollisionIgnoreGroup = 1; 368 if (RandomGen.NextDouble(0, 100) < 95) 369 { 370 taso.Image = lattiatext[2]; 371 } 372 else 373 { 374 int x = RandomGen.NextInt(2); 375 taso.Image = lattiatext[x]; 376 } 377 378 379 380 381 382 Add(taso, -2); 383 } 264 384 void LuoTaso(Vector paikka, double leveys, double korkeus) 265 385 { … … 275 395 void luoAvain(Vector paikka, double leveys, double korkeus) 276 396 { 397 arvotext(paikka, leveys, korkeus); 277 398 if (RandomGen.NextDouble(0, 100) < 80) 278 399 { … … 292 413 void OvenAvaus(PhysicsObject tormaaja, PhysicsObject ovi) 293 414 { 294 if ( avaintenLkm >= 1)415 if (Keyboard.GetKeyState(Key.E)==ButtonState.Down) 295 416 { 296 417 ClearAll(); 297 luohuone( 1);418 luohuone(2); 298 419 299 420 … … 302 423 void LuoPelaaja(Vector paikka, double leveys, double korkeus) 303 424 { 304 player = new PhysicsObject(50, 50); 425 arvotext(paikka, leveys, korkeus); 426 player = new Pelihahmo(45, 50, 10); 305 427 Image c = LoadImage("thecharacter"); 306 428 player.Shape = Shape.FromImage(c); 307 429 player.Image = c; 430 player.ElamaLaskuri.LowerLimit += delegate 431 { 432 player.Destroy(); 433 luoruumis(player.Position, ruumisvihu[0]); 434 }; 308 435 309 436 //player. … … 312 439 player.LinearDamping = 0.6; 313 440 player.AngularDamping = 0.6; 441 player.CollisionIgnoreGroup = 1; 314 442 315 443 player.MaxAngularVelocity = 8000.0; … … 317 445 player.Mass = 1; 318 446 Add(player); 447 player.Tag="player"; 319 448 AddCollisionHandler(player, "avain", AvaintenKerays); 320 449 AddCollisionHandler(player, "ovi", OvenAvaus); 321 AddCollisionHandler(player, "ase96", PoimiAse); 450 AddCollisionHandler(player, "l96wallbuy", PoimiAse); 451 452 453 454 455 322 456 323 457 //player.CollisionIgnoreGroup = 1; … … 370 504 371 505 } 506 void LuoL96wallbuy(Vector paikka, double leveys, double korkeus) 507 { 508 PhysicsObject l96wallbuy = PhysicsObject.CreateStaticObject(leveys, korkeus); 509 l96wallbuy.Position = paikka; 510 Image t = LoadImage("l96wallbuy"); 511 512 l96wallbuy.Image = t; 513 l96wallbuy.Tag = "l96wallbuy"; 514 515 516 517 Add(l96wallbuy); 518 519 520 521 } 522 void luowallbuymp5(Vector paikka, double leveys, double korkeus) 523 { 524 PhysicsObject wallbuymp5 = PhysicsObject.CreateStaticObject(leveys, korkeus); 525 wallbuymp5.Position = paikka; 526 Image y = LoadImage("wallbuymp5"); 527 528 wallbuymp5.Image = y; 529 wallbuymp5.Tag = "wallbuymp5"; 530 531 532 533 Add(wallbuymp5); 534 535 536 } 537 void Staminup(Vector paikka, double leveys, double korkeus) 538 { 539 arvotext(paikka, leveys, korkeus); 540 PhysicsObject staminup = PhysicsObject.CreateStaticObject(leveys, korkeus); 541 staminup.Position = paikka; 542 Image s = LoadImage("staminup"); 543 544 staminup.Image = s; 545 staminup.Tag = "staminup"; 546 547 548 Add(staminup); 549 550 551 } 372 552 373 553 } -
2015/23/HenriK/dungeoncrawlar/dungeoncrawlar/dungeoncrawlarContent/dungeoncrawlarContent.contentproj
r5865 r5872 95 95 </ItemGroup> 96 96 <ItemGroup> 97 <Compile Include=" mapeasy lol.txt">98 <Name> mapeasy lol</Name>97 <Compile Include="huone1.txt"> 98 <Name>huone1</Name> 99 99 <Importer>TextFileImporter</Importer> 100 100 <Processor>TextFileContentProcessor</Processor> … … 139 139 <Compile Include="raygun.png"> 140 140 <Name>raygun</Name> 141 <Importer>TextureImporter</Importer> 142 <Processor>TextureProcessor</Processor> 143 </Compile> 144 </ItemGroup> 145 <ItemGroup> 146 <Compile Include="zombi.png"> 147 <Name>zombi</Name> 148 <Importer>TextureImporter</Importer> 149 <Processor>TextureProcessor</Processor> 150 </Compile> 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="Untitled.png"> 154 <Name>Untitled</Name> 155 <Importer>TextureImporter</Importer> 156 <Processor>TextureProcessor</Processor> 157 </Compile> 158 </ItemGroup> 159 <ItemGroup> 160 <Compile Include="zombi1.png"> 161 <Name>zombi1</Name> 162 <Importer>TextureImporter</Importer> 163 <Processor>TextureProcessor</Processor> 164 </Compile> 165 <Compile Include="zombi2.png"> 166 <Name>zombi2</Name> 167 <Importer>TextureImporter</Importer> 168 <Processor>TextureProcessor</Processor> 169 </Compile> 170 <Compile Include="zombi3.png"> 171 <Name>zombi3</Name> 172 <Importer>TextureImporter</Importer> 173 <Processor>TextureProcessor</Processor> 174 </Compile> 175 <Compile Include="zombi4.png"> 176 <Name>zombi4</Name> 177 <Importer>TextureImporter</Importer> 178 <Processor>TextureProcessor</Processor> 179 </Compile> 180 <Compile Include="zombi5.png"> 181 <Name>zombi5</Name> 182 <Importer>TextureImporter</Importer> 183 <Processor>TextureProcessor</Processor> 184 </Compile> 185 <Compile Include="zombi6.png"> 186 <Name>zombi6</Name> 187 <Importer>TextureImporter</Importer> 188 <Processor>TextureProcessor</Processor> 189 </Compile> 190 <Compile Include="zombi7.png"> 191 <Name>zombi7</Name> 192 <Importer>TextureImporter</Importer> 193 <Processor>TextureProcessor</Processor> 194 </Compile> 195 </ItemGroup> 196 <ItemGroup> 197 <Compile Include="sword.png"> 198 <Name>sword</Name> 199 <Importer>TextureImporter</Importer> 200 <Processor>TextureProcessor</Processor> 201 </Compile> 202 </ItemGroup> 203 <ItemGroup> 204 <Compile Include="thecharacterpistol.png"> 205 <Name>thecharacterpistol</Name> 206 <Importer>TextureImporter</Importer> 207 <Processor>TextureProcessor</Processor> 208 </Compile> 209 </ItemGroup> 210 <ItemGroup> 211 <Compile Include="playertwo.png"> 212 <Name>playertwo</Name> 213 <Importer>TextureImporter</Importer> 214 <Processor>TextureProcessor</Processor> 215 </Compile> 216 <Compile Include="wallbuyassaultrifle.png"> 217 <Name>wallbuyassaultrifle</Name> 218 <Importer>TextureImporter</Importer> 219 <Processor>TextureProcessor</Processor> 220 </Compile> 221 <Compile Include="wallbuymp5.png"> 222 <Name>wallbuymp5</Name> 223 <Importer>TextureImporter</Importer> 224 <Processor>TextureProcessor</Processor> 225 </Compile> 226 <Compile Include="wallbuyshotgun.png"> 227 <Name>wallbuyshotgun</Name> 228 <Importer>TextureImporter</Importer> 229 <Processor>TextureProcessor</Processor> 230 </Compile> 231 </ItemGroup> 232 <ItemGroup> 233 <Compile Include="l96wallbuy.png"> 234 <Name>l96wallbuy</Name> 235 <Importer>TextureImporter</Importer> 236 <Processor>TextureProcessor</Processor> 237 </Compile> 238 </ItemGroup> 239 <ItemGroup> 240 <Compile Include="staminup.png"> 241 <Name>staminup</Name> 242 <Importer>TextureImporter</Importer> 243 <Processor>TextureProcessor</Processor> 244 </Compile> 245 </ItemGroup> 246 <ItemGroup> 247 <Compile Include="m1911.png"> 248 <Name>m1911</Name> 249 <Importer>TextureImporter</Importer> 250 <Processor>TextureProcessor</Processor> 251 </Compile> 252 </ItemGroup> 253 <ItemGroup> 254 <Compile Include="huone2.txt"> 255 <Name>huone2</Name> 256 <Importer>TextFileImporter</Importer> 257 <Processor>TextFileContentProcessor</Processor> 258 </Compile> 259 </ItemGroup> 260 <ItemGroup> 261 <Compile Include="blackwhitegorund bloody1.png"> 262 <Name>blackwhitegorund bloody1</Name> 263 <Importer>TextureImporter</Importer> 264 <Processor>TextureProcessor</Processor> 265 </Compile> 266 <Compile Include="blackwhitegorund bloody2.png"> 267 <Name>blackwhitegorund bloody2</Name> 141 268 <Importer>TextureImporter</Importer> 142 269 <Processor>TextureProcessor</Processor>
Note: See TracChangeset
for help on using the changeset viewer.