- Timestamp:
- 2014-07-23 15:03:41 (9 years ago)
- Location:
- 2014/30/AtteB
- Files:
-
- 55 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/AtteB/Peli/Peli/Peli/Peli.cs
r5577 r5599 7 7 using Jypeli.Widgets; 8 8 9 class Vihollinen : P hysicsObject9 class Vihollinen : PlatformCharacter 10 10 { 11 private IntMeter elamaLaskuri = new IntMeter(3, 0, 3);11 private IntMeter elamaLaskuri; 12 12 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 13 13 14 public Vihollinen(double leveys, double korkeus )14 public Vihollinen(double leveys, double korkeus, int elama) 15 15 : base(leveys, korkeus) 16 16 { 17 elamaLaskuri = new IntMeter(elama, 0, elama); 17 18 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 18 19 } … … 59 60 60 61 PlatformCharacter pelaaja1; 62 PhysicsObject Vihollinen; 63 Vihollinen Slime; 61 64 62 65 Image tahtiKuva = LoadImage("tahti"); … … 74 77 Image Clear = LoadImage("Clear"); 75 78 Image Heart1 = LoadImage("heart"); 79 Image SlimeBall = LoadImage("SlimeBall"); 76 80 77 81 SoundEffect maaliAani = LoadSoundEffect("maali"); 78 82 SoundEffect HowItBegins = LoadSoundEffect("HowItBegins"); 83 SoundEffect PlayerShoot1 = LoadSoundEffect("PlayerShoot"); 79 84 80 85 public override void Begin() … … 87 92 LuoKentta(); 88 93 LisaaNappaimet(); 94 LuoElämäLaskuri(); 89 95 90 96 Camera.Follow(pelaaja1); … … 96 102 Inventory inventory = new Inventory(); 97 103 Add(inventory); 104 105 Camera.FollowedObject = pelaaja1; 106 Camera.Zoom(1.5); 107 108 MediaPlayer.Play("howitbegins"); 98 109 } 99 110 … … 167 178 pelaaja1.Position = paikka; 168 179 pelaaja1.Mass = 10.0; 180 pelaaja1.Tag = "pelaaja"; 169 181 pelaaja1.Image = Pelaaja_Seisoo; 170 182 AddCollisionHandler(pelaaja1, "vihollinen", PelaajaOsuuViholliseen); … … 182 194 183 195 pelaaja1.Add(P1FireBall); 196 197 P1FireBall.AttackSound = null; 184 198 } 185 199 … … 219 233 vihollinen.Position = paikka; 220 234 vihollinen.Tag = "vihollinen"; 235 //AddCollisionHandler(vihollinen, "ammus", AmmusOsuiViholliseen); 221 236 Add(vihollinen); 222 237 } … … 232 247 public void PelaajaOsuuViholliseen(PhysicsObject pelaaja1, PhysicsObject kohde) 233 248 { 234 elämäLaskuri.Value -= elämäLaskuri -10;249 elämäLaskuri.Value -= 10; 235 250 236 251 if (elämäLaskuri <= 0) … … 240 255 public void PelaajaOsuuHeart(PhysicsObject pelaaja1, PhysicsObject kohde) 241 256 { 242 elämäLaskuri.Value += elämäLaskuri + 20; 257 if (elämäLaskuri <= elämäLaskuri.MaxValue - 10) 258 { 259 elämäLaskuri.Value += elämäLaskuri + 20; 260 kohde.Destroy(); 261 } 243 262 } 244 263 245 264 void LuoSlime(Vector paikka, double leveys, double korkeus) 246 265 { 247 PhysicsObject Slime = new PhysicsObject(leveys, korkeus);266 Vihollinen Slime = new Vihollinen(leveys, korkeus * 0.5, 5); 248 267 Slime.CanRotate = false; 249 268 Slime.Position = paikka; … … 251 270 Slime.Image = Slime1; 252 271 Add(Slime); 272 273 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 274 tasoAivot.Speed = 150; 275 Slime.Brain = tasoAivot; 276 277 FollowerBrain SlimeAivot = new FollowerBrain("pelaaja"); 278 SlimeAivot.Speed = 200; 279 SlimeAivot.DistanceFar = 600; 280 SlimeAivot.DistanceClose = 300; 281 SlimeAivot.StopWhenTargetClose = true; 282 SlimeAivot.FarBrain = tasoAivot; 283 284 Slime.Weapon = new AssaultRifle(30, 10); 285 Slime.Weapon.ProjectileCollision = AmmusOsuiPelaajaan; 286 Slime.Weapon.IsVisible = true; 287 Slime.Weapon.AttackSound = null; 288 289 Timer ajastin = new Timer(); 290 ajastin.Interval = 0.5; 291 ajastin.Timeout += delegate 292 { 293 PhysicsObject ammus = Slime.Weapon.Shoot(); 294 if (ammus != null) 295 { 296 ammus.Image = SlimeBall; 297 ammus.Size = new Vector(20, 20); 298 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 299 ammus.Tag = "ammus"; 300 301 } 302 }; 303 ajastin.Start(); 304 305 Timer ajastin2 = new Timer(); 306 ajastin2.Interval = 0.01; 307 ajastin2.Timeout += delegate 308 { 309 310 Vector suunta = (pelaaja1.Position - Slime.Position).Normalize(); 311 Slime.Weapon.Angle = suunta.Angle; 312 313 }; 314 ajastin2.Start(); 315 } 316 317 void LuoBoss1(Vector paikka, double leveys, double korkeus) 318 { 319 Vihollinen Boss1 = new Vihollinen(leveys, korkeus * 0.5, 20); 320 Boss1.CanRotate = false; 321 Boss1.Position = paikka; 322 Boss1.Tag = "vihollinen"; 323 Boss1.Image = Slime1; 324 Add(Boss1); 325 326 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 327 tasoAivot.Speed = 150; 328 Boss1.Brain = tasoAivot; 329 330 FollowerBrain SlimeAivot = new FollowerBrain("vihollinen"); 331 SlimeAivot.Speed = 200; 332 SlimeAivot.DistanceFar = 600; 333 SlimeAivot.DistanceClose = 300; 334 SlimeAivot.StopWhenTargetClose = true; 335 SlimeAivot.FarBrain = tasoAivot; 336 337 Boss1.Weapon = new AssaultRifle(30, 10); 338 Boss1.Weapon.ProjectileCollision = AmmusOsuiPelaajaan; 339 Boss1.Weapon.IsVisible = false; 340 Boss1.Weapon.AttackSound = null; 341 342 Timer ajastin = new Timer(); 343 ajastin.Interval = 1.0; 344 ajastin.Timeout += delegate 345 { 346 PhysicsObject ammus = Boss1.Weapon.Shoot(); 347 if (ammus != null) 348 { 349 ammus.Image = SlimeBall; 350 ammus.Size = new Vector(20, 20); 351 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 352 ammus.Tag = "ammus"; 353 } 354 }; 355 ajastin.Start(); 356 if (Boss1.IsDestroyed) 357 { 358 ajastin.Stop(); 359 } 253 360 } 254 361 … … 257 364 ammus.Destroy(); 258 365 366 if (kohde.Tag.ToString() == "vihollinen") 367 { 368 (kohde as Vihollinen).ElamaLaskuri.Value--; 369 } 370 } 371 372 void AmmusOsuiPelaajaan(PhysicsObject ammus, PhysicsObject kohde) 373 { 374 ammus.Destroy(); 375 376 if (kohde.Tag.ToString() == "pelaaja") 377 { 378 elämäLaskuri.Value--; 379 } 259 380 } 260 381 261 382 void AmmuAseella(AssaultRifle ase) 262 383 { 384 ase.AbsoluteAngle = pelaaja1.FacingDirection.Angle; 263 385 PhysicsObject ammus = ase.Shoot(); 264 386 … … 268 390 ammus.Size = new Vector(40, 40); 269 391 ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 392 ammus.Tag = "ammus"; 270 393 } 271 394 } … … 283 406 284 407 ProgressBar elämäPalkki = new ProgressBar(150, 20); 285 elämäPalkki.X = Screen.Left + 150;286 elämäPalkki.Y = Screen.Top - 20;408 elämäPalkki.X = Screen.Left + 500; 409 elämäPalkki.Y = Screen.Top - 100; 287 410 elämäPalkki.BindTo(elämäLaskuri); 288 411 elämäPalkki.Color = Color.Transparent; … … 294 417 void ElämäLoppui() 295 418 { 419 Explosion PelaajaRäjähtää = new Explosion(200); 420 PelaajaRäjähtää.Position = pelaaja1.Position; 421 PelaajaRäjähtää.Sound = null; 422 Add(PelaajaRäjähtää); 423 296 424 MessageDisplay.Add("Elämät loppuivat, voi voi."); 297 Remove(pelaaja1); 425 pelaaja1.Destroy(); 426 427 Timer.SingleShot(4.0, AloitaPeliAlusta); 428 } 429 430 public void SlimeLähelläPelaajaa() 431 { 432 Vector suunta = (pelaaja1.Position - Slime.Position).Normalize(); 433 434 Slime.Angle = suunta.Angle; 435 } 436 437 void AloitaPeliAlusta() 438 { 439 ClearAll(); 440 Begin(); 298 441 } 299 442 -
2014/30/AtteB/Peli/Peli/Peli/Peli.csproj.Debug.cachefile
r5577 r5599 17 17 Content\Fireball_4.xnb 18 18 Content\Clear.xnb 19 Content\HowItBegins.xnb 19 20 Content\heart.xnb 20 Content\HowItBegins.xnb 21 Content\Slimeball.xnb 22 Content\PlayerShoot.xnb 21 23 Content\HowItBegins.wma 24 Content\PlayerShoot.wma -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/ContentPipeline-{2D86B228-748C-44C7-93B1-DCBD6910317C}.xml
r5577 r5599 36 36 <Options>None</Options> 37 37 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\kentta1.xnb</Output> 38 <Time>2014-07-23T1 1:52:10.0873113+03:00</Time>38 <Time>2014-07-23T13:24:51.8127339+03:00</Time> 39 39 </Item> 40 40 <Item> … … 117 117 <Options>None</Options> 118 118 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Slime.xnb</Output> 119 <Time>2014-07-2 2T14:06:10.9162814+03:00</Time>119 <Time>2014-07-23T13:43:22.1617577+03:00</Time> 120 120 </Item> 121 121 <Item> … … 163 163 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Clear.xnb</Output> 164 164 <Time>2014-07-23T10:21:25.007312+03:00</Time> 165 </Item>166 <Item>167 <Source>heart.jpg</Source>168 <Name>heart</Name>169 <Importer>TextureImporter</Importer>170 <Processor>TextureProcessor</Processor>171 <Options>None</Options>172 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\heart.xnb</Output>173 <Time>2014-07-23T12:02:01.4194386+03:00</Time>174 165 </Item> 175 166 <Item> … … 182 173 <Extra>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\HowItBegins.wma</Extra> 183 174 <Time>2014-07-23T11:50:07.3910911+03:00</Time> 175 </Item> 176 <Item> 177 <Source>heart.png</Source> 178 <Name>heart</Name> 179 <Importer>TextureImporter</Importer> 180 <Processor>TextureProcessor</Processor> 181 <Options>None</Options> 182 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\heart.xnb</Output> 183 <Time>2014-07-23T12:45:31.8687631+03:00</Time> 184 </Item> 185 <Item> 186 <Source>Slimeball.png</Source> 187 <Name>Slimeball</Name> 188 <Importer>TextureImporter</Importer> 189 <Processor>TextureProcessor</Processor> 190 <Options>None</Options> 191 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Slimeball.xnb</Output> 192 <Time>2014-07-23T13:43:35.0980512+03:00</Time> 193 </Item> 194 <Item> 195 <Source>PlayerShoot.mp3</Source> 196 <Name>PlayerShoot</Name> 197 <Importer>Mp3Importer</Importer> 198 <Processor>SongProcessor</Processor> 199 <Options>None</Options> 200 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.xnb</Output> 201 <Extra>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.wma</Extra> 202 <Time>2014-07-23T13:51:43.8689234+03:00</Time> 184 203 </Item> 185 204 <BuildSuccessful>true</BuildSuccessful> -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/Peli.csproj.FileListAbsolute.txt
r5577 r5599 28 28 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\HowItBegins.xnb 29 29 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\HowItBegins.wma 30 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Slimeball.xnb 31 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.xnb 32 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.wma -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/cachefile-{2D86B228-748C-44C7-93B1-DCBD6910317C}-targetpath.txt
r5577 r5599 17 17 Content\Fireball_4.xnb 18 18 Content\Clear.xnb 19 Content\heart.xnb20 19 Content\HowItBegins.xnb 21 20 Content\HowItBegins.wma 21 Content\heart.xnb 22 Content\Slimeball.xnb 23 Content\PlayerShoot.xnb 24 Content\PlayerShoot.wma -
2014/30/AtteB/Peli/Peli/PeliContent/PeliContent.contentproj
r5577 r5599 160 160 </ItemGroup> 161 161 <ItemGroup> 162 <Compile Include="heart.jpg"> 162 <Compile Include="HowItBegins.mp3"> 163 <Name>HowItBegins</Name> 164 <Importer>Mp3Importer</Importer> 165 <Processor>SongProcessor</Processor> 166 </Compile> 167 </ItemGroup> 168 <ItemGroup> 169 <Compile Include="heart.png"> 163 170 <Name>heart</Name> 164 171 <Importer>TextureImporter</Importer> … … 167 174 </ItemGroup> 168 175 <ItemGroup> 169 <Compile Include="HowItBegins.mp3"> 170 <Name>HowItBegins</Name> 176 <Compile Include="Slimeball.png"> 177 <Name>Slimeball</Name> 178 <Importer>TextureImporter</Importer> 179 <Processor>TextureProcessor</Processor> 180 </Compile> 181 </ItemGroup> 182 <ItemGroup> 183 <Compile Include="PlayerShoot.mp3"> 184 <Name>PlayerShoot</Name> 171 185 <Importer>Mp3Importer</Importer> 172 186 <Processor>SongProcessor</Processor> -
2014/30/AtteB/Peli/Peli/PeliContent/kentta1.txt
r5577 r5599 1 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 3 4 5 N 6 ????? 7 ??????.......H.......................................... 8 ???????..............?.....?. 9 ????????.............?..S..?. 10 ########################################################### 1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 ............................? 3 ............................? 4 ............................? 5 N..........................? 6 ?????.......................? 7 ??????.......H.............. ........................... 8 ???????.............?....... . 9 ????????............?...S...?. 10 ##################################### #################### 11 ............................................................ 12 ............................................................ 13 ............................................................ 14 ............................................................ 15 ............................................................ 16 ............................................................ 17 ............................................................ 18 ############################################################
Note: See TracChangeset
for help on using the changeset viewer.