예제 #1
0
    public void SaveToFile(string fileName)
    {
        if (fileName == "" || fileName == null)
        {
            Debug.Log("No file specified to save");
            return;
        }
        EasyFileSave saveFile = new EasyFileSave(fileName);

        Debug.Log("Filename:" + saveFile.GetFileName());
        try
        {
            object[] obj = Resources.FindObjectsOfTypeAll <SerializedObject>(); //this ensures disabled object are also considered
            //object[] obj = Resources.FindObjectsOfType(typeof (SerializedObject)); //this ignores disabled objects
            foreach (object o in obj)
            {
                SerializedObject g = (SerializedObject)o;
                if (g.UUID == "")
                {
                    continue;
                }

                saveFile.AddBinary(g.UUID, g.getSaveData());
                //Debug.Log(g.UUID + " is saved");
            }
            saveFile.Save();
            PlayerPrefs.SetString("LastCheckPoint", fileName);
            PlayerPrefs.Save();
            Debug.Log("saving done");
        } catch (Exception e) {
            Debug.Log("Exception while saving file:" + e);
        } finally {
            saveFile.Dispose();
        }
    }
    public HeroeBase LoadHeroe(HeroeBase heroe)
    {
        EasyFileSave miarchivo = new EasyFileSave(heroe.nombre);

        if (miarchivo.Load())
        {
            heroe.vidaActual   = miarchivo.GetInt("HeroeVidaActual");
            heroe.vidaBase     = miarchivo.GetInt("HeroeVidaBase");
            heroe.manaActual   = miarchivo.GetInt("HeroeManaActual");
            heroe.manaBase     = miarchivo.GetInt("HeroeManaBase");
            heroe.fuerza       = miarchivo.GetInt("HeroeFuerza");
            heroe.inteligencia = miarchivo.GetInt("HeroeInteligencia");
            heroe.resistenciaF = miarchivo.GetInt("HeroeResistenciaF");
            heroe.resistenciaM = miarchivo.GetInt("HeroeResistenciaM");
            heroe.velocidad    = miarchivo.GetInt("HeroeVelocidad");

            heroe.cantidadXP = miarchivo.GetFloat("HeroeXP");
            heroe.nivel      = miarchivo.GetInt("HeroeNivel");

            Debug.Log(heroe.nombre + " Cargado");

            miarchivo.Dispose();
        }
        else
        {
            Debug.LogWarning("Fallo al cargar " + heroe.nombre);
        }

        return(heroe);
    }
예제 #3
0
    private void Awake()
    {
        EasyFileSave myFile = new EasyFileSave();

        Debug.Log("persistant save location " + Application.persistentDataPath);
        Debug.Log("data save location " + Application.dataPath);

        CloudOnce.Cloud.Storage.Load();

        if (myFile.Load())
        {
            player.level              = myFile.GetInt("PlayerLevel");
            player.playerExp          = myFile.GetFloat("PlayerExp");
            player.goalExp            = myFile.GetFloat("GoalExp");
            player.gold               = myFile.GetInt("PlayerGold");
            player.diamond            = myFile.GetInt("PlayerDiamond");
            player.skipForward        = myFile.GetInt("PlayerSkipForward");
            player.monsterKillRecord  = myFile.GetInt("MonsterKillRecord");
            player.playerTotalCP      = myFile.GetInt("PlayerTotalScore");
            player.StartScene         = myFile.GetBool("StartScene");
            soundManager.masterVolume = myFile.GetFloat("Volume");
            soundManager.isMute       = myFile.GetBool("VolumeSprite");
            player.CollectionItemsId  = myFile.GetList <int>("PlayerCollection");
            player.SkillItemsId       = myFile.GetList <int>("PlayerSkills");
            player.DialogueProgress   = myFile.GetList <int>("PlayerProgress");
        }

        myFile.Dispose();

        // Cloud Save
    }
        public void Delete(string name)
        {
            EasyFileSave file = new EasyFileSave(name);

            file.Delete();
            DeleteFromFileNames(name);
        }
    public void LoadOpciones()
    {
        EasyFileSave miarchivo = new EasyFileSave("Opciones");

        if (miarchivo.Load() && miarchivo.FileExists())
        {
            if (miarchivo.KeyExists("Musica"))
            {
                GameObject.FindGameObjectWithTag("Musica").GetComponent <AudioSource>().volume = miarchivo.GetFloat("Musica");
            }

            if (miarchivo.KeyExists("SFX"))
            {
                GameObject.FindGameObjectWithTag("Audio").GetComponent <AudioSource>().volume = miarchivo.GetFloat("SFX");
            }

            Debug.Log("Opciones Cargado");

            miarchivo.Dispose();
        }
        else
        {
            Debug.LogWarning("Fallo al cargar Opciones");
        }
    }
