Ejemplo n.º 1
0
 public void saveHighScore(string filename)
 {
     HighScore highScore = new HighScore();
     try
     {
         StreamWriter sr = new StreamWriter(File.Open(filename, FileMode.Create));
         foreach (KeyValuePair<int,HighScoreItem> item in highScores)
         {
             sr.WriteLine(item.Value.printToFile());
         }
         sr.Close();
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.Message);
         System.Windows.Forms.Application.Exit();
     }
 }
Ejemplo n.º 2
0
 public static HighScore loadHighScore( string filename )
 {
     HighScore highScore = new HighScore();
     string line;
     string[] lineItem;
     try
     {
         StreamReader sr = new StreamReader(File.Open(filename, FileMode.Open));
         line = "";
         while ((line = sr.ReadLine()) != null)
         {
             lineItem = line.Split(';');
             highScore.addHighScoreItem(lineItem[0],Convert.ToInt32(lineItem[1]),Convert.ToInt32(lineItem[2]));
         }
         sr.Close();
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.Message);
         System.Windows.Forms.Application.Exit();
     }
     return highScore;
 }
Ejemplo n.º 3
0
        private void TetrisForm_Load(object sender, EventArgs e)
        {
            pbTetrisMap.Image = new Bitmap(TetrisForm.MAP_X, TetrisForm.MAP_Y);
            pbTetrisMap.SizeMode = PictureBoxSizeMode.StretchImage;

            pbFallItem.Image = new Bitmap(TetrisForm.FALLITEM_X, TetrisForm.FALLITEM_Y);
            pbFallItem.SizeMode = PictureBoxSizeMode.StretchImage;

            Level.initLevel();
            for (int i = 0; i < Level.MAX_LEVEL; i++)
            {
                cbLevel.Items.Add(Level.levelItems[i]);
            }
            if (cbLevel.Items.Count > 0)
            {
                cbLevel.SelectedIndex = 0;
            }

            kmf = new KeyMessageFilter();
            Application.AddMessageFilter(kmf);

            highScore = HighScore.loadHighScore(HighScore.HIGH_SCORE_FILE_NAME);

            this.initHighScore();

            initTetrisMap();
        }