public HighScoreViewModel(HighScoreWindow window) { this.window = window; this.container = getContainer(); this.window.Scores.ItemsSource = container.GetRecords(); this.BackCommand = new CommandBase(this.ExecuteBackCommand, this.CanExecuteBackCommand); }
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); } }
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); } } }
/// <summary> /// /// </summary> /// <returns></returns> public static TreasureUser Beginner() { return(new TreasureUser { Name = "Beginner", FrequencyDelta = 3000, CurrentLevel = 1, Scores = HighScoreContainer.Default() }); }
private void SaveContainer(HighScoreContainer container, RecordSerializer serilizer) { try { serilizer.Serialize(container); } catch (RecordSerializationException) { //Log Error return; } }
/// <summary> /// /// </summary> /// <returns></returns> public static TreasureUser Expert() { var GG = new TreasureUser { Name = "Expert", FrequencyDelta = 4500, CurrentLevel = 10, Scores = HighScoreContainer.Default() }; return(GG); }
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); }
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); }
/// <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(); }
private void Awake() { saveService = GetComponent <IHighscoreSaveService>(); loadService = GetComponent <IHighscoreLoadService>(); highScoreContainer = loadService.Load(); }