Exemple #1
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     graphicsLib = new GraphicsLib(Content); // ladataan grafiikkakirjasto
     soundsLib   = new SoundsLib(Content);
     menuControl = new MenuControl(spriteBatch, soundsLib.menuSound, graphicsLib);
     popup       = new Popup(spriteBatch, graphicsLib.text, graphicsLib.popup);
     highScores  = HighScores.Load("Content/hiscores.xml");
     highScores.Sort();
 }
Exemple #2
0
        /// <summary>
        /// Ladataan highscore -listan tulokset
        /// </summary>
        /// <param name="filename">tiedoston nimi</param>
        /// <returns>highscore-listan</returns>
        public static HighScores Load(string filename)
        {
            if (File.Exists(filename))
            {
                Stream        stream     = File.OpenRead(filename);
                XmlSerializer serializer = new XmlSerializer(typeof(HighScores));
                HighScores    Scores     = (HighScores)serializer.Deserialize(stream);
                stream.Close();
                return(Scores);
            }
            else
            {
                //alustetaan lista, jos aikaisempaa listaa ei ole olemassa
                HighScores defaultScores = new HighScores();

                for (int i = 0; i < 20; i++)
                {
                    defaultScores.names[i] = "John Doe";
                    defaultScores.kills[i] = 0;
                }
                return(defaultScores);
            }
        }
Exemple #3
0
 /// <summary>
 /// Lisää highscore -listaan uuden tuloksen
 /// </summary>
 /// <param name="gameTime"></param>
 /// <param name="highScores"></param>
 private void AddHighScore(GameTime gameTime, HighScores highScores)
 {
     highScores.AddScore(popup.Name, kills);
     highScoreEntered = true;
 }