Changeset 2407


Ignore:
Timestamp:
2011-07-01 11:54:06 (12 years ago)
Author:
jojumuho
Message:

Talletus.

Location:
2011/26/JouniM/MatoPeli/MatoPeli
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/JouniM/MatoPeli/MatoPeli/MatoPeli/Peli.cs

    r2370 r2407  
    1818    Timer aikaLaskuri; 
    1919    IntMeter pisteLaskuri; 
    20  
     20    int SaaliidenMaara = 0; 
    2121    Image MadonKuva = LoadImage("Mato"); 
    2222    Image SaaliinKuva = LoadImage("Saalis"); 
    2323    Image GameOver = LoadImage("game over"); 
     24    Image taustaKuva = LoadImage("taustakuva"); 
     25 
     26    ScoreList topLista = new ScoreList(10, false, 0); 
     27 
     28 
    2429 
    2530    bool kuolematon = false; 
     
    4045        aikaLaskuri.Interval = 0.1; 
    4146        aikaLaskuri.Trigger += LaskeAlaspain; 
     47 
     48        MediaPlayer.Play("duck hunt"); 
     49 
     50        if (DataStorage.Exists("pisteet.xml")) 
     51            topLista = DataStorage.Load<ScoreList>(topLista, "pisteet.xml"); 
     52 
    4253 
    4354        Aloitapeli(); 
     
    5162        LuoMato(); 
    5263        AsetaOhjaimet(); 
     64        SaaliidenMaara = 0; 
    5365        LuoSaalis(20, 30); 
    5466        LuoLaskuri(); 
     
    5971 
    6072 
     73 
    6174    } 
    6275 
     
    6578        Level.CreateBorders(); 
    6679        Camera.ZoomToLevel(); 
    67  
    68  
     80        Level.Background.Image = taustaKuva; 
     81        Level.Background.FitToLevel(); 
     82        Level.Background.FitToLevel(); 
    6983    } 
    7084 
     
    88102            kohde.Destroy(); 
    89103            SaalisDestroyed(); 
     104            
    90105        } 
    91106 
     
    136151        Saalis.Tag = "saalis"; 
    137152        Saalis.Image = SaaliinKuva; 
     153        SaaliidenMaara++; 
    138154        Add(Saalis); 
    139155        Saalis.Shape = Shape.Star; 
     
    155171    void SaalisDestroyed() 
    156172    { 
    157         LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 
    158         LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 
     173        SaaliidenMaara--; 
     174        if (SaaliidenMaara < 10) 
     175        { 
     176            LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 
     177            LuoSaalis(RandomGen.NextDouble(Level.Left, Level.Right), RandomGen.NextDouble(Level.Bottom, Level.Top)); 
     178        } 
    159179        pisteLaskuri.Value = pisteLaskuri.Value + 1 ; 
    160180        // KasvataMatoa(); 
     
    214234        PhysicsObject Vihollinen = new PhysicsObject(new RaySegment(position, suunta, 2000)); 
    215235        Vihollinen.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
    216         Vihollinen.Color = Color.Red; 
     236        Vihollinen.Color = Color.Yellow; 
    217237        AddCollisionHandler(Vihollinen, KasitteleVihollisenTormays); 
    218238        Add(Vihollinen); 
     
    225245        { 
    226246            kohde.Destroy(); 
     247            PeliLoppui(); 
    227248        } 
    228249    } 
     
    247268        if (alaspainLaskuri.Value <= 0) 
    248269        { 
    249             MessageDisplay.Add("Peli Loppui"); 
    250270            timer.Stop(); 
     271            PeliLoppui(); 
     272 
     273            // täydennä mitä tapahtuu, kun aika loppuu 
     274        } 
     275    } 
     276 
     277 
     278    void uudestaan() 
     279    { 
     280        ClearAll(); 
     281 
     282        Aloitapeli(); 
     283    } 
     284 
     285 
     286    void PeliLoppui() 
     287    { 
     288          MessageDisplay.Add("Peli Loppui"); 
     289          ajastin.Stop(); 
    251290            ClearAll(); 
     291            Keyboard.Listen(Key.R, ButtonState.Released, uudestaan, "aloitus"); 
    252292            Widget lopputeksti = new Widget(Screen.Width, Screen.Height); 
    253293            lopputeksti.Image = GameOver; 
    254294            Add(lopputeksti); 
    255295 
    256             // täydennä mitä tapahtuu, kun aika loppuu 
    257         } 
    258     } 
    259  
    260  
    261     void uudestaan() 
    262     { 
    263         ClearAll(); 
    264  
    265         Aloitapeli(); 
     296            HighScoreWindow topIkkuna = new HighScoreWindow("Pelin nimi tai jotain", 
     297                                 "Parhaat pisteet", 
     298                                 "Onneksi olkoon, pääsit listalle pisteillä %p! Syötä nimesi:", 
     299                                 topLista, pisteLaskuri.Value); 
     300            topIkkuna.Closed += TallennaPisteet; 
     301            Add(topIkkuna); 
     302 
     303    } 
     304 
     305    void TallennaPisteet(Window sender) 
     306    { 
     307        DataStorage.Save<ScoreList>(topLista, "pisteet.xml"); 
    266308    } 
    267309 
  • 2011/26/JouniM/MatoPeli/MatoPeli/MatoPeliContent/MatoPeliContent.contentproj

    r2370 r2407  
    6363    </Compile> 
    6464  </ItemGroup> 
     65  <ItemGroup> 
     66    <Compile Include="taustakuva.jpg"> 
     67      <Name>taustakuva</Name> 
     68      <Importer>TextureImporter</Importer> 
     69      <Processor>TextureProcessor</Processor> 
     70    </Compile> 
     71  </ItemGroup> 
     72  <ItemGroup> 
     73    <Compile Include="duck hunt.mp3"> 
     74      <Name>duck hunt</Name> 
     75      <Importer>Mp3Importer</Importer> 
     76      <Processor>SongProcessor</Processor> 
     77    </Compile> 
     78  </ItemGroup> 
    6579  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    6680  <!--  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.