- Timestamp:
- 2014-06-13 11:47:42 (9 years ago)
- Location:
- 2014/24/EeroF
- Files:
-
- 17 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1.cs
r4992 r5030 20 20 Image hamiskuva = LoadImage("Hamis"); 21 21 Image hamiskuva2 = LoadImage("HamisNopea"); 22 Image ohjuskuva = LoadImage("Ohjus"); 22 23 Image SaMiKu = LoadImage("Sahkomies"); 23 24 Image mikkokaveri = LoadImage("MikkoKaveri2"); 24 25 Image Alku = LoadImage("Alku"); 26 Image MikkoMG = LoadImage("MikkoMG"); 27 Image MikkoKaveriMG = LoadImage("MikkoKaveriMG"); 28 Image MikkoAR = LoadImage("MikkoAR"); 29 Image MikkoKaveriAR = LoadImage("MikkoKaveriAR"); 25 30 SoundEffect Ai = LoadSoundEffect("Ai"); 26 31 SoundEffect Nam = LoadSoundEffect("Nam"); … … 54 59 { 55 60 SmoothTextures = false; 56 IsFullScreen = true;61 //IsFullScreen = true; 57 62 peli = this; 58 63 IsPaused = false; … … 345 350 346 351 ClusterGrenade kranu = new ClusterGrenade(4.0, 2); 347 kranu.Explosion.ShockwaveReachesObject += KranaattiOsui;348 352 kranu.NumberOfClusters = 8; 349 353 kranu.ClusterArc = 360; 350 354 pelaaja.Throw(kranu, Angle.FromDegrees(0), 5000); 351 352 353 } 355 kranu.Explosion.ShockwaveReachesObject += KranaattiOsui; 356 357 } 358 354 359 void Ohjus(PhysicsObject pelaaja) 355 360 { 356 357 } 361 List<GameObject> viholliset = GetObjectsWithTag("Hamis"); 362 if (viholliset.Count == 0) return; 363 364 Vector tahtaysPiste = Vector.FromLengthAndAngle(100.0, pelaaja.Angle); 365 366 double lahinEtaisyys = Vector.Distance(tahtaysPiste, viholliset[0].Position); 367 int lahimmanIndeksi = 0; 368 369 for (int i = 0; i < viholliset.Count; i++) 370 { 371 double tamanEtaisyys = Vector.Distance(tahtaysPiste, viholliset[i].Position); 372 if (tamanEtaisyys < lahinEtaisyys) 373 { 374 lahinEtaisyys = tamanEtaisyys; 375 lahimmanIndeksi = i; 376 } 377 } 378 379 double lahtoNopeus = 500; 380 double lentoNopeus = 250; 381 HakeutuvaAmmus ammus = new HakeutuvaAmmus(40, 8, viholliset[lahimmanIndeksi], pelaaja.Position + Vector.FromLengthAndAngle(100, pelaaja.Angle), Vector.FromLengthAndAngle(lahtoNopeus, pelaaja.Angle), lentoNopeus); 382 ammus.MaximumLifetime = TimeSpan.FromSeconds(8.5); 383 Add(ammus); 384 ammus.Image = ohjuskuva; 385 AddCollisionHandler(ammus, "Hamis", HAmmusOsui); 386 387 } 388 358 389 void Piilotatekstikentta(Label tekstiKentta) 359 390 { … … 373 404 pelaajan1Ase.FireRate += 50; 374 405 Mittari.Value += 1; 406 Mikko.Image = MikkoMG; 375 407 if (pelaajia == 2) 376 408 { 377 409 pelaajan2Ase.FireRate += 50; 410 Mikkokaveri.Image = MikkoKaveriMG; 378 411 }; 379 412 } … … 383 416 pelaajan1Ase.FireRate -= 50; 384 417 Mittari.Value -= 1; 418 parannuskuva(); 385 419 if (pelaajia == 2) 386 420 { … … 478 512 hamis.Hit(Vector.FromLengthAndAngle(2500, ammus.Angle)); 479 513 } 514 } 515 public void HAmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 516 { 517 Explosion rajahdys = new Explosion(50); 518 rajahdys.Position = ammus.Position; 519 rajahdys.MaxRadius = 150; 520 Add(rajahdys); 521 ammus.Destroy(); 522 rajahdys.ShockwaveReachesObject += KranaattiOsui; 523 if (kohde is Vihu) 524 { 525 Vihu hamis = kohde as Vihu; 526 hamis.ElamaLaskuri.Value -= 5; 527 hamis.Hit(Vector.FromLengthAndAngle(2500, ammus.Angle)); 528 } 529 530 531 480 532 } 481 533 void KranaattiOsui(IPhysicsObject rajahdyksenKohde, Vector v) … … 699 751 { 700 752 if (tormaaja.Image.Equals(mikkokuva)) elamaLaskuri.Value++; 701 else elamalaskuri2.Value++; 753 else if (pelaajia == 2 )elamalaskuri2.Value++; 754 if (tormaaja.Image.Equals(MikkoMG)) elamaLaskuri.Value++; 755 else if (pelaajia == 2) elamalaskuri2.Value++; 756 if (tormaaja.Image.Equals(MikkoAR)) elamaLaskuri.Value++; 757 else if (pelaajia == 2) elamalaskuri2.Value++; 702 758 DoNextUpdate(delegate 703 759 { … … 710 766 { 711 767 if (tormaaja.Image.Equals(mikkokuva)) elamaLaskuri.Value--; 712 else elamalaskuri2.Value--; 713 768 else 769 if (pelaajia == 2) 770 { 771 elamalaskuri2.Value--; 772 } 773 else elamaLaskuri.Value--; 714 774 Ai.Play(); 715 775 DoNextUpdate(delegate … … 840 900 { 841 901 montakopaivitysta ++; 842 if (tormaaja.Image.Equals(mikkokuva)) 902 parannuskuva(); 903 if (pelaajia == 1) 843 904 { 844 905 pelaajan1Ase.FireRate += 5; … … 847 908 else 848 909 { 910 pelaajan1Ase.FireRate += 5; 911 nopeusVakioAmmukselle += 0.1; 849 912 pelaajan2Ase.FireRate += 5; 850 913 nopeusVakioAmmukselle += 0.1; … … 856 919 tormaaja.AngularAcceleration = 0; 857 920 }); 921 } 922 void parannuskuva() 923 { 924 if (montakopaivitysta == 1) 925 { 926 Mikko.Image = MikkoAR; 927 if(pelaajia == 2) Mikkokaveri.Image = MikkoKaveriAR; 928 } 929 if (montakopaivitysta == 5) 930 { 931 Mikko.Image = MikkoMG; 932 if(pelaajia == 2) Mikkokaveri.Image = MikkoKaveriMG; 933 } 934 858 935 } 859 936 void Lopetus() … … 986 1063 } 987 1064 988 public class Ammus : PhysicsObject1065 public class HakeutuvaAmmus : PhysicsObject 989 1066 { 990 public Ammus(double width, double height) 1067 GameObject kohde { get; set; } 1068 1069 double nopeus {get; set;} 1070 1071 public HakeutuvaAmmus(double width, double height, GameObject kohde, Vector position, Vector launchDirection, double nopeus) 991 1072 :base(width, height) 992 1073 { 993 1074 this.kohde = kohde; 1075 this.IsUpdated = true; 1076 this.nopeus = nopeus; 1077 this.Position = position; 1078 Launch(launchDirection); 1079 } 1080 1081 public override void Update(Time time) 1082 { 1083 if (kohde == null) return; 1084 1085 const double HAKEUTUMISNOPEUS = 6; // 4 1086 1087 Angle suunta = (kohde.AbsolutePosition - this.AbsolutePosition).Angle; 1088 Vector suuntaKohteeseen = Vector.FromLengthAndAngle(nopeus, suunta); 1089 this.Angle = this.Velocity.Angle; 1090 if (this.Velocity == suuntaKohteeseen) return; // ollaan oikeassa suunnassa 1091 1092 if (this.Velocity.X < suuntaKohteeseen.X) this.Velocity = new Vector(this.Velocity.X + HAKEUTUMISNOPEUS, this.Velocity.Y); 1093 else this.Velocity = new Vector(this.Velocity.X - HAKEUTUMISNOPEUS, this.Velocity.Y); 1094 1095 if (this.Velocity.Y < suuntaKohteeseen.Y) this.Velocity = new Vector(this.Velocity.X, this.Velocity.Y + HAKEUTUMISNOPEUS); 1096 else this.Velocity = new Vector(this.Velocity.X, this.Velocity.Y - HAKEUTUMISNOPEUS); 1097 this.Velocity *= 1.01; 1098 base.Update(time); 1099 } 1100 1101 public void Launch(Vector launchDirection) 1102 { 1103 this.Hit(launchDirection); 994 1104 } 995 1105 } -
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1.csproj.Debug.cachefile
r4944 r5030 19 19 Content\MikkoKuoli.xnb 20 20 Content\Turret.xnb 21 Content\MikkoMG.xnb 22 Content\MikkoKaveriMG.xnb 23 Content\Ohjus.xnb 24 Content\MikkoAR.xnb 25 Content\MikkoKaveriAR.xnb -
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/ContentPipeline-{8A550B88-C547-4E1E-A9B8-2DC78D369A1D}.xml
r4964 r5030 181 181 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Turret.xnb</Output> 182 182 <Time>2014-06-11T10:42:33.7711351+03:00</Time> 183 </Item> 184 <Item> 185 <Source>MikkoMG.png</Source> 186 <Name>MikkoMG</Name> 187 <Importer>TextureImporter</Importer> 188 <Processor>TextureProcessor</Processor> 189 <Options>None</Options> 190 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoMG.xnb</Output> 191 <Time>2014-06-13T10:14:47.1114115+03:00</Time> 192 </Item> 193 <Item> 194 <Source>MikkoKaveriMG.png</Source> 195 <Name>MikkoKaveriMG</Name> 196 <Importer>TextureImporter</Importer> 197 <Processor>TextureProcessor</Processor> 198 <Options>None</Options> 199 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoKaveriMG.xnb</Output> 200 <Time>2014-06-13T10:14:52.5709574+03:00</Time> 201 </Item> 202 <Item> 203 <Source>Ohjus.png</Source> 204 <Name>Ohjus</Name> 205 <Importer>TextureImporter</Importer> 206 <Processor>TextureProcessor</Processor> 207 <Options>None</Options> 208 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Ohjus.xnb</Output> 209 <Time>2014-06-13T10:39:07.9907507+03:00</Time> 210 </Item> 211 <Item> 212 <Source>MikkoAR.png</Source> 213 <Name>MikkoAR</Name> 214 <Importer>TextureImporter</Importer> 215 <Processor>TextureProcessor</Processor> 216 <Options>None</Options> 217 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoAR.xnb</Output> 218 <Time>2014-06-13T11:37:28.8769716+03:00</Time> 219 </Item> 220 <Item> 221 <Source>MikkoKaveriAR.png</Source> 222 <Name>MikkoKaveriAR</Name> 223 <Importer>TextureImporter</Importer> 224 <Processor>TextureProcessor</Processor> 225 <Options>None</Options> 226 <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoKaveriAR.xnb</Output> 227 <Time>2014-06-13T11:37:37.9386806+03:00</Time> 183 228 </Item> 184 229 <BuildSuccessful>true</BuildSuccessful> -
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/FysiikkaPeli1.csproj.FileListAbsolute.txt
r4944 r5030 27 27 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\obj\x86\Debug\FysiikkaPeli1.pdb 28 28 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Turret.xnb 29 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoMG.xnb 30 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoKaveriMG.xnb 31 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Ohjus.xnb 32 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoAR.xnb 33 C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoKaveriAR.xnb -
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/cachefile-{8A550B88-C547-4E1E-A9B8-2DC78D369A1D}-targetpath.txt
r4944 r5030 19 19 Content\MikkoKuoli.xnb 20 20 Content\Turret.xnb 21 Content\MikkoMG.xnb 22 Content\MikkoKaveriMG.xnb 23 Content\Ohjus.xnb 24 Content\MikkoAR.xnb 25 Content\MikkoKaveriAR.xnb -
2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1Content/FysiikkaPeli1Content.contentproj
r4944 r5030 185 185 </Compile> 186 186 </ItemGroup> 187 <ItemGroup> 188 <Compile Include="MikkoMG.png"> 189 <Name>MikkoMG</Name> 190 <Importer>TextureImporter</Importer> 191 <Processor>TextureProcessor</Processor> 192 </Compile> 193 </ItemGroup> 194 <ItemGroup> 195 <Compile Include="MikkoKaveriMG.png"> 196 <Name>MikkoKaveriMG</Name> 197 <Importer>TextureImporter</Importer> 198 <Processor>TextureProcessor</Processor> 199 </Compile> 200 </ItemGroup> 201 <ItemGroup> 202 <Compile Include="Ohjus.png"> 203 <Name>Ohjus</Name> 204 <Importer>TextureImporter</Importer> 205 <Processor>TextureProcessor</Processor> 206 </Compile> 207 </ItemGroup> 208 <ItemGroup> 209 <Compile Include="MikkoAR.png"> 210 <Name>MikkoAR</Name> 211 <Importer>TextureImporter</Importer> 212 <Processor>TextureProcessor</Processor> 213 </Compile> 214 </ItemGroup> 215 <ItemGroup> 216 <Compile Include="MikkoKaveriAR.png"> 217 <Name>MikkoKaveriAR</Name> 218 <Importer>TextureImporter</Importer> 219 <Processor>TextureProcessor</Processor> 220 </Compile> 221 </ItemGroup> 187 222 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 188 223 <!-- 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.