Changeset 4168 for 2013/24


Ignore:
Timestamp:
2013-06-14 12:53:03 (10 years ago)
Author:
alvirmas
Message:

Talletus.

Location:
2013/24/AleksanteriV/Protokolla236/Protokolla236
Files:
9 added
8 edited

Legend:

Unmodified
Added
Removed
  • 2013/24/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.cs

    r4133 r4168  
    77using Jypeli.Widgets; 
    88 
    9 // apuva lista:|  toinen pelaaja |   portti kentästä toiseen ja takaisin    | 
     9// apuva lista: 
    1010 
    1111public class Protokolla236 : PhysicsGame 
     
    2929    Image Block121 = LoadImage("Block121"); 
    3030    private Image[] Blockanim = LoadImages("Block1.1", "Block1.2", "Block1.3", "Block1.2"); 
     31    private Image[] Block06anim = LoadImages("Block06", "Block061", "Block062", "Block063","Block064","Block063","Block062","Block063","Block061"); 
    3132 
    3233    private Image[] vihu1 = LoadImages("vihu01", "vihu02"); 
     
    4041    SoundEffect raketti = LoadSoundEffect("raketti"); 
    4142    List<Pelaaja> pelaajat = new List<Pelaaja>(); 
     43    Timer MessageDisplaynAjastin; 
    4244 
    4345    //AssaultRifle pelaajan1Ase; 
     
    5557    public override void Begin() 
    5658    { 
    57  
     59        MessageDisplay.Position += new Vector(Screen.Width / 2, 0); 
     60         
     61        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 
     62"yksinpeli tarina (1P)","selviytyminen (2P)", "Lopeta"); 
     63        Add(alkuValikko); 
     64 
     65        alkuValikko.AddItemHandler(0, AloitaPeli); 
     66        alkuValikko.AddItemHandler(1, selviytyminen); 
     67        alkuValikko.AddItemHandler(2, Exit); 
     68        MediaPlayer.Play(soitin[0]); 
     69         
     70    } 
     71    void AloitaPeli() 
     72    { 
    5873        ClearAll(); 
    5974 
    6075        seuraavakentta(); 
    6176 
    62         //lisaaohjaimet(); 
    63          
    64  
    65  
    66         MediaPlayer.Play(soitin[0]); 
    6777        MediaPlayer.IsRepeating = true; 
    6878 
     
    7080        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null); 
    7181    } 
     82 
     83    void selviytyminen() 
     84    { 
     85        MediaPlayer.Play(soitin[2]); 
     86        kenttaNro = 5; 
     87        AloitaPeli(); 
     88    } 
     89 
    7290    void luokentta(string kenttakuva) 
    7391    { 
    7492        ColorTileMap ruudut = ColorTileMap.FromLevelAsset(kenttakuva); 
    75         //BD87FF 
     93        //FFA8AC 
    7694        ruudut.SetTileMethod(Color.FromHexCode("00FF00"), luopelaaja1); 
    7795        ruudut.SetTileMethod(Color.FromHexCode("00FFC5"), luopelaaja2); 
     
    83101        ruudut.SetTileMethod(Color.FromHexCode("D9FF93"), luotaso, (Animation)Blocklasi); 
    84102        ruudut.SetTileMethod(Color.FromHexCode("FF42C0"), luotausta, new Animation(Blockanim)); 
     103        ruudut.SetTileMethod(Color.FromHexCode("B7FF9E"), luotausta, new Animation(Block06anim)); 
    85104        ruudut.SetTileMethod(Color.FromHexCode("42B9FF"), luotausta, (Animation)BlockMusta); 
    86105        ruudut.SetTileMethod(Color.FromHexCode("00FF90"), luotausta, (Animation)Block021); 
     
    91110        ruudut.SetTileMethod(Color.FromHexCode("A860FF"), luoportti, new Animation(porttianim)); 
    92111        ruudut.SetTileMethod(Color.FromHexCode("BD87FF"), luoportti2, new Animation(porttianim)); 
     112        ruudut.SetTileMethod(Color.FromHexCode("6DFF81"), luoportti3, new Animation(porttianim)); 
     113        ruudut.SetTileMethod(Color.FromHexCode("FFA8AC"), luoportti4, new Animation(porttianim)); 
    93114        ruudut.Execute(50, 50); 
    94115 
    95116        Gravity = new Vector(0.0, -200.0); 
    96117        Level.CreateBorders(0.5, true); 
     118        
    97119        Camera.Follow(pelaajat.ToArray()); 
    98120    } 
     121 
     122     
     123 
    99124    void seuraavakentta() 
    100125    { 
    101126        ClearAll(); 
    102  
    103         if (kenttaNro == 1) luokentta("kentta121"); 
    104         else if (kenttaNro == 2) luokentta("kentta3"); 
    105         else if (kenttaNro == 3) luokentta("kenttatest03"); 
    106         else if (kenttaNro == 4) luokentta("kentta4"); 
     127        pelaajat.Clear(); 
     128 
     129        if (kenttaNro == 1) luokentta("kenttatest01"); 
     130        else if (kenttaNro == 2) luokentta("kenttatest11"); 
     131        else if (kenttaNro == 3) luokentta("kentta3"); 
     132        else if (kenttaNro == 4) luokentta("kentta5"); 
    107133        else if (kenttaNro == 5) luokentta("kentta121"); 
    108         else if (kenttaNro > 5) Exit(); 
     134        else if (kenttaNro == 6) luokentta("kentta1"); 
    109135 
    110136    } 
     
    129155        portti2.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 
    130156    } 
    131      
     157    void luoportti3(Vector paikka, double leveys, double korkeus, Animation kuva) 
     158    { 
     159        PhysicsObject portti3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     160        portti3.Position = paikka; 
     161        portti3.Tag = "portti3"; 
     162        Add(portti3); 
     163        portti3.Animation = kuva; 
     164        portti3.Animation.Start(); 
     165        portti3.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 
     166    } 
     167    void luoportti4(Vector paikka, double leveys, double korkeus, Animation kuva) 
     168    { 
     169        PhysicsObject portti3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     170        portti3.Position = paikka; 
     171        portti3.Tag = "portti4"; 
     172        Add(portti3); 
     173        portti3.Animation = kuva; 
     174        portti3.Animation.Start(); 
     175        portti3.Animation.FPS = RandomGen.NextDouble(3.0, 7.0); 
     176    } 
    132177 
    133178 
    134179    void portti(PhysicsObject pelaaja, PhysicsObject portti) 
    135180    { 
    136         if (portti.Tag.Equals("portti2")) 
    137         { 
    138             kenttaNro = 3; 
     181        if (portti.Tag.Equals("portti4")) 
     182        { 
     183            kenttaNro = 6; 
    139184            seuraavakentta(); 
    140185        } 
    141         else kenttaNro = 2; 
     186 
     187        else if (portti.Tag.Equals("portti3")) 
     188        { 
     189            kenttaNro = 4; 
     190            seuraavakentta(); 
     191        } 
     192         else if (portti.Tag.Equals("portti2")) 
     193        { 
     194            kenttaNro = 2; 
     195            seuraavakentta(); 
     196        } 
     197        else kenttaNro = 3; 
    142198        seuraavakentta(); 
    143199         
     
    187243    } 
    188244 
     245    void TekstiaDisplaylle(string tekst) 
     246    { 
     247        MessageDisplay.Add(tekst); 
     248        MessageDisplaynAjastin = new Timer(); 
     249        MessageDisplaynAjastin.Timeout += delegate { MessageDisplay.Clear(); }; 
     250        MessageDisplaynAjastin.Interval = 5; 
     251        MessageDisplaynAjastin.Start(1); 
     252    } 
     253 
     254 
    189255    void ElamaLoppui() 
    190256    { 
    191         foreach (var item in pelaajat) 
    192         { 
    193             item.Destroy(); 
    194         } 
    195257        pelaajat.Clear(); 
    196         if (pelaajat.Count > 1) 
    197         { 
    198             seuraavakentta(); 
    199         } 
    200         MessageDisplay.Add("Kuolit!"); 
     258 
     259        TekstiaDisplaylle("Kuolit!"); 
     260 
    201261        kenttaNro = 1; 
    202262        seuraavakentta(); 
     
    204264 
    205265 
     266    void ElamaLoppuiSurvivalissa() 
     267    { 
     268        foreach (var item in pelaajat) 
     269        { 
     270            if (!item.IsDestroyed) 
     271                item.Destroy(); 
     272        } 
     273        pelaajat.Clear(); 
     274        TekstiaDisplaylle("Kuolitte!"); 
     275        seuraavakentta(); 
     276 
     277 
     278    } 
     279 
     280 
    206281    Pelaaja alustaPelaaja(Vector paikka) 
    207282    { 
    208283        Pelaaja pelaaja = new Pelaaja(50, 50); 
    209         pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppui();  }; 
     284        if(kenttaNro == 5) 
     285            pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppuiSurvivalissa(); }; 
     286        else pelaaja.ElamaLaskuri.LowerLimit += delegate { ElamaLoppui();  }; 
    210287        pelaaja.Position = paikka; 
    211288        pelaaja.CanRotate = false; 
     
    224301        AddCollisionHandler(pelaaja, "portti", portti); 
    225302        AddCollisionHandler(pelaaja, "portti2", portti); 
     303        AddCollisionHandler(pelaaja, "portti3", portti); 
     304        AddCollisionHandler(pelaaja, "portti4", portti); 
    226305        AddCollisionHandler(pelaaja, "vihu", PelaajaOsuu); 
    227306        AddCollisionHandler(pelaaja, "sikio", PelaajaOsuu); 
     
    286365        Pelaaja pelaaja = luoPelaaja(paikka, leveys, korkeus); 
    287366        LuoElamaLaskuri(pelaaja, Screen.Right - 150, Screen.Top - 20, Color.Blue); 
    288         //pelaaja.Image = LoadImage("pelaaja2.0"); 
     367        pelaaja.Image = LoadImage("pelaaja2.0"); 
    289368        //-2-2-2-2-2-2-2--22-2-2-2-2-22-2-22-2-22-22-2-22-22--22-22-2-2-2-2-2-2-22-22-2---------- 
    290369        Keyboard.Listen(Key.A, ButtonState.Down, kaannaPelaajaa, null, 5.0, pelaaja); 
    291370        Keyboard.Listen(Key.D, ButtonState.Down, kaannaPelaajaa, null, -5.0, pelaaja); 
    292371        Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, null, 900.0, pelaaja); 
    293         Keyboard.Listen(Key.Q, ButtonState.Down, AmmuAseella, null, pelaaja.Ase); 
     372        Keyboard.Listen(Key.LeftControl, ButtonState.Down, AmmuAseella, null, pelaaja.Ase); 
    294373 
    295374        //----------------------------------------------------------------- 
     
    367446        vihu.AngularDamping = 0.1; 
    368447        vihu.IgnoresGravity = true; 
     448 
    369449 
    370450        Add(vihu, 1); 
  • 2013/24/AleksanteriV/Protokolla236/Protokolla236/Protokolla236Content/Protokolla236Content.contentproj

    r4133 r4168  
    447447    </Compile> 
    448448  </ItemGroup> 
     449  <ItemGroup> 
     450    <Compile Include="pelaaja2.0.png"> 
     451      <Name>pelaaja2.0</Name> 
     452      <Importer>TextureImporter</Importer> 
     453      <Processor>TextureProcessor</Processor> 
     454    </Compile> 
     455  </ItemGroup> 
     456  <ItemGroup> 
     457    <Compile Include="Block06.png"> 
     458      <Name>Block06</Name> 
     459      <Importer>TextureImporter</Importer> 
     460      <Processor>TextureProcessor</Processor> 
     461    </Compile> 
     462    <Compile Include="Block061.png"> 
     463      <Name>Block061</Name> 
     464      <Importer>TextureImporter</Importer> 
     465      <Processor>TextureProcessor</Processor> 
     466    </Compile> 
     467    <Compile Include="Block062.png"> 
     468      <Name>Block062</Name> 
     469      <Importer>TextureImporter</Importer> 
     470      <Processor>TextureProcessor</Processor> 
     471    </Compile> 
     472    <Compile Include="Block063.png"> 
     473      <Name>Block063</Name> 
     474      <Importer>TextureImporter</Importer> 
     475      <Processor>TextureProcessor</Processor> 
     476    </Compile> 
     477    <Compile Include="Block064.png"> 
     478      <Name>Block064</Name> 
     479      <Importer>TextureImporter</Importer> 
     480      <Processor>TextureProcessor</Processor> 
     481    </Compile> 
     482  </ItemGroup> 
     483  <ItemGroup> 
     484    <Compile Include="kenttatest11.png"> 
     485      <Name>kenttatest11</Name> 
     486      <Importer>TextureImporter</Importer> 
     487      <Processor>TextureProcessor</Processor> 
     488    </Compile> 
     489  </ItemGroup> 
     490  <ItemGroup> 
     491    <Compile Include="kentta5.png"> 
     492      <Name>kentta5</Name> 
     493      <Importer>TextureImporter</Importer> 
     494      <Processor>TextureProcessor</Processor> 
     495    </Compile> 
     496  </ItemGroup> 
     497  <ItemGroup> 
     498    <Compile Include="kentta5000.png"> 
     499      <Name>kentta5000</Name> 
     500      <Importer>TextureImporter</Importer> 
     501      <Processor>TextureProcessor</Processor> 
     502    </Compile> 
     503  </ItemGroup> 
    449504  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    450505  <!--  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.