public static ItemDatabase LoadUser() { string path = Application.persistentDataPath + "/Xml/Item.Xml"; if (System.IO.File.Exists(path)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(System.IO.File.ReadAllText(path)); //복호화//// XmlElement elmRoot = xmlDoc.DocumentElement; var decrpytData = DataSecurityManager.DecryptData(elmRoot.InnerText); elmRoot.InnerXml = decrpytData; ////////// string _xml; using (var stringWriter = new StringWriter()) using (var xmlTextWriter = XmlWriter.Create(stringWriter)) { xmlDoc.WriteTo(xmlTextWriter); xmlTextWriter.Flush(); _xml = stringWriter.GetStringBuilder().ToString(); } if (_xml != null) { XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase)); var reader = new StringReader(_xml); ItemDatabase itemDB = serializer.Deserialize(reader) as ItemDatabase; reader.Close(); Debugging.Log("ItemDatabase 기존 파일 로드"); return(itemDB); } } Debugging.LogSystemWarning("ItemDatabase wasn't loaded. >> " + path + " is null. >>"); return(null); }
public static ItemDatabase Load() { TextAsset _xml = Resources.Load <TextAsset>("XmlData/Item"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_xml.text); if (_xml != null) { XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase)); var reader = new StringReader(_xml.text); ItemDatabase itemDB = serializer.Deserialize(reader) as ItemDatabase; reader.Close(); Debugging.Log("ItemDatabase 로드 성공"); return(itemDB); } Debugging.LogSystemWarning("ItemDatabase wasn't loaded."); return(null); }
public static ItemDatabase Load() { string path = "Item"; TextAsset _xml = Resources.Load <TextAsset>(path); if (_xml != null) { Debugging.LogSystem("ItemDatabase is loading... " + path + ".xml"); XmlSerializer serializer = new XmlSerializer(typeof(ItemDatabase)); var reader = new StringReader(_xml.text); ItemDatabase itemDB = serializer.Deserialize(reader) as ItemDatabase; reader.Close(); return(itemDB); } else { Debugging.LogSystemWarning("ItemDatabase wasn't loaded. >> " + path + " is null. >>"); return(null); } }
public static void LoadPlayer() { Common.isDataLoadSuccess = false; int loadTryCount = 0; string path = Application.persistentDataPath + "/player.fun"; PlayerData data = null; while (loadTryCount < 3) { if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); data = formatter.Deserialize(stream) as PlayerData; stream.Close(); break; } else { loadTryCount++; } } if (data != null) { status.isDead = false; status.isPlaying = false; status.isCtrl = false; status.isInBuilding = false; status.hp = data.hp; status.hpFull = data.hpFull; status.coin = data.coin; status.air = data.air; status.bullet = data.bullet; status.currentWeaponId = data.currentWeaponId; status.minAttack = data.minAttack; status.maxAttack = data.maxAttack; status.stageNumber = data.stageNumber; status.stageDetailNumber = data.stageDetailNumber; status.checkPoint = new Vector3(data.checkPoint[0], data.checkPoint[1]); string[] str = data.weapons.Split(','); str = Common.GetDistinctValues <string>(str); foreach (var weapon in str) { if (!string.IsNullOrEmpty(weapon)) { int weaponNumber = Convert.ToInt32(weapon); Item item = ItemSystem.GetItem(weaponNumber); if (item != null) { status.weapons.Add(item); } } } Debugging.LogSystem("File is loaded Successfully >> Try : " + loadTryCount + "\r\n" + JsonUtility.ToJson(data)); } else { Debugging.LogSystemWarning("Save file not fount in " + path); InitPlayer(); } Common.isDataLoadSuccess = true; }
public static void LoadPlayer() { int loadTryCount = 0; string path = Application.persistentDataPath + "/player.fun"; PlayerData data = null; while (loadTryCount < 3) { if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); data = formatter.Deserialize(stream) as PlayerData; stream.Close(); break; } else { loadTryCount++; } } if (data != null) { User.isDead = false; User.isPlaying = false; if (!string.IsNullOrEmpty(Common.GoogleUserId)) { User.id = Common.GoogleUserId; } else { User.id = data.id; } User.level = data.level; User.exp = data.exp; User.coin = data.coin; User.blackCrystal = data.blackCrystal; User.portalEnergy = data.portalEnergy; User.abilityCount = data.abilityCount; User.stageNumber = data.stageNumber; User.stageDetailNumber = data.stageDetailNumber; User.stageHeros = data.stageHeros; User.lobbyHeros = data.lobbyHeros; User.flatEnergyChargingLevel = data.flatEnergyChargingLevel; User.flatEnergyMaxLevel = data.flatEnergyMaxLevel; User.addMoneyLevel = data.addMoneyLevel; User.addExpLevel = data.addExpLevel; User.addAttackLevel = data.addAttackLevel; User.addDefenceLevel = data.addDefenceLevel; User.gachaSeed = data.gachaSeed; if (data.playerSkill == null) { data.playerSkill = new int[2]; } User.playerSkill = data.playerSkill; if (data.inventoryCount < 100) { data.inventoryCount = 100; } User.inventoryCount = data.inventoryCount; User.name = data.name; if (data.language == null) { data.language = "ko"; } User.language = data.language; //Debugging.LogSystem("File is loaded Successfully >> Try : " + loadTryCount + "\r\n" + JsonUtility.ToJson(data)); } else { Debugging.LogSystemWarning("Save file not fount in " + path); } }