Changeset 4318 for 2013


Ignore:
Timestamp:
2013-06-28 12:34:50 (10 years ago)
Author:
arosrinn
Message:

Talletus.

Location:
2013/26/ArttuR/Pako
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/ArttuR/Pako/Pako/Pako/Pako.cs

    r4240 r4318  
    1010{ 
    1111    const double nopeus = 200; 
    12     const double hyppyNopeus = 750; 
     12    const double hyppyNopeus = 800; 
    1313    const int RUUDUN_KOKO = 40; 
    1414 
     
    2323    Image morkoKuva = LoadImage("morko"); 
    2424    Image maaliKuva = LoadImage("maali2"); 
     25    Image supermorkoKuva = LoadImage("supermorko"); 
     26    Image lentomorkoKuva = LoadImage("lentomorko"); 
     27    Image rajahdysKuva = LoadImage("rajahdys"); 
     28    Image tasoKuva = LoadImage("taso"); 
    2529 
    2630    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    2731 
     32    List<Label> valikonKohdat; 
     33 
    2834    public override void Begin() 
    2935    { 
    30         
    31  
     36 
     37        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", 
     38"Aloita peli", "Ohjeet" ,"Lopeta"); 
     39        Add(alkuValikko); 
    3240        //LuoKentta("kentta1"); 
    33         SeuraavaKentta(); 
     41        alkuValikko.AddItemHandler(0, SeuraavaKentta); 
     42        alkuValikko.AddItemHandler(1, NaytaOhjeet); 
     43        alkuValikko.AddItemHandler(2, Exit); 
    3444         
     45    } 
     46 
     47 
     48    void NaytaOhjeet() 
     49    { 
     50        MessageWindow ikkuna = new MessageWindow("Ohjeet"); 
     51        ikkuna.Closed += delegate { Begin(); }; 
     52 
     53        Add(ikkuna); 
     54 
     55        Label tekstia = new Label("Pelaaja liikkuu nuolilla. Yritä olla osumatta mörköihin, vaikka ne näyttävätkin söpöiltä. Ja älä tipu laavaan. \n Jos osut hirviöihin tai laavaan, kuolet ja aloitat tason alusta. Paina F1 pelin aikana nähdäksesi tarkemmin pelin näppäimet"); 
     56 
     57        ikkuna.Add(tekstia); 
     58 
    3559         
    36     } 
     60 
     61    } 
     62 
     63    void rajahdys(PhysicsObject olio) 
     64    { 
     65    /* 
     66       Explosion rajahdys = new Explosion(500); 
     67       rajahdys.UseShockWave = false; 
     68       rajahdys.Position = olio.Position; 
     69       rajahdys.Speed = 500; 
     70       Add(rajahdys); 
     71       rajahdys.Image = rajahdysKuva; 
     72     */ 
     73 
     74        for (int i = 0; i < 75; i++) 
     75        { 
     76            PhysicsObject p = new PhysicsObject(50, 50); 
     77            p.Position = olio.Position; 
     78            p.Shape = Shape.Circle; 
     79            p.Color = Color.Lerp(Color.Cyan, Color.Transparent, 0.5); 
     80            p.Hit(RandomGen.NextVector(1000, 1000)); 
     81            p.IgnoresCollisionResponse = true; 
     82            p.LifetimeLeft = TimeSpan.FromSeconds(0.5); 
     83            Add(p); 
     84        } 
     85    } 
     86 
    3787 
    3888    void LuoKentta(string kenttaTiedostonNimi) 
     
    4494        kentta.SetTileMethod('M', LisaaMaali); 
    4595        kentta.SetTileMethod('L', LisaaLaava); 
     96        kentta.SetTileMethod('S', LisaaSuperMorko); 
     97        kentta.SetTileMethod('P', LisaaLentoMorko); 
     98        kentta.Optimize('L'); 
    4699        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    47100        Level.CreateBorders(); 
     
    49102        Gravity = new Vector(0, -1000); 
    50103    } 
    51  
     104     
    52105    void LisaaLaava(Vector paikka, double leveys, double korkeus) 
    53106    { 
     
    65118        morko.Image = morkoKuva; 
    66119        morko.Tag = "vihollinen"; 
     120 
    67121        PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 
    68         tasoAivot.Speed = 100; 
     122        tasoAivot.Speed = 125; 
    69123 
    70124        morko.Brain = tasoAivot; 
    71125        Add(morko); 
    72126    } 
     127 
     128    void LisaaSuperMorko(Vector paikka, double leveys, double korkeus) 
     129    { 
     130        PlatformCharacter supermorko = new PlatformCharacter(leveys, korkeus); 
     131        supermorko.Position = paikka; 
     132        supermorko.Image =  supermorkoKuva; 
     133        supermorko.Tag = "vihollinen"; 
     134        PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 
     135        tasoAivot.Speed = 250; 
     136 
     137        supermorko.Brain = tasoAivot; 
     138        Add(supermorko); 
     139    } 
     140 
     141    
    73142 
    74143    void TormattiinLaavaan(PhysicsObject pelaaja1, PhysicsObject maali) 
     
    84153        else if (kenttaNro == 2) LuoKentta("kentta2"); 
    85154        else if (kenttaNro == 3) LuoKentta("kentta3"); 
     155        else if (kenttaNro == 4) LuoKentta("kentta4"); 
     156        else { 
     157            kenttaNro = 1; 
     158            Begin(); 
     159        } 
    86160 
    87161        LisaaNappaimet(); 
     
    90164        pisteNaytto.X = Screen.Left + 100; 
    91165        pisteNaytto.Y = Screen.Top - 100; 
     166        pisteNaytto.Title = "Kuolemat"; 
    92167        pisteNaytto.TextColor = Color.Black; 
    93168        pisteNaytto.Color = Color.White; 
     
    105180        PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    106181        taso.Position = paikka; 
    107         taso.Color = Color.Gray; 
     182        taso.Image = tasoKuva; 
     183        taso.CollisionIgnoreGroup = 1; 
    108184        Add(taso); 
    109185    } 
     
    114190    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    115191    { 
    116         pelaaja1 = new PlatformCharacter(leveys, korkeus); 
     192        pelaaja1 = new PlatformCharacter(leveys*0.5, korkeus*1); 
    117193        pelaaja1.Position = paikka; 
     194        pelaaja1.Tag = "pelaaja"; 
    118195        aloitus = paikka; 
    119196        pelaaja1.Mass = 4; 
     
    124201    } 
    125202 
     203    void LisaaLentoMorko(Vector paikka, double leveys, double korkeus) 
     204    { 
     205        PhysicsObject lentomorko = new PhysicsObject(leveys, korkeus); 
     206        lentomorko.Position = paikka; 
     207        lentomorko.Image = lentomorkoKuva; 
     208        lentomorko.Tag = "vihollinen"; 
     209        lentomorko.IgnoresCollisionResponse = true; 
     210        FollowerBrain seuraajanAivot = new FollowerBrain("pelaaja"); 
     211        seuraajanAivot.DistanceClose = 5; 
     212        seuraajanAivot.TargetClose += delegate{ TormattiinViholliseen(pelaaja1, lentomorko);}; 
     213        seuraajanAivot.Speed = 100; 
     214        seuraajanAivot.Active = true; 
     215 
     216        lentomorko.Brain = seuraajanAivot; 
     217        Add(lentomorko); 
     218    } 
     219 
    126220    void TormattiinViholliseen(PhysicsObject obj, PhysicsObject morko) 
    127221    { 
    128         obj.Position = aloitus; 
     222        if (obj.IsDestroyed) return; 
     223 
     224        rajahdys(obj); 
     225        //obj.Position = aloitus; 
    129226        kuolemaLaskuri.Value++; 
     227        obj.Destroy(); 
     228        //obj.Velocity = Vector.Zero; 
     229 
     230        Timer.SingleShot(1.0, delegate 
     231        { 
     232            SeuraavaKentta(); 
     233        }); 
    130234    } 
    131235 
     
    152256    void LisaaNappaimet() 
    153257    { 
     258 
     259 
     260 
    154261        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    155262        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     
    159266        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    160267 
    161         ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    162  
    163         ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 
    164         ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 
    165         ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    166  
    167         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     268         
    168269    } 
    169270 
     
    176277    { 
    177278        hahmo.Jump(nopeus); 
     279    } 
     280 
     281    void alkuVlikko() 
     282    { 
     283        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pako", 
     284        "Aloita peli", "Parhaat pisteet", "Lopeta"); 
     285        //alkuValikko.AddItemHandler(0, ); 
     286        //alkuValikko.AddItemHandler(1,); 
     287        alkuValikko.AddItemHandler(2, Exit); 
     288    } 
     289 
     290 
     291    void Valikko() 
     292    { 
     293        ClearAll(); 
     294 
     295        valikonKohdat = new List<Label>(); 
     296 
     297        Label kohta1 = new Label("Aloita uusi peli"); 
     298        kohta1.Position = new Vector(0, 40); 
     299        valikonKohdat.Add(kohta1); 
     300 
     301        foreach (Label valikonKohta in valikonKohdat) 
     302        { 
     303            Add(valikonKohta); 
     304        } 
    178305    } 
    179306 
  • 2013/26/ArttuR/Pako/Pako/Pako/Pako.csproj.Debug.cachefile

    r4240 r4318  
    66Content\morko.xnb 
    77Content\kentta3.xnb 
     8Content\kentta4.xnb 
     9Content\supermorko.xnb 
     10Content\lentomorko.xnb 
     11Content\rajahdys.xnb 
     12Content\taso.xnb 
  • 2013/26/ArttuR/Pako/Pako/PakoContent/PakoContent.contentproj

    r4240 r4318  
    9292    </Compile> 
    9393  </ItemGroup> 
     94  <ItemGroup> 
     95    <Compile Include="kentta4.txt"> 
     96      <Name>kentta4</Name> 
     97      <Importer>TextFileImporter</Importer> 
     98      <Processor>TextFileContentProcessor</Processor> 
     99    </Compile> 
     100  </ItemGroup> 
     101  <ItemGroup> 
     102    <Compile Include="supermorko.png"> 
     103      <Name>supermorko</Name> 
     104      <Importer>TextureImporter</Importer> 
     105      <Processor>TextureProcessor</Processor> 
     106    </Compile> 
     107  </ItemGroup> 
     108  <ItemGroup> 
     109    <Compile Include="lentomorko.png"> 
     110      <Name>lentomorko</Name> 
     111      <Importer>TextureImporter</Importer> 
     112      <Processor>TextureProcessor</Processor> 
     113    </Compile> 
     114  </ItemGroup> 
     115  <ItemGroup> 
     116    <Compile Include="rajahdys.png"> 
     117      <Name>rajahdys</Name> 
     118      <Importer>TextureImporter</Importer> 
     119      <Processor>TextureProcessor</Processor> 
     120    </Compile> 
     121  </ItemGroup> 
     122  <ItemGroup> 
     123    <Compile Include="taso.png"> 
     124      <Name>taso</Name> 
     125      <Importer>TextureImporter</Importer> 
     126      <Processor>TextureProcessor</Processor> 
     127    </Compile> 
     128  </ItemGroup> 
    94129  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    95130  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2013/26/ArttuR/Pako/Pako/PakoContent/kentta1.txt

    r4240 r4318  
    1313                       K       ## 
    1414                  ########## 
    15        N               
     15P      N               
    1616      ########## 
    1717 
  • 2013/26/ArttuR/Pako/Pako/PakoContent/kentta2.txt

    r4240 r4318  
    1010                       K                        
    1111                      #######                        
    12                                           N   
     12                                          N       P 
    1313                                ###    #####               
    1414                                              
  • 2013/26/ArttuR/Pako/Pako/PakoContent/kentta3.txt

    r4240 r4318  
    1616                                                                                       
    1717                                           ##                                            
    18                              K    K   ##                                                   
    19                          ############                                                             
    20                                                                                        
    21                     #                                                                
    22       N        ##                                                                     
     18                              S       ##                                                   
     19                     ##  ############                                                             
     20  P     N       ##                                                                     
    2321   ########                                                                                    
    2422                                                                                       
Note: See TracChangeset for help on using the changeset viewer.