示例#1
0
        public void Deserialization()
        {
            var myFile = new FileInfo(SerializationPath);

            if (!myFile.Exists)
            {
                return;
            }
            IFormatter formatter = new BinaryFormatter();
            FileStream stream    = new FileStream(SerializationPath, FileMode.Open, FileAccess.Read);

            container = (ScoresContainer)formatter.Deserialize(stream);
            stream.Close();
        }
示例#2
0
        public void StartGame()
        {
            container = new ScoresContainer();

            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            TopMost         = true;

            min = 0;
            sec = 0;

            simpleSound.PlayLooping();


            HeroPlane = new MainHeroPlane(MainHeroPlane.PHOTOS.upDown);
            enemies   = new List <Enemies>();
            clouds    = new List <Clouds>();


            timer1.Start();
            timerGame.Start();

            isStarted = false;

            fillEnemiesList();

            fillCloudList();

            FolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PlaneCrash");
            if (!Directory.Exists(FolderPath))
            {
                Directory.CreateDirectory(FolderPath);
            }

            Console.WriteLine($"Folder Path: [{FolderPath}]");

            SerializationPath = Path.Combine(FolderPath, "points.txt");
            Console.WriteLine($"File path: [{SerializationPath}]");

            Deserialization();
        }