예제 #6
0
    /** Save level before going to next */
    public bool SaveLevel(int level, int score, int timer)
    {
        savedName = currentUserName();
        if (savedName != null)
        {
            myFile = new EasyFileSave(savedName);
            if (myFile.Load())
            {
                Debug.Log("Level: " + level + " score: " + score + " Name:" + savedName + " Time: " + timer);
                myFile.Add("username", savedName);
                myFile.Add("level", level);
                myFile.Add("score", score);
                myFile.Add("timer", timer);
                if (myFile.Save())
                {
                    myFile.Dispose(); return(true);
                }
                else
                {
                    return(false);
                }
            }
        }

        return(false);
    }
    public void SaveBreak(int cantidad, float barra)
    {
        EasyFileSave miarchivo = new EasyFileSave("Break");

        miarchivo.Add("barra", barra);
        miarchivo.Add("cantidad", cantidad);

        miarchivo.Save();
    }
예제 #8
0
    void Start()
    {
        // Start a new instance of Easy File Save. The file name is not specified, so a default name will be used.

        myFile = new EasyFileSave();

        // If this file already exists for some reason, I delete it.

        myFile.Delete();
    }
    public void SaveOpciones(float valorMusica, float valorSFX)
    {
        EasyFileSave miarchivo = new EasyFileSave("Opciones");

        miarchivo.Add("Musica", valorMusica);
        miarchivo.Add("SFX", valorSFX);

        miarchivo.Save();
        Debug.Log("Opciones Guardado");
    }
        public void Save(TextAsset asset)
        {
            EasyFileSave file = new EasyFileSave(asset.name);

            file.Add("text", asset.text);
            file.Save();
            if (!allFileNames.Contains(asset.name))
            {
                AddToFileNames(asset.name);
            }
        }
예제 #11
0
    void Start()
    {
        // Start a new instance of Easy File Save. The file name is not specified, so a default name will be used.

        myFile = new EasyFileSave();
        myFile.suppressWarning = false;

        // If this file already exists for some reason, I delete it.

        myFile.Delete();

        Debug.Log(">> HELLO! I'M READY!" + "\n");
    }
예제 #12
0
 /** Return current user name from currentUser.dat  */
 public string currentUserName()
 {
     currentFile = new EasyFileSave("currentUserFile");
     if (currentFile.Load())
     {
         testName = currentFile.GetString("currentUser");
         return(testName);
     }
     else
     {
         return(null);
     }
 }
예제 #13
0
 /********** Getter for Level **********/
 public int GetCurrentLevel()
 {
     savedName = currentUserName();
     if (savedName != null)
     {
         myFile = new EasyFileSave(savedName);
         if (myFile.Load())
         {
             return(myFile.GetInt("level"));
         }
     }
     return(0);
 }
        public TextAsset Load(string name)
        {
            EasyFileSave file = new EasyFileSave(name);

            if (file.Load())
            {
                TextAsset asset = new TextAsset(file.GetString("text"));
                asset.name = name;
                file.Dispose();
                return(asset);
            }
            throw new Exception();
        }
