Changeset 4583 for 2013/30


Ignore:
Timestamp:
2013-07-23 14:58:15 (10 years ago)
Author:
nieekrva
Message:

Talletus.

Location:
2013/30/NikiV
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/NikiV/Airbattle/Airbattle/Airbattle/Airbattle.cs

    r4524 r4583  
    99public class Airbattle : PhysicsGame 
    1010{ 
     11    PhysicsObject alus; 
     12    Image aluskuva = LoadImage("alus"); 
     13    IntMeter pisteLaskuri; 
     14    ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("rajahdys"), 100); 
     15    EasyHighScore topLista = new EasyHighScore(); 
    1116    public override void Begin() 
    1217    { 
     18        Aloitapeli(); 
     19         
     20    } 
     21 
     22    void Aloitapeli() 
     23    { 
     24        ClearAll(); 
     25        Add(rajahdys); 
    1326        Level.Size = new Vector(800, 600); 
    1427        SetWindowSize(800, 600, false); 
    15         // TODO: Kirjoita ohjelmakoodisi tähän 
    16         PhysicsObject alus = new PhysicsObject(50.0, 50.0, Shape.Circle); 
    17         Add(alus); 
    18         alus.LinearDamping = 0.9; 
    19         alus.CanRotate = false; 
    20         alus.Tag = "alus"; 
    21         Image aluskuva = LoadImage("alus"); 
    22         alus.Image = aluskuva; 
    23         AddCollisionHandler(alus, "hämis", PelaajaOsuu); 
    2428 
    25         PhysicsObject hamis = new PhysicsObject(50.0, 50.0); 
    26         hamis.X = 200; 
    27         Add(hamis); 
    28         hamis.CanRotate = false; 
    29         //hamis.AngularDamping = 0.9; 
    30         Image hamiskuva = LoadImage("hamis"); 
    31         hamis.Image = hamiskuva; 
    32         FollowerBrain seuraajanAivot = new FollowerBrain("alus"); 
    33         seuraajanAivot.Speed = 200; 
    34         seuraajanAivot.Active = true; 
    35         hamis.Brain = seuraajanAivot; 
    36         hamis.Tag = "hämis"; 
     29        LuoKentta(); 
     30        LuoPistelaskuri(); 
     31        MediaPlayer.Play("taustamusa"); 
     32        MediaPlayer.IsRepeating = true; 
     33         
    3734 
    38         Level.CreateBorders(1.0, true); 
    3935        Camera.ZoomToLevel(); 
     36        Keyboard.Listen(Key.Space, ButtonState.Pressed, Ammu, "Ammu", alus); 
    4037 
    4138        Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, alus, new Vector(-1000, 0)); 
     
    5451        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    5552    } 
     53 
     54 
     55    void Ammu(PhysicsObject ampuja) 
     56    { 
     57        PhysicsObject ammus = new PhysicsObject(10, 10); 
     58        //ammus.Image = luodinkuva; 
     59 
     60        ammus.Position = ampuja.Position; 
     61        ammus.IgnoresGravity = true; 
     62        ammus.Angle = ampuja.Angle; 
     63        ammus.Color = Color.Yellow; 
     64        ammus.CanRotate = false; 
     65        ammus.LifetimeLeft = TimeSpan.FromSeconds(2); 
     66        ammus.Tag = "ammus"; 
     67        ammus.CollisionIgnoreGroup = ampuja.CollisionIgnoreGroup; 
     68        ammus.Hit(Vector.FromLengthAndAngle(1000, ampuja.Angle + Angle.FromDegrees(90))); 
     69        Add(ammus); 
     70        AddCollisionHandler(ammus, "hämis", CollisionHandler.AddMeterValue(pisteLaskuri, 200)); 
     71        AddCollisionHandler(ammus, AmmusOsuu); 
     72 
     73    } 
     74 
     75    void AmmusOsuu(PhysicsObject ammus, PhysicsObject kohde) 
     76    { 
     77        ammus.Destroy(); 
     78        if(!kohde.Tag.Equals("seinä"))kohde.Destroy(); 
     79    } 
     80 
     81 
     82 
     83 
    5684    void PelaajaOsuu(PhysicsObject alus, PhysicsObject hamis) 
    5785    { 
    5886        alus.Destroy(); 
     87        rajahdys.AddEffect(alus.X, alus.Y, 100); 
     88        topLista.EnterAndShow(pisteLaskuri.Value); 
     89        topLista.HighScoreWindow.Closed += IkkunaSuljettu; 
     90 
    5991    } 
    60  
     92    void IkkunaSuljettu(Window sender) 
     93    { 
     94        Aloitapeli(); 
     95    } 
    6196 
    6297    void LiikutaPelaajaa(PhysicsObject alus, Vector nopeus) 
     
    99134        ruudut.SetTileMethod('a', Luoalus); 
    100135        ruudut.SetTileMethod('h', Luohamis); 
    101         ruudut.Execute(20, 20); 
     136        ruudut.Execute(50, 50); 
    102137    } 
    103138    void Luoalus(Vector paikka, double leveys, double korkeus) 
    104139    { 
    105         alus = new PhysicsObject(10, 10); 
     140        alus = new PhysicsObject(leveys, korkeus, Shape.Circle); 
     141        Add(alus); 
    106142        alus.Position = paikka; 
     143        alus.LinearDamping = 0.9; 
     144        alus.CollisionIgnoreGroup = 2; 
     145        alus.CanRotate = false; 
     146        alus.Tag = "alus"; 
     147        alus.Image = aluskuva; 
     148        AddCollisionHandler(alus, "hämis", PelaajaOsuu); 
     149    } 
     150    void Luohamis(Vector paikka, double leveys, double korkeus) 
     151    { 
     152        PhysicsObject hamis = new PhysicsObject(leveys, korkeus); 
     153        hamis.Position = paikka; 
     154        Add(hamis); 
     155        hamis.CanRotate = false; 
     156        //hamis.AngularDamping = 0.9; 
     157        Image hamiskuva = LoadImage("hamis"); 
     158        hamis.Image = hamiskuva; 
     159        FollowerBrain seuraajanAivot = new FollowerBrain("alus"); 
     160        seuraajanAivot.Speed = 200; 
     161        seuraajanAivot.Active = true; 
     162        hamis.Brain = seuraajanAivot; 
     163        hamis.Tag = "hämis"; 
     164         
     165    } 
     166 
     167    void LuoPistelaskuri() 
     168    { 
     169        pisteLaskuri = new IntMeter(0); 
     170 
     171        Label pisteNaytto = new Label(); 
     172        pisteNaytto.X = Screen.Left + 100; 
     173        pisteNaytto.Y = Screen.Top - 100; 
     174        pisteNaytto.TextColor = Color.Black; 
     175        pisteNaytto.Color = Color.White; 
     176 
     177        pisteNaytto.BindTo(pisteLaskuri); 
     178        Add(pisteNaytto); 
     179    } 
     180 
     181 
     182 
     183 
     184 
     185 
    107186 
    108187} 
  • 2013/30/NikiV/Airbattle/Airbattle/AirbattleContent/AirbattleContent.contentproj

    r4524 r4583  
    5959    </Compile> 
    6060  </ItemGroup> 
     61  <ItemGroup> 
     62    <Compile Include="kentta1.txt"> 
     63      <Name>kentta1</Name> 
     64      <Importer>TextFileImporter</Importer> 
     65      <Processor>TextFileContentProcessor</Processor> 
     66    </Compile> 
     67  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="taustamusa.mp3"> 
     70      <Name>taustamusa</Name> 
     71      <Importer>Mp3Importer</Importer> 
     72      <Processor>SongProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="token1.png"> 
     77      <Name>token1</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
     82  <ItemGroup> 
     83    <Compile Include="plasmaammus.png"> 
     84      <Name>plasmaammus</Name> 
     85      <Importer>TextureImporter</Importer> 
     86      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88  </ItemGroup> 
     89  <ItemGroup> 
     90    <Compile Include="rajahdys.png"> 
     91      <Name>rajahdys</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="1alus.png"> 
     98      <Name>1alus</Name> 
     99      <Importer>TextureImporter</Importer> 
     100      <Processor>TextureProcessor</Processor> 
     101    </Compile> 
     102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="2alusta.png"> 
     105      <Name>2alusta</Name> 
     106      <Importer>TextureImporter</Importer> 
     107      <Processor>TextureProcessor</Processor> 
     108    </Compile> 
     109  </ItemGroup> 
     110  <ItemGroup> 
     111    <Compile Include="3alusta.png"> 
     112      <Name>3alusta</Name> 
     113      <Importer>TextureImporter</Importer> 
     114      <Processor>TextureProcessor</Processor> 
     115    </Compile> 
     116  </ItemGroup> 
     117  <ItemGroup> 
     118    <Compile Include="perusvihu.png"> 
     119      <Name>perusvihu</Name> 
     120      <Importer>TextureImporter</Importer> 
     121      <Processor>TextureProcessor</Processor> 
     122    </Compile> 
     123  </ItemGroup> 
    61124  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    62125  <!--  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.