- Timestamp:
- 2015-07-24 12:21:39 (8 years ago)
- Location:
- 2015/30/SamuelL
- Files:
-
- 8 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/30/SamuelL/jotain/jotain/jotain/jotain.cs
r6995 r7029 16 16 AssaultRifle ase1; 17 17 bool ase1Flipattu = false; 18 bool otettuOsumaa = false; 19 IntMeter helat; 18 20 19 21 Image pelaajanKuva = LoadImage("pelaajakuva"); … … 33 35 Image Asekuva = LoadImage("GUN"); 34 36 Image Tähtäin = LoadImage("tähtäin"); 37 Image[] Hirviökuvat = LoadImages("hirviö1", "hirviö2"); 38 Image alienpesä = LoadImage("pesä"); 35 39 36 40 int kenttänumero = 1; … … 41 45 SoundEffect TuliPalo = LoadSoundEffect("tuli"); 42 46 SoundEffect pistolshot = LoadSoundEffect("PistolShot"); 47 SoundEffect spooky = LoadSoundEffect("spooky"); 48 SoundEffect alien = LoadSoundEffect("aline"); 43 49 44 50 public override void Begin() … … 50 56 void LuoKentta() 51 57 { 58 ase1Flipattu = false; 52 59 TileMap kentta = TileMap.FromLevelAsset("kentta" + kenttänumero); 53 60 kentta.SetTileMethod('#', LisaaTaso); … … 62 69 kentta.SetTileMethod('o', Lisaakivi, pienikivi, -1); 63 70 kentta.SetTileMethod('p', Lisaapuu, puu, 1); 71 kentta.SetTileMethod('L', Lisaapesä); 64 72 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 65 73 kentta.Optimize('#'); … … 118 126 Add(tahti); 119 127 } 128 void OtaOsumaa(PhysicsObject a, PhysicsObject b) 129 { 130 if (!otettuOsumaa) 131 { 132 helat.Value--; 133 otettuOsumaa = true; 134 } 135 Timer.SingleShot(3, delegate { otettuOsumaa = false; }); 136 } 120 137 121 138 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) … … 126 143 pelaaja1.Image = pelaajanKuva; 127 144 pelaaja1.Tag = "pelaaja1"; 145 pelaaja1.CollisionIgnoreGroup = 3; 128 146 pelaaja1.AnimWalk = kävely; 129 147 pelaaja1.AnimIdle = new Animation(pelaajanKuva); … … 132 150 Add(pelaaja1); 133 151 AddCollisionHandler(pelaaja1, "vaihto", tormaavaihtoon); 152 AddCollisionHandler(pelaaja1, "hirviö", OtaOsumaa); 153 154 helat = new IntMeter(5, 0, 5); 155 helat.LowerLimit += delegate 156 { 157 kenttänumero = 1; 158 AloitaKentta(); 159 }; 160 161 ProgressBar elamaPalkki = new ProgressBar(50, 10); 162 elamaPalkki.Y = 50; 163 elamaPalkki.BindTo(helat); 164 pelaaja1.Add(elamaPalkki); 165 134 166 135 167 GameObject pimeys = new GameObject(2700, 2700); … … 148 180 ase1.Image = Asekuva; 149 181 ase1.Size *= 0.1; 150 ase1.Power.Value = 2000; 151 ase1.FireRate = 2.0; 182 ase1.FireRate = 2.5; 152 183 ase1.Tag = "ase"; 153 184 ase1.AttackSound = pistolshot; 154 155 156 157 185 158 186 Add(ase1); … … 275 303 void AloitaKentta() 276 304 { 277 ClearAll(); 305 ClearAll(); 278 306 kävely = LoadAnimation("pelaaja"); 279 307 Gravity = new Vector(0, -1000); … … 294 322 { 295 323 MediaPlayer.Stop(); 324 MediaPlayer.Play("spooky"); 325 MediaPlayer.IsRepeating = true; 296 326 } 297 327 } … … 324 354 { 325 355 PhysicsObject ammus = ase1.Shoot(); 356 Vector ampumispaikka = ase1.AbsolutePosition; 326 357 327 358 if (ammus != null) 328 359 { 360 ammus.Size *= 1.0; 361 ammus.Image = null; 362 ammus.Color = Color.Black; 363 ammus.Shape = Shape.Rectangle; 364 ammus.Position += ase1.AbsoluteAngle.GetVector() * 20; 329 365 ammus.MaximumLifetime = TimeSpan.FromSeconds(5); 366 ammus.Tag = "ammus"; 330 367 331 AddCollisionHandler(ammus, "taso", delegate(PhysicsObject a, PhysicsObject b) 368 Timer ajastin = new Timer(); 369 ajastin.Interval = 0.01; 370 ajastin.Timeout += delegate 332 371 { 333 ammus.Destroy(); 372 GameObject vana = new GameObject(ammus.Width * 1.7, ammus.Height * 0.4); 373 vana.Angle = (ammus.Position - ampumispaikka).Angle; 374 vana.Color = Color.Black; //new Color(0, 0, 0, 128); 375 vana.Position = ammus.Position; 376 vana.FadeColorTo(Color.Transparent, 0.5); 377 vana.LifetimeLeft = TimeSpan.FromSeconds(0.5); 378 Add(vana); 379 }; 380 ajastin.Start(); 381 382 AddCollisionHandler(ammus, delegate(PhysicsObject a, PhysicsObject b) 383 { 384 ammus.Destroy(); 385 ajastin.Stop(); 334 386 }); 335 387 } 336 388 } 389 void Lisaapesä(Vector paikka, double leveys, double korkeus) 390 { 391 PhysicsObject pesä = PhysicsObject.CreateStaticObject(leveys*2, korkeus*1.5); 392 pesä.Position = paikka; 393 pesä.IsVisible = true; 394 pesä.Y -= korkeus*0.2; 395 pesä.Tag = "pesä"; 396 pesä.IgnoresCollisionResponse = true; 397 Add(pesä); 398 pesä.Color = Color.Emerald; 399 pesä.Image = alienpesä; 400 401 Timer ajastin = new Timer(); 402 ajastin.Interval = 8; 403 ajastin.Timeout += delegate 404 { 405 Lisäähirviö(paikka,leveys,korkeus); 406 }; 407 ajastin.Start(); 408 409 IntMeter elämät = new IntMeter(12); 410 AddCollisionHandler(pesä, "ammus", delegate(PhysicsObject a, PhysicsObject b) 411 { 412 elämät.Value--; 413 }); 414 elämät.LowerLimit += delegate 415 { 416 pesä.Destroy(); 417 ajastin.Stop(); 418 LisaaEfekti(pesä.Position); 419 }; 420 } 421 422 void Lisäähirviö(Vector paikka, double leveys, double korkeus) 423 { 424 PhysicsObject hirviö = new PhysicsObject(leveys, korkeus); 425 hirviö.Animation = new Animation(Hirviökuvat); 426 hirviö.Animation.Start(); 427 hirviö.Position = paikka; 428 hirviö.CanRotate = false; 429 hirviö.Tag = "hirviö"; 430 Add(hirviö); 431 432 RandomMoverBrain satunnaisAivot = new RandomMoverBrain(100); 433 satunnaisAivot.WanderRadius = 200; 434 FollowerBrain seuraajanAivot = new FollowerBrain("pelaaja1"); 435 seuraajanAivot.Speed = 80; // Millä nopeudella kohdetta seurataan 436 seuraajanAivot.DistanceFar = 270; // Etäisyys jolla aletaan seurata kohdetta 437 seuraajanAivot.FarBrain = satunnaisAivot; 438 hirviö.Brain = seuraajanAivot; 439 440 IntMeter elämät = new IntMeter(3); 441 AddCollisionHandler(hirviö, "ammus", delegate(PhysicsObject a, PhysicsObject b) 442 { 443 elämät.Value--; 444 }); 445 elämät.LowerLimit += delegate 446 { 447 hirviö.Destroy(); 448 LisaaEfekti(hirviö.Position); 449 MediaPlayer.Play("alien"); 450 MediaPlayer.IsRepeating = false; 451 }; 452 } 453 454 void LisaaEfekti(Vector paikka) 455 { 456 for (int i = 0; i < 10; i++) 457 { 458 PhysicsObject pala = new PhysicsObject(10, 10); 459 //pala.Image = ... 460 pala.Color = Color.DarkGreen; 461 pala.FadeColorTo(Color.Transparent, 1.0); 462 pala.LifetimeLeft = TimeSpan.FromSeconds(1.0); 463 pala.CollisionIgnoreGroup = 3; 464 pala.Position = paikka; 465 pala.Hit(RandomGen.NextVector(50, 200)); 466 Add(pala); 467 } 468 } 337 469 338 470 } -
2015/30/SamuelL/jotain/jotain/jotain/jotain.csproj.Debug.cachefile
r6995 r7029 9 9 Content\kÀvely loulassa.xnb 10 10 Content\kÀvely ruohossa.xnb 11 Content\spooky.xnb12 11 Content\tulikuva.xnb 13 12 Content\kentta2.xnb … … 36 35 Content\tÀhtÀin.xnb 37 36 Content\PistolShot.xnb 37 Content\hirviö1.xnb 38 Content\hirviö2.xnb 39 Content\spooky.xnb 40 Content\alien.xnb 41 Content\pesÀ.xnb 38 42 Content\tuli.wma 43 Content\spooky.wma 44 Content\alien.wma -
2015/30/SamuelL/jotain/jotain/jotainContent/jotainContent.contentproj
r6995 r7029 110 110 </ItemGroup> 111 111 <ItemGroup> 112 <Compile Include="spooky.wav">113 <Name>spooky</Name>114 <Importer>WavImporter</Importer>115 <Processor>SoundEffectProcessor</Processor>116 </Compile>117 </ItemGroup>118 <ItemGroup>119 112 <Compile Include="tulikuva.png"> 120 113 <Name>tulikuva</Name> … … 219 212 <Importer>WavImporter</Importer> 220 213 <Processor>SoundEffectProcessor</Processor> 214 </Compile> 215 </ItemGroup> 216 <ItemGroup> 217 <Compile Include="hirviö1.png"> 218 <Name>hirviö1</Name> 219 <Importer>TextureImporter</Importer> 220 <Processor>TextureProcessor</Processor> 221 </Compile> 222 </ItemGroup> 223 <ItemGroup> 224 <Compile Include="hirviö2.png"> 225 <Name>hirviö2</Name> 226 <Importer>TextureImporter</Importer> 227 <Processor>TextureProcessor</Processor> 228 </Compile> 229 </ItemGroup> 230 <ItemGroup> 231 <Compile Include="spooky.mp3"> 232 <Name>spooky</Name> 233 <Importer>Mp3Importer</Importer> 234 <Processor>SongProcessor</Processor> 235 </Compile> 236 </ItemGroup> 237 <ItemGroup> 238 <Compile Include="alien.mp3"> 239 <Name>alien</Name> 240 <Importer>Mp3Importer</Importer> 241 <Processor>SongProcessor</Processor> 242 </Compile> 243 </ItemGroup> 244 <ItemGroup> 245 <Compile Include="pesä.png"> 246 <Name>pesä</Name> 247 <Importer>TextureImporter</Importer> 248 <Processor>TextureProcessor</Processor> 221 249 </Compile> 222 250 </ItemGroup> -
2015/30/SamuelL/jotain/jotain/jotainContent/kentta2.txt
r6995 r7029 3 3 ## #### 4 4 ### ###### 5 # ##### ##### ##########6 ########### ## ##########7 8 9 10 11 12 13 K p k K 14 O 5 # ##### ##### ########### 6 ########### L L ################# 7 ####### L L ##### 8 # # 9 # # 10 # # 11 # # 12 # # 13 # K p k K # 14 # O # 15 15 ##############################################################
Note: See TracChangeset
for help on using the changeset viewer.