예제 #15
0
    // Start is called before the first frame update
    void Start()
    {
        easyFileSave = new EasyFileSave();


        rb = GetComponent <Rigidbody2D>();
        SpriteRenderer sr = gameObject.GetComponent <SpriteRenderer>();

        Canvas = GameObject.Find("Canvas");
        NewCan = Canvas.GetComponent <Canvas>();
        //NewCan.enabled = false;
        deadSms.SetActive(false);
        pointsText = GameObject.Find("PointsText");
    }
예제 #16
0
    /********** New game button **********/
    private void showInput()
    {
        // Debug.Log(field.text.ToString());

        nameFromUser = field.text.Trim().ToString();
        if (nameFromUser.Length != 0) // Check if name isn't blank
        {
            myFile = new EasyFileSave(nameFromUser);
            myFile.suppressWarning = false;

            /**  Check if username exist */
            if (myFile.Load())
            {
                Debug.Log("Username already exist");
                errorText.gameObject.SetActive(true);
                errorText.text = "Username already exist!";
            }
            else
            {
                /** we are going to save username */
                userData = new List <savedData>();
                userData.Add(new savedData {
                    username = nameFromUser, level = 0, score = 0, timer = 60
                });                                                                                      // Data set for new user
                myFile.AddSerialized("user", userData);
                myFile.Save();


                /** Save current username in currentUser.dat file */
                currentFile = new EasyFileSave("currentUserFile");
                currentFile.Add("currentUser", nameFromUser);
                currentFile.Save();
                if (myFile.Load() && currentFile.Load()) // Check if data saved
                {
                    myFile.Dispose();                    // Free data
                    currentFile.Dispose();               // Free data
                    FindObjectOfType <SceneLoader>().LoadNextScene();
                }
                else
                {
                    Debug.Log("Error while saving! Try again");
                }
            }
        }
        else
        {
            errorText.gameObject.SetActive(true);
        }
    }
    public void LoadBreak(SistemaBreak sistemaBreak)
    {
        EasyFileSave miarchivo = new EasyFileSave("Break");

        if (miarchivo.Load())
        {
            sistemaBreak.cantidadBreak    = miarchivo.GetInt("cantidad");
            sistemaBreak.barra.fillAmount = miarchivo.GetFloat("barra");
            sistemaBreak.Actualizar();
        }
        else
        {
            Debug.LogWarning("Fallo al cargar Sistema Break");
        }
    }
예제 #18
0
    /********** Load game button **********/
    public void LoadGame()
    {
        savedName = currentUserName();
        myFile    = new EasyFileSave(savedName);
        myFile.suppressWarning = false;
        if (myFile.Load())
        {
            level = myFile.GetInt("level");

            FindObjectOfType <SceneLoader>().LoadNextScene(level); // Load level from saving
        }
        else
        {
            Debug.Log("Doesn't loaded");
        }
    }
예제 #19
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     #endregion Singleton logic
     gold        = inventoryPanel.GetComponentInChildren <Gold>();
     Player      = GameObject.FindGameObjectWithTag("Player");
     gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     myFile      = new EasyFileSave("Items")
     {
         suppressWarning = false
     };
 }
