Changeset 3615


Ignore:
Timestamp:
2012-07-05 15:12:52 (11 years ago)
Author:
mianheha
Message:
 
Location:
2012/27/MiloH
Files:
47 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/MiloH/Helicopter criminal/Helicopter criminal/Helicopter criminal/Helicopter_criminal.cs

    r3523 r3615  
    99public class Helicopter_criminal : PhysicsGame 
    1010{ 
     11    Image kopterikuva = LoadImage ("helikopteri");  
     12    PhysicsObject helikopteri; 
     13    AssaultRifle ase; 
     14    PlatformCharacter sankari; 
    1115    public override void Begin() 
    1216    { 
     17        Level.Width = 10000.0; 
     18 
     19 
     20         
    1321        liikkeet(); 
    1422         
    15         PhysicsObject sankari = new PhysicsObject(20, 50); 
    16         Add(sankari); 
    17         sankari.Shape = Shape.Circle; 
    18         Gravity = new Vector(0.0, -800.0); 
    19         Explosion rajahdys = new Explosion(100); 
    20         rajahdys.Position = sankari.Position; 
    21         Add(rajahdys); 
    22         rajahdys.ShockwaveColor = Color.DarkRed; 
    23              
    24          
     23        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 
     24"Aloita peli","Tasot", "Parhaat pisteet", "Lopeta peli"); 
     25        Add(alkuValikko); 
    2526 
    2627         
     28        alkuValikko.Color = Color.DarkMagenta; 
     29 
     30        helikopteri = new PhysicsObject(150, 70); 
     31        Add (helikopteri); 
     32        helikopteri.Image = kopterikuva; 
     33        sankari = new PlatformCharacter(20, 50); 
     34 
     35        Add(sankari); 
     36        sankari.Shape = Shape.Triangle; 
     37        sankari.Push(new Vector(400, 0)); 
     38        sankari.X = Level.Left + 20.0; 
     39        ase = new AssaultRifle(30.0, 10.0); 
    2740         
     41        ase.Angle += Angle.FromDegrees(5); 
     42        ase.Shoot(); 
     43        ase.Tag = "ase"; 
     44        sankari.Add(ase); 
     45        ase.ProjectileCollision = ammusosui; 
     46 
     47        AddCollisionHandler(sankari, ase, PelaajatTormaavat); 
     48 
     49        AddCollisionHandler<PlatformCharacter, PhysicsObject>(sankari, tormays); 
     50 
     51 
     52 
     53        PlatformCharacter poliisi = new PlatformCharacter(30, 60); 
     54        Add(poliisi); 
     55        poliisi.Color = Color.MediumBlue; 
     56        poliisi.X = Level.Left + 1000; 
     57        poliisi.Y = Level.Bottom + 1; 
     58        poliisi.Push(new Vector(-300, 0.0)); 
     59        FollowerBrain poliisinaivot = new FollowerBrain(sankari); 
     60        poliisi.Brain = poliisinaivot; 
     61        poliisinaivot.Speed = 200; 
     62 
     63        Gravity = new Vector (0.0, -800.0) 
     64            ; 
     65        Level.CreateBottomBorder(); 
     66        Level.CreateLeftBorder(); 
     67 
     68 
     69        Camera.Follow(sankari); 
     70        AddCollisionHandler(sankari, tormays); 
     71        AddCollisionHandler(sankari, poliisi, PelaajatTormaavat); 
     72 
     73 
    2874    } 
    2975    void liikkeet() 
    3076    { 
    31          
     77        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaaja vasemmalle", (-300.0)); 
     78        Keyboard.Listen(Key.D, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaaja oikealle",(300.0)); 
     79        Keyboard.Listen(Key.W, ButtonState.Down, hyppääpelaajalla, "hyppää pelaajalla", (300.0)); 
     80        //Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaaja ylos", new Vector(0, 300)); 
     81        //Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaaja alas", new Vector(0, -300)); 
     82 
     83        //Keyboard.Listen(Key.A, ButtonState.Released, LiikutaPelaajaa, "pysayta pelaaja", new Vector(-300, 0)); 
     84        //Keyboard.Listen(Key.D, ButtonState.Released, LiikutaPelaajaa, "pysayta pelaaja", new Vector(300, 0)); 
     85        //Keyboard.Listen(Key.W, ButtonState.Released, LiikutaPelaajaa, "pysayta pelaaja", new Vector(0, 300)); 
     86        //Keyboard.Listen(Key.S, ButtonState.Released, LiikutaPelaajaa, "pysayta pelaaja", new Vector(0, -300)); 
     87        Mouse.Listen(MouseButton.Left, ButtonState.Down, ammuaseella, "ammu"); 
    3288         
    3389        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     90 
     91        Mouse.ListenMovement(0.1, hiirenliike, null); 
     92    } 
     93 
     94    void LiikutaPelaajaa(double nopeus) 
     95    { 
     96        sankari.Walk(nopeus); 
     97         
     98    } 
     99    void hyppääpelaajalla(double nopeus) 
     100    { 
     101        sankari.Jump(nopeus); 
     102         
     103 
     104    } 
     105 
     106 
     107    void ammuaseella() 
     108    { 
     109 
     110 
     111        PhysicsObject ammus = ase.Shoot(); 
     112        { 
     113 
     114            if (ammus != null) 
     115            { 
     116                ammus.Size *= 1; 
     117            } 
     118        } 
     119    } 
     120    void ammusosui(PhysicsObject ammus, PhysicsObject kohde) 
     121    { 
     122        ammus.Destroy(); 
     123        Explosion rajahdys = new Explosion(1.0); 
     124        rajahdys.Position = ammus.Position; 
     125        Add(rajahdys); 
     126    } 
     127    void HeitaKranaatti(PhysicsObject sankari) 
     128    { 
     129        Grenade kranu = new Grenade(4.0); 
     130        sankari.Throw(kranu, Angle.FromDegrees(30), 10000); 
     131    } 
     132    void hiirenliike(AnalogState hiirentila) 
     133    { 
     134        Vector v = Mouse.PositionOnWorld - sankari.Position; 
     135        ase.Angle = v.Angle; 
     136         
     137    } 
     138    void painettiinvalikonnappia(int valinta) 
     139    { 
     140        switch (valinta) 
     141        {case 0: 
     142                //Aloitapeli (); 
     143                break; 
     144                case 1: 
     145                //Tasot 
     146                break; 
     147            case 2: 
     148                // parhaatpisteet(); 
     149                break; 
     150            case 3: 
     151                Exit(); 
     152                break; 
     153        } 
     154 
     155    } 
     156    void tormays(PhysicsObject tormaaja, PhysicsObject kohde) 
     157    { 
     158        PlatformCharacter sankari = tormaaja as PlatformCharacter; 
     159         
    34160 
    35161    }new PhysicsObject 
    36162    { 
    37163    } 
    38 } 
     164 
     165 
     166    } 
     167    void PelaajatTormaavat(PhysicsObject tormaaja, PhysicsObject kohde) 
     168    { 
     169        MessageDisplay.Add("You picked up assault rifle!"); 
     170    } 
     171 
     172     
     173     
     174 
     175 
     176}  
  • 2012/27/MiloH/Helicopter criminal/Helicopter criminal/Helicopter criminalContent/Helicopter criminalContent.contentproj

    r3485 r3615  
    4545  </ItemGroup> 
    4646  <ItemGroup> 
    47     <Compile Include="sankari.png"> 
    48       <Name>sankari</Name> 
     47    <Compile Include="helikopteri.png"> 
     48      <Name>helikopteri</Name> 
    4949      <Importer>TextureImporter</Importer> 
    5050      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.