public HighScoreViewModel(HighScoreWindow window)
 {
     this.window    = window;
     this.container = getContainer();
     this.window.Scores.ItemsSource = container.GetRecords();
     this.BackCommand = new CommandBase(this.ExecuteBackCommand, this.CanExecuteBackCommand);
 }
Exemplo n.º 2
0
 public static void Load()
 {
     if (File.Exists(Application.persistentDataPath + "/" + fileName))
     {
         string json = File.ReadAllText(Application.persistentDataPath + "/" + fileName);
         _scores = JsonUtility.FromJson <HighScoreContainer>(json);
         Debug.Log("Loading from: " + Application.persistentDataPath + "/" + fileName + "\nJson: " + json);
     }
 }
Exemplo n.º 3
0
    public void Save(HighScoreContainer saveData)
    {
        string path = Application.persistentDataPath + PathData.FilePath;

        using (FileStream fs = File.Create(path)) {
            using (BinaryWriter writer = new BinaryWriter(fs)) {
                saveData.Write(writer);
            }
        }
    }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static TreasureUser Beginner()
 {
     return(new TreasureUser
     {
         Name = "Beginner",
         FrequencyDelta = 3000,
         CurrentLevel = 1,
         Scores = HighScoreContainer.Default()
     });
 }
Exemplo n.º 5
0
 private void SaveContainer(HighScoreContainer container, RecordSerializer serilizer)
 {
     try
     {
         serilizer.Serialize(container);
     }
     catch (RecordSerializationException)
     {
         //Log Error
         return;
     }
 }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static TreasureUser Expert()
        {
            var GG = new TreasureUser
            {
                Name           = "Expert",
                FrequencyDelta = 4500,
                CurrentLevel   = 10,
                Scores         = HighScoreContainer.Default()
            };

            return(GG);
        }
Exemplo n.º 7
0
        private void SaveScore(string name, int points)
        {
            BinaryFormatter  formatter = new BinaryFormatter();
            string           fileName  = GlobalConstants.ScorFilePath;
            RecordSerializer serilizer = new RecordSerializer(formatter, fileName);

            HighScoreContainer container = GetContainer(serilizer);

            Player player = new Player(DateTime.Now, name, points);

            container.Add(player);

            SaveContainer(container, serilizer);
        }
Exemplo n.º 8
0
    public HighScoreContainer Load()
    {
        HighScoreContainer highScoreContainer = new HighScoreContainer();

        string path = Application.persistentDataPath + PathData.FilePath;

        if (File.Exists(path))
        {
            using (FileStream fs = File.OpenRead(path)) {
                using (BinaryReader reader = new BinaryReader(fs)) {
                    highScoreContainer.Read(reader);
                }
            }
        }

        return(highScoreContainer);
    }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 public TreasureUser()
 {
     this._userType     = UserType.Stereotype;
     this._Name         = "";
     this._FqTraining   = 2500;
     this._FqDelta      = 0;
     this._FqComparison = 0;
     this._currLevel    = 1;
     this._currLife     = 4;
     this._currGold     = 0;
     this._currScore    = 0;
     this._currTarget   = 0;
     this._maxTarget    = 0;
     this._currExposure = 0;
     this._nbActions    = 0;
     this._showDebug    = false;
     this._scores       = new HighScoreContainer();
     this.Pattern       = new WinPattern();
     this.VisualTiming  = new Gates();
 }
Exemplo n.º 10
0
 private void Awake()
 {
     saveService        = GetComponent <IHighscoreSaveService>();
     loadService        = GetComponent <IHighscoreLoadService>();
     highScoreContainer = loadService.Load();
 }