Beispiel #1
0
 public void viewHighScores()
 {
     try
     {
         using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
         {
             IFormatter formatter = new BinaryFormatter();
             highScores = (HighScores)formatter.Deserialize(fileStream);
         }
     }
     catch (Exception ex)
     {
         FileName = "ZombieApocalypse";
     }
 }
Beispiel #2
0
        public Winner(Hero hero)
        {
            InitializeComponent();
            player.URL = "win.mp3";
            player.controls.play();
            this.hero      = hero;
            DoubleBuffered = true;
            width          = this.Width;
            height         = this.Height;

            Invalidate(true);

            highScores = null;
            try
            {
                using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                {
                    IFormatter formatter = new BinaryFormatter();
                    highScores = (HighScores)formatter.Deserialize(fileStream);
                }
            }
            catch (Exception ex)
            {
                FileName   = "ZombieApocalypse";
                highScores = new HighScores();
            }


            Invalidate(true);
            highScores.add(hero.Kills, hero.Name);
            r               = new Random();
            timer3          = new Timer();
            timer3.Interval = 50;
            timer3.Tick    += new EventHandler(timer3_tick);
            timer3.Start();
            using (FileStream fileStream = new FileStream(FileName, FileMode.Create))
            {
                IFormatter formatter = new BinaryFormatter();
                formatter.Serialize(fileStream, highScores);
            }
            this.BackgroundImage  = Properties.Resources.picgr;
            BackgroundImageLayout = ImageLayout.Stretch;
        }