예제 #20
0
    public void Save()
    {
        EasyFileSave myFile = new EasyFileSave();

        myFile.Add("PlayerLevel", player.level);
        myFile.Add("PlayerExp", player.playerExp);
        myFile.Add("GoalExp", player.goalExp);
        myFile.Add("PlayerGold", player.gold);
        myFile.Add("PlayerDiamond", player.diamond);
        myFile.Add("PlayerSkipForward", player.skipForward);
        myFile.Add("MonsterKillRecord", player.monsterKillRecord);
        myFile.Add("PlayerTotalScore", player.playerTotalCP);
        myFile.Add("StartScene", player.StartScene);
        myFile.Add("Volume", soundManager.masterVolume);
        myFile.Add("VolumeSprite", soundManager.isMute);
        for (int i = 0; i < player.CollectionItemsId.Count; i++)
        {
            if (!myFile.GetList <int>("PlayerCollection").Contains(i))
            {
                CollectionItemsId.Add(player.CollectionItemsId[i]);
            }
        }

        for (int i = 0; i < player.SkillItemsId.Count; i++)
        {
            if (!myFile.GetList <int>("PlayerSkills").Contains(i))
            {
                SkillsItemsId.Add(player.SkillItemsId[i]);
            }
        }

        for (int i = 0; i < player.DialogueProgress.Count; i++)
        {
            if (!myFile.GetList <int>("PlayerProgress").Contains(i))
            {
                PlayerProgressId.Add(player.DialogueProgress[i]);
            }
        }
        myFile.Add("PlayerSkills", SkillsItemsId);
        myFile.Add("PlayerCollection", CollectionItemsId);
        myFile.Add("PlayerProgress", PlayerProgressId);
        myFile.Save();
    }
예제 #21
0
    public void LoadFromFile(string fileName)
    {
        if (fileName == "" || fileName == null)
        {
            Debug.Log("No file specified to load");
            return;
        }
        EasyFileSave saveFile = new EasyFileSave(fileName);

        Debug.Log("Filename:" + saveFile.GetFileName());
        try
        {
            if (!saveFile.Load())
            {
                Debug.Log("load issue");
                return;
            }

            object[] obj = Resources.FindObjectsOfTypeAll <SerializedObject>(); //this ensures disabled object are also considered
            //object[] obj = GameObject.FindObjectsOfType(typeof (SerializedObject)); //this ignores disabled objects
            foreach (object o in obj)
            {
                SerializedObject g = (SerializedObject)o;
                if (g.UUID == "")
                {
                    continue;
                }

                var objData = saveFile.GetBinary(g.UUID);
                if (objData != null)
                {
                    Debug.Log(g.UUID + " is loaded");
                    g.setLoadData(objData);
                }
            }
            Debug.Log("load done");
        } catch (Exception e) {
            Debug.Log("Exception while saving file:" + e);
        } finally {
            saveFile.Dispose();
        }
    }
    public void SaveHeroe(HeroeBase heroe)
    {
        EasyFileSave miarchivo = new EasyFileSave(heroe.nombre);

        miarchivo.Add("nombre", heroe.nombre);
        miarchivo.Add("HeroeVidaActual", heroe.vidaActual);
        miarchivo.Add("HeroeVidaBase", heroe.vidaBase);
        miarchivo.Add("HeroeManaActual", heroe.manaActual);
        miarchivo.Add("HeroeManaBase", heroe.manaBase);
        miarchivo.Add("HeroeFuerza", heroe.fuerza);
        miarchivo.Add("HeroeInteligencia", heroe.inteligencia);
        miarchivo.Add("HeroeResistenciaF", heroe.resistenciaF);
        miarchivo.Add("HeroeResistenciaM", heroe.resistenciaM);
        miarchivo.Add("HeroeVelocidad", heroe.velocidad);

        miarchivo.Add("HeroeXP", heroe.cantidadXP);
        miarchivo.Add("HeroeNivel", heroe.nivel);

        miarchivo.Save();

        Debug.Log(heroe.nombre + " Guardado");
    }
