Changeset 5030 for 2014/24


Ignore:
Timestamp:
2014-06-13 11:47:42 (9 years ago)
Author:
eefadjuk
Message:
 
Location:
2014/24/EeroF
Files:
17 added
11 edited

Legend:

Unmodified
Added
Removed
  • 2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1.cs

    r4992 r5030  
    2020    Image hamiskuva = LoadImage("Hamis"); 
    2121    Image hamiskuva2 = LoadImage("HamisNopea"); 
     22    Image ohjuskuva = LoadImage("Ohjus"); 
    2223    Image SaMiKu = LoadImage("Sahkomies"); 
    2324    Image mikkokaveri = LoadImage("MikkoKaveri2"); 
    2425    Image Alku = LoadImage("Alku"); 
     26    Image MikkoMG = LoadImage("MikkoMG"); 
     27    Image MikkoKaveriMG = LoadImage("MikkoKaveriMG"); 
     28    Image MikkoAR = LoadImage("MikkoAR"); 
     29    Image MikkoKaveriAR = LoadImage("MikkoKaveriAR"); 
    2530    SoundEffect Ai = LoadSoundEffect("Ai"); 
    2631    SoundEffect Nam = LoadSoundEffect("Nam"); 
     
    5459    { 
    5560        SmoothTextures = false; 
    56         IsFullScreen = true; 
     61        //IsFullScreen = true; 
    5762        peli = this; 
    5863        IsPaused = false; 
     
    345350 
    346351        ClusterGrenade kranu = new ClusterGrenade(4.0, 2); 
    347         kranu.Explosion.ShockwaveReachesObject += KranaattiOsui; 
    348352        kranu.NumberOfClusters = 8; 
    349353        kranu.ClusterArc = 360; 
    350354        pelaaja.Throw(kranu, Angle.FromDegrees(0), 5000); 
    351  
    352  
    353     } 
     355        kranu.Explosion.ShockwaveReachesObject += KranaattiOsui; 
     356 
     357    } 
     358 
    354359    void Ohjus(PhysicsObject pelaaja) 
    355360    { 
    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 
    358389    void Piilotatekstikentta(Label tekstiKentta) 
    359390    { 
     
    373404                pelaajan1Ase.FireRate += 50; 
    374405                Mittari.Value += 1; 
     406                Mikko.Image = MikkoMG; 
    375407                if (pelaajia == 2) 
    376408                { 
    377409                    pelaajan2Ase.FireRate += 50; 
     410                    Mikkokaveri.Image = MikkoKaveriMG; 
    378411                }; 
    379412            } 
     
    383416                pelaajan1Ase.FireRate -= 50; 
    384417                Mittari.Value -= 1; 
     418                parannuskuva(); 
    385419                if (pelaajia == 2) 
    386420                { 
     
    478512            hamis.Hit(Vector.FromLengthAndAngle(2500, ammus.Angle)); 
    479513        } 
     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 
    480532    } 
    481533    void KranaattiOsui(IPhysicsObject rajahdyksenKohde, Vector v) 
     
    699751    { 
    700752        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++; 
    702758        DoNextUpdate(delegate 
    703759        { 
     
    710766    { 
    711767        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--; 
    714774        Ai.Play(); 
    715775        DoNextUpdate(delegate 
     
    840900    { 
    841901        montakopaivitysta ++; 
    842         if (tormaaja.Image.Equals(mikkokuva)) 
     902        parannuskuva(); 
     903        if (pelaajia == 1) 
    843904        { 
    844905            pelaajan1Ase.FireRate += 5; 
     
    847908        else 
    848909        { 
     910            pelaajan1Ase.FireRate += 5; 
     911            nopeusVakioAmmukselle += 0.1; 
    849912            pelaajan2Ase.FireRate += 5; 
    850913            nopeusVakioAmmukselle += 0.1; 
     
    856919            tormaaja.AngularAcceleration = 0; 
    857920        }); 
     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             
    858935    } 
    859936    void Lopetus() 
     
    9861063} 
    9871064 
    988 public class Ammus : PhysicsObject 
     1065public class HakeutuvaAmmus : PhysicsObject 
    9891066{ 
    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) 
    9911072        :base(width, height) 
    9921073    { 
    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); 
    9941104    } 
    9951105} 
  • 2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1.csproj.Debug.cachefile

    r4944 r5030  
    1919Content\MikkoKuoli.xnb 
    2020Content\Turret.xnb 
     21Content\MikkoMG.xnb 
     22Content\MikkoKaveriMG.xnb 
     23Content\Ohjus.xnb 
     24Content\MikkoAR.xnb 
     25Content\MikkoKaveriAR.xnb 
  • 2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/ContentPipeline-{8A550B88-C547-4E1E-A9B8-2DC78D369A1D}.xml

    r4964 r5030  
    181181      <Output>C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Turret.xnb</Output> 
    182182      <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> 
    183228    </Item> 
    184229    <BuildSuccessful>true</BuildSuccessful> 
  • 2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/obj/x86/Debug/FysiikkaPeli1.csproj.FileListAbsolute.txt

    r4944 r5030  
    2727C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\obj\x86\Debug\FysiikkaPeli1.pdb 
    2828C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Turret.xnb 
     29C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoMG.xnb 
     30C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoKaveriMG.xnb 
     31C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\Ohjus.xnb 
     32C:\MyTemp\EeroF\FysiikkaPeli1\FysiikkaPeli1\FysiikkaPeli1\bin\x86\Debug\Content\MikkoAR.xnb 
     33C:\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  
    1919Content\MikkoKuoli.xnb 
    2020Content\Turret.xnb 
     21Content\MikkoMG.xnb 
     22Content\MikkoKaveriMG.xnb 
     23Content\Ohjus.xnb 
     24Content\MikkoAR.xnb 
     25Content\MikkoKaveriAR.xnb 
  • 2014/24/EeroF/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1Content/FysiikkaPeli1Content.contentproj

    r4944 r5030  
    185185    </Compile> 
    186186  </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> 
    187222  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    188223  <!--  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.