// Start is called before the first frame update private void Start() { myFile.Delete(); if (myFile.FileExists()) { if (myFile.Load()) { LoadInventory(); LoadEquipment(); LoadShop(); // Gold gold.ChangeGold(myFile.GetInt("gold", defaultValue: 5000)); // Encounter gameManager.nextEncounterNumber = myFile.GetInt("encounter", defaultValue: 1); } else { MessageSystem.Print("Load Failed!"); } } else { gold.ChangeGold(5000); shop.GenerateItems(); SaveInventory(); } myFile.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); }
public void LoadData() { if (myFile.Load()) { totalShotBullet = myFile.GetInt("totalShotBullet"); totalEnemyKilled = myFile.GetInt("totalEnemyKilled"); } }
private void SetMoney() { if (SaveGame.Load()) { points = SaveGame.GetInt("points"); storeMoney.GetComponent <TextMeshProUGUI>().text = points.ToString(); } else { points = 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 }
/********** 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 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"); } }
/********** 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"); } }
void Update() { // When [S] key is pressed: SAVE. if (Input.GetKeyUp(KeyCode.S)) { Debug.Log(">> I'M GOING TO SAVE SOME DATA!" + "\n"); // Some values. equipment = new List <string>(); equipment.Add("Hammer"); equipment.Add("Knife"); equipment.Add("Rope"); initialLocation = new Vector3(101.5f, -30.4f, 22f); coins = new Dictionary <string, int>(); coins.Add("Copper", 1200); coins.Add("Silver", 450); coins.Add("Gold", 300); // Simple data. character = "Conan"; age = 30; strenght = 300.5f; has_sword = true; has_bow = false; myFile.Add("name", character); myFile.Add("age", age); myFile.Add("strenght", strenght); myFile.Add("has_sword", has_sword); myFile.Add("has_bow", has_bow); // GameObject data. myFile.Add("equipment", equipment); myFile.Add("coins", coins); myFile.Add("initialLocation", initialLocation); myFile.Add("player", gameObject.transform); // Class data (serialization). items = new List <Item>(); items.Add(new Item { name = "Gold", quantity = 15000 }); items.Add(new Item { name = "Darts", quantity = 24 }); items.Add(new Item { name = "Potions", quantity = 10 }); myFile.AddSerialized("items", items); // Custom Extension for managing BoxCollider myFile.AddCustom("collider", gameObject.GetComponent <BoxCollider>(), "BoxCollider"); // Save all the collected data. // At the end of the process, stored data is cleared to free memory. myFile.Save(); Debug.Log(">> Data saved in: " + myFile.GetFileName() + "\n"); ShowData(); } // When [L] key is pressed: LOAD. if (Input.GetKeyUp(KeyCode.L)) { // Load data from file. if (myFile.Load()) { Debug.Log(">> I'M GOING TO USE LOADED DATA!" + "\n"); // Simple data. character = myFile.GetString("name"); age = myFile.GetInt("age"); strenght = myFile.GetFloat("strenght"); has_sword = myFile.GetBool("has_sword"); has_bow = myFile.GetBool("has_bow"); // In this case, if 'nickname' key doesn't exist, 'user_1234' string is used. nickname = myFile.GetString("nickname", "user_1234"); // GameObject data. equipment = (List <string>)myFile.GetData("equipment"); coins = (Dictionary <string, int>)myFile.GetData("coins"); initialLocation = myFile.GetUnityVector3("initialLocation"); var tr = myFile.GetUnityTransform("player"); gameObject.transform.position = tr.position; gameObject.transform.rotation = tr.rotation; gameObject.transform.localScale = tr.localScale; // Class data (serialization). items = (List <Item>)myFile.GetDeserialized("items", typeof(List <Item>)); // Custom Extension for managing BoxCollider. var bc = myFile.GetCustom("collider", "BoxCollider"); var thisBoxColllider = gameObject.GetComponent <BoxCollider>(); thisBoxColllider.center = new Vector3 { x = bc["centerX"].ToFloat(), y = bc["centerY"].ToFloat(), z = bc["centerZ"].ToFloat() }; thisBoxColllider.isTrigger = bc["isTrigger"].ToBool(); // Loaded data has been used as needed. // Stored data is manually cleared to free memory. myFile.Dispose(); Debug.Log(">> Data loaded from: " + myFile.GetFileName() + "\n"); ShowData(); } } // When [A] key is pressed: APPEND. if (Input.GetKeyUp(KeyCode.A)) { // Simple data. myFile.Add("nickname", "The Warrior"); myFile.Add("age", 32); // Append this data to the current file content. // 'nickname' key is new, so its value is added to the file. // 'age' key already exists, so its current value is updated with this new one. myFile.Append(); Debug.Log(">> New data added to: " + myFile.GetFileName() + "\n"); Debug.Log(">> Age value updated to 32." + "\n"); Debug.Log(">> Added nickname." + "\n"); } // When [Del] key is pressed: FILE DELETE. if (Input.GetKeyUp(KeyCode.Delete)) { // Delete this file. // This method clears stored data as well. myFile.Delete(); Debug.Log(">> The file has been deleted." + "\n"); } // When [T] key is pressed: SAVING AND LOADING DATA TEST. if (Input.GetKeyUp(KeyCode.T)) { // Perform a test of writing and loading data. // ------------------------------------------- myFile.Delete(); // Add some values to the internal storage for saving and loading test. equipment = new List <string>(); equipment.Add("Hammer"); equipment.Add("Knife"); equipment.Add("Rope"); initialLocation = new Vector3(101.5f, -30.4f, 22f); character = "Conan"; age = 30; strenght = 300.5f; has_sword = true; has_bow = false; items = new List <Item>(); items.Add(new Item { name = "Gold", quantity = 15000 }); items.Add(new Item { name = "Darts", quantity = 24 }); items.Add(new Item { name = "Potions", quantity = 10 }); myFile.Add("name", character); myFile.Add("age", age); myFile.Add("strenght", strenght); myFile.Add("has_sword", has_sword); myFile.Add("has_bow", has_bow); myFile.Add("equipment", equipment); myFile.Add("initialLocation", initialLocation); myFile.Add("player", gameObject.transform); myFile.AddSerialized("items", items); myFile.AddCustom("collider", gameObject.GetComponent <BoxCollider>(), "BoxCollider"); // Test if (myFile.TestDataSaveLoad()) { Debug.Log("<color=green>GOOD! Go to step 2!</color>\n"); } else { Debug.Log("<color=red>OPS! SOMETHING WENT WRONG!</color>\n"); } } }
// 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); } }
public void LoadData() { if (myfile.Load()) { totalShotBullet = myfile.GetInt("totalShotBullet"); totalEnemyKilled = myfile.GetInt("totalEnemyKilled"); bestShotBullet = myfile.GetInt("bestShotBullet"); bestEnemyKilled = myfile.GetInt("bestEnemyKilled"); totalEarnedCoin = myfile.GetInt("totalEarnedCoin"); totalSword = myfile.GetInt("totalSword"); totalHat = myfile.GetInt("totalHat"); totalPotion = myfile.GetInt("totalPotion"); power = myfile.GetInt("power"); defance = myfile.GetInt("defance"); ability = myfile.GetInt("ability"); } }