Esempio n. 1
0
        public GameViewModel(Config cfg)
        {
            _currWolf              = _wolfLT;
            animator.ReadyToCatch += EggReadyToCatch;
            animator.LifeActivate += LifeActive;

            _config = cfg;

            if (File.Exists("LeaderBord.ldr"))
            {
                try
                {
                    _scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr");
                }
                catch (InvalidOperationException)
                {
                    _scores = Score.GetDeffaultScoreList();
                    CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord");
                    messageBox.ShowDialog();
                    MySerializer.SerializeXml <List <Score> >(_scores, "LeaderBord.ldr");
                }
            }
            else
            {
                _scores = Score.GetDeffaultScoreList();
            }
        }
Esempio n. 2
0
        public LeaderBordViewModel(Config cfg)
        {
            if (File.Exists("LeaderBord.ldr"))
            {
                try
                {
                    Scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr");
                }
                catch (InvalidOperationException)
                {
                    Scores = Score.GetDeffaultScoreList();
                    CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord");
                    messageBox.ShowDialog();

                    MySerializer.SerializeXml <List <Score> >(Scores, "LeaderBord.ldr");
                }
            }

            else
            {
                Scores = Score.GetDeffaultScoreList();
            }
            Scores.Sort();
            Scores.Reverse();

            _config = cfg;
        }
Esempio n. 3
0
        public void Xml_Serialization_Deserialization_Equal_Test(string serFileName)
        {
            MySerializer.SerializeXml(TestCatalog.StandardDir, serFileName);
            _desDir = MySerializer.DeserializeFromFile(serFileName, "-xml");
            File.Delete(serFileName);

            Assert.That(_desDir, Is.EqualTo(TestCatalog.StandardDir));
        }
Esempio n. 4
0
        private void ScoreCalculation()
        {
            if (CurrentScore > _scores.Min().LeaderScore)
            {
                _scores.Remove(_scores.Min());

                NewHightScore          NHS   = new NewHightScore();
                NewHightScoreViewModel NHSVM = NHS.DataContext as NewHightScoreViewModel;
                NHSVM.LeaderNameChanged += LeaderNameChanged;
                NHS.ShowDialog();
                _scores.Add(new Score(CurrentScore, _leaderName));
                MySerializer.SerializeXml <List <Score> >(_scores, "LeaderBord.ldr");
            }
        }
Esempio n. 5
0
        private void LoadSettings()
        {
            if (File.Exists($"config.cfg"))
            {
                try
                {
                    _config = MySerializer.DeserializeXml <Config>("config.cfg");
                }
                catch (InvalidOperationException)
                {
                    _config.SetDeffault();

                    CustomMessageBox messageBox = new CustomMessageBox("File config.cfg is damaged. Reset to default settings");
                    messageBox.ShowDialog();
                    MySerializer.SerializeXml <Config>(_config, "config.cfg");
                }
            }
            else
            {
                _config.SetDeffault();
            }
        }