Esempio n. 1
0
    public void Save()
    {
        BinaryFormatter bf  = new BinaryFormatter();
        FileStream      fs  = File.Create(Application.persistentDataPath + "/" + saveFile);
        CoreDataO       cdO = new CoreDataO(this.hp, this.xp, this.lvl);

        bf.Serialize(fs, cdO);
        fs.Close();
    }
Esempio n. 2
0
    public void Load(string fileName)
    {
        string path = Application.persistentDataPath + "/" + fileName;

        saveFile = fileName;
        if (File.Exists(path))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(path, FileMode.Open);
            CoreDataO       cd   = (CoreDataO)bf.Deserialize(file);
            file.Close();
            SetFields(cd);
            lvl = cd.lvl;
            Application.LoadLevel(lvl);
        }
        else
        {
            Debug.LogError("No File found of name: " + fileName);
        }
    }
Esempio n. 3
0
 private void SetFields(CoreDataO cd)
 {
     this.hp = cd.health;
     this.xp = cd.xp;
 }