예제 #23
0
    // private List GetWinnerList (){
    // myFile = new EasyFileSave("user6");
    // if(myFile.Load()){
    //     Debug.Log(myFile.GetInt("timer"));
    // }
    // var path = Application.persistentDataPath + "/";
    // var info = new DirectoryInfo(path);
    // var fileInfo = info.GetFiles();
    // return fileInfo;
    // users = new List<Users>();
    // scoreEntryList = {};
    // foreach (var file in fileInfo) {
    //     // Debug.Log(GetFileNameWithoutExtension(file.Name));
    //     string tmpName = System.IO.Path.GetFileNameWithoutExtension(file.ToString());
    //     // string[] x = file.Name.Split(".");
    //     // Debug.Log("TMP: " + tmpName);
    //     if(tmpName == "currentUserFile") continue;
    //     myFile = new EasyFileSave(tmpName);
    //     myFile.suppressWarning = false;
    //     if(myFile.Load()){
    //         int str=0;
    //         // myFile.GetString("name"), myFile.GetInt("level"), myFile.GetInt("score"), myFile.GetInt("timer"));
    //         str = myFile.GetInt("timer");
    //         // Debug.Log(myFile.GetString("username") + ":username");
    //         scoreEntryList = new List<ScoreEntry>(){
    //             new ScoreEntry{name = myFile.GetString("username"), score = myFile.GetInt("score"), timer = myFile.GetInt("timer")};
    //         };



    //     } else Debug.Log("Bad with load");


    // }


    // Debug.Log(users);
    // }



    private void Awake()
    {
        entryContainer = transform.Find("EntryContainer");
        entryTemplate  = entryContainer.Find("TemplateRow");

        entryTemplate.gameObject.SetActive(false);

        // scoreEntryList = new List<ScoreEntry>(){
        //     new ScoreEntry{name = "Name1", score = 10, timer = 30},
        //     new ScoreEntry{name = "Name1", score = 150, timer = 30},
        //     new ScoreEntry{name = "Name1", score = 20, timer = 30},
        //     new ScoreEntry{name = "Name1", score = 10, timer = 30},
        //     new ScoreEntry{name = "Name1", score = 1440, timer = 30},
        // };

        var path     = Application.persistentDataPath + "/";
        var info     = new DirectoryInfo(path);
        var fileInfo = info.GetFiles();

        scoreEntryList = new List <ScoreEntry>();
        foreach (var file in fileInfo)
        {
            // Debug.Log(GetFileNameWithoutExtension(file.Name));
            string tmpName = System.IO.Path.GetFileNameWithoutExtension(file.ToString());
            // string[] x = file.Name.Split(".");
            // Debug.Log("TMP: " + tmpName);
            if (tmpName == "currentUserFile")
            {
                continue;
            }
            myFile = new EasyFileSave(tmpName);
            myFile.suppressWarning = false;
            if (myFile.Load())
            {
                Debug.Log("Filename: " + tmpName);
                int str = 0;
                // myFile.GetString("name"), myFile.GetInt("level"), myFile.GetInt("score"), myFile.GetInt("timer"));
                str = myFile.GetInt("timer");
                // Debug.Log(myFile.GetString("username") + ":username");
                if (myFile.GetString("username") != "")
                {
                    scoreEntryList.Add(new ScoreEntry {
                        name = myFile.GetString("username"), score = myFile.GetInt("score"), timer = myFile.GetInt("timer")
                    });
                }
            }
            else
            {
                Debug.Log("Bad with load");
            }
        }

        /** Sorting by timer */
        for (int i = 0; i < scoreEntryList.Count; i++)
        {
            for (int j = i + 1; j < scoreEntryList.Count; j++)
            {
                if (scoreEntryList[j].timer > scoreEntryList[i].timer)
                {
                    ScoreEntry tmp = scoreEntryList[i];
                    scoreEntryList[i] = scoreEntryList[j];
                    scoreEntryList[j] = tmp;
                }
            }
        }

        hightScoreEntryTransformList = new List <Transform>();
        foreach (ScoreEntry highscoreEntry in scoreEntryList)
        {
            CreateScoreEntryTransform(highscoreEntry, entryContainer, hightScoreEntryTransformList);
        }
    }
예제 #24
0
 private void Start()
 {
     SaveGame = new EasyFileSave();
     storeUI.SetActive(false);
 }
예제 #25
0
 void StartProcess()
 {
     myFile = new EasyFileSave();
     LoadData();
 }