public void LoadHashTable() { if (!isProxyValid()) { return; } string _tag = uniqueTag.Value; if (string.IsNullOrEmpty(_tag)) { _tag = Fsm.GameObjectName + "/" + Fsm.Name + "/hashTable/" + reference; } ES2Settings loadSettings = new ES2Settings(); if (loadFromResources.Value) { loadSettings.saveLocation = ES2Settings.SaveLocation.Resources; } Dictionary <string, string> _dict = ES2.LoadDictionary <string, string>(saveFile.Value + "?tag=" + _tag); Log("Loaded from " + saveFile.Value + "?tag=" + _tag); proxy.hashTable.Clear(); foreach (string key in _dict.Keys) { proxy.hashTable[key] = PlayMakerUtils.ParseValueFromString(_dict[key]); } Finish(); }
/// <summary> /// Save attribute ID/Value pair. /// </summary> /// <param name="SaveGameID">ID of the save game.</param> /// <param name="ID">Attribute ID being saved.</param> /// <param name="Value">Value of the attribute</param> protected override void SaveAttribute(int SaveGameID, int ID, float Value) { var AllAttributes = new Dictionary <int, float>(); if (ES2.Exists(localDB + "?tag=SaveGameAttributes_" + SaveGameID)) { AllAttributes = ES2.LoadDictionary <int, float>(localDB + "?tag=SaveGameAttributes_" + SaveGameID); } AllAttributes[ID] = Value; ES2.Save(AllAttributes, localDB + "?tag=SaveGameAttributes_" + SaveGameID); }
static public string LoadBattleSetting(string prefix) { if (prefix.IsNullOrEmpty()) { return(""); } string path = getBattleSettingPath(prefix); if (ES2.Exists(path) == false) { return(""); } Dictionary <string, string> savedata = null; try { savedata = ES2.LoadDictionary <string, string>(path, Es2ButtleSetting(prefix)); } catch (Exception e) { return(""); } if (savedata.Count != 1) { return(""); } foreach (KeyValuePair <string, string> kvp in savedata) { string shar1 = Sha1BattleSetting(kvp.Value); if (kvp.Key == shar1) { return(kvp.Value); } else { return(""); } } return(""); }
/// <summary> /// Returns list of available character slots. /// </summary> /// <returns>List of SlotID/CharacterName + Date pairs.</returns> public override List <SimpleDataPair> GetCharacterSlotList() { var SimpleReturn = new List <SimpleDataPair>(); var AllSlots = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveSlots")) { AllSlots = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveSlots"); foreach (int Key in AllSlots.Keys.OrderByDescending(x => x)) { SimpleReturn.Add(new SimpleDataPair() { Value = Key, Display = GetDelimitedDataFromJSON("~", AllSlots[Key], new string[] { "CharacterName", "CreatedOn" }) }); } } return(SimpleReturn); }
public override void InstanceInitiate(StateMachine checkMachine) { GetComponent <StateMaster> ().Setup(); inputMachine.Initiate(); PlayerMachine.playerObject = gameObject; PlayerMachine.instance = this; DontDestroyOnLoad(gameObject); if (ES2.Exists("resources")) { resources = ES2.LoadDictionary <string, int> ("resources"); } else { resources = new Dictionary <string, int> (); } Object[] objs = Resources.LoadAll(""); loadedResources = new Dictionary <string, GameObject> (); foreach (Object obj in objs) { if (obj.name.Substring(0, 3) == "obj") { loadedResources.Add(obj.name, (GameObject)obj); } } if (ES2.Exists("playerLocation")) { Transform tr = ES2.Load <Transform> ("playerLocation"); transform.position = tr.position; transform.localScale = tr.localScale; transform.localRotation = tr.localRotation; Destroy(tr.gameObject); } else { transform.position = AreaStartStateMachine.instance.transform.position + Vector3.up * InputMachine.playerHeight; transform.rotation = AreaStartStateMachine.instance.transform.rotation; } LoadGos(); if (InputMachine.instance.gos.Count == 0) { ADMIN.CreateGos(); } }
/// <summary> /// Load attribute value. /// </summary> /// <param name="SaveGameID">Save game ID containing the attribute.</param> /// <param name="ID">Attribute ID</param> /// <returns>Value of specified attribute.</returns> protected override float LoadAttribute(int SaveGameID, int ID) { try { var AllAttributes = new Dictionary <int, float>(); if (ES2.Exists(localDB + "?tag=SaveGameAttributes_" + SaveGameID)) { AllAttributes = ES2.LoadDictionary <int, float>(localDB + "?tag=SaveGameAttributes_" + SaveGameID); return(AllAttributes[ID]); } else { return(0); // not found } } catch { return(0); // not found } }
/// <summary> /// Returns list of available save games for the selected slot. /// </summary> /// <param name="SelectedSlotID">Slot ID to filter the save game list by.</param> /// <returns>List of SaveGameID/SceneName + XP + Date pairs</returns> public override List <SimpleDataPair> GetSaveGameListForSlot(int SelectedSlotID) { var SimpleReturn = new List <SimpleDataPair>(); var AllSaves = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveGames")) { AllSaves = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveGames"); foreach (int Key in AllSaves.Keys.OrderByDescending(x => x)) { if (AllSaves[Key].Contains("\"SlotID\":" + SelectedSlotID)) { SimpleReturn.Add(new SimpleDataPair() { Value = Key, Display = GetDelimitedDataFromJSON("~", AllSaves[Key], new string[] { "CreatedOn", "Level", "XP", "SceneID" }) }); } } } return(SimpleReturn); }
} // check for database upgrades /// <summary> /// Load the header data array /// </summary> /// <param name="SaveGameID">ID of the save game being loaded.</param> /// <param name="SceneName">Return the name of the scene to load.</param> /// <param name="Data">Return the character data in list form.</param> protected override void LoadHeader(int SaveGameID, ref string SceneName, ref List <SimpleDataHeader> Data) { // load slot data list var AllSlots = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveSlots")) { AllSlots = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveSlots"); } // load save game data list var AllSaveGames = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveGames")) { AllSaveGames = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveGames"); } // extract the save game JSON to simpleData List <SimpleDataHeader> SaveGameData = JSONToHeader(AllSaveGames[SaveGameID], SimpleDataLevel.SaveGame); // find the slot/scene ids from this save game int SlotID = Convert.ToInt32(SaveGameData.Find(s => s.Name == "SlotID").Value); int SceneID = Convert.ToInt32(SaveGameData.Find(s => s.Name == "SceneID").Value); // find the scene name to load var AllScenes = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=Scenes")) { AllScenes = ES2.LoadDictionary <int, string>(localDB + "?tag=Scenes"); } SceneName = AllScenes[SceneID]; // extract the slot game JSON to simpleData List <SimpleDataHeader> SlotGameData = JSONToHeader(AllSlots[SlotID], SimpleDataLevel.Slot); // merge both lists for readback Data = SlotGameData.Concat(SaveGameData).ToList(); }
/// <summary> /// Extract delimited data from stored JSON string. /// </summary> /// <param name="Delimiter">Character data to separate the extracted fields by.</param> /// <param name="JSON">JSON string to extract from.</param> /// <param name="Fields">Field list to extract.</param> /// <returns>Data string of the desired fields.</returns> public string GetDelimitedDataFromJSON(string Delimiter, string JSON, string[] Fields) { // build lookup dictionary of the fields desired from the JSON string[] JSONSplit = JSON.Replace("{", string.Empty).Replace("}", string.Empty).Split(new[] { ",\"" }, StringSplitOptions.RemoveEmptyEntries); var FieldLookup = new Dictionary <string, string>(); foreach (string Prop in JSONSplit) { string[] PropSplit = Prop.Split(new[] { "\":" }, StringSplitOptions.RemoveEmptyEntries); if (Fields.Contains(PropSplit[0].Replace("\"", string.Empty))) { FieldLookup[PropSplit[0].Replace("\"", string.Empty)] = PropSplit[1].Replace("\"", string.Empty); } } // build return string in the correct field order string ReturnAllDelimitered = ""; for (int i = 0; i < Fields.Length; i++) { if (ReturnAllDelimitered.Length > 0) { ReturnAllDelimitered += Delimiter; } if (Fields[i] == "SceneID") { // join to scenes lookup var AllScenes = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=Scenes")) { AllScenes = ES2.LoadDictionary <int, string>(localDB + "?tag=Scenes"); } ReturnAllDelimitered += AllScenes[Convert.ToInt32(FieldLookup[Fields[i]])]; } else { // normal pure value ReturnAllDelimitered += FieldLookup[Fields[i]]; } } return(ReturnAllDelimitered); }
public void LoadGos() { if (InputMachine.instance.gos == null) { InputMachine.instance.gos = new List <GameObject> (); } InputMachine.instance.gos.RemoveAll(item => item == null); if (ES2.Exists("gos")) { Dictionary <Transform, SaveObject> loadGos = ES2.LoadDictionary <Transform, SaveObject> ("gos"); foreach (KeyValuePair <Transform, SaveObject> kvp in loadGos) { if (loadedResources.ContainsKey(kvp.Value.objName)) { GameObject go = (GameObject)GameObject.Instantiate(loadedResources [kvp.Value.objName]); go.GetComponent <StateMachine> ().Load(kvp.Key, kvp.Value); Destroy(kvp.Key.gameObject); } } InputMachine.instance.CheckObjects(); } }
static public Dictionary <string, uint> LoadAssetBundleVersions() { string path = getAssetbundleVersionPath(); if (ES2.Exists(path)) { Dictionary <string, uint> dic = new Dictionary <string, uint>(); try { dic = ES2.LoadDictionary <string, uint>(path); } catch (Exception e) { dic = new Dictionary <string, uint>(); } return(dic); } else { return(new Dictionary <string, uint>()); } }
void Awake() { if (!created) { DontDestroyOnLoad(this.gameObject); created = true; } else { Destroy(this.gameObject); } System.Array templist = System.Enum.GetValues(typeof(Marble.Skin)); if (ES2.Exists("Unlocks.gsw?tag=UnlockState") && !forceRefresh) { //If dictionary is same size as marble skin enum, will need to append to ensure updates don't wipe unlocks UnlockState = ES2.LoadDictionary <Marble.Skin, bool>("Unlocks.gsw?tag=UnlockState"); } else { UnlockState = new Dictionary <Marble.Skin, bool>(); InitializeSkins(); } }
static public Dictionary <uint, uint> LoadWebviewCheck() { string path = getWebviewCheckPath(); if (ES2.Exists(path)) { Dictionary <uint, uint> dic; try { dic = ES2.LoadDictionary <uint, uint>(path); } catch (Exception e) { dic = new Dictionary <uint, uint>(); } return(dic); } else { RemoveWebviewCheck(); return(new Dictionary <uint, uint>()); } }
/// <summary> /// Save the header, creating slot if needed. /// </summary> /// <param name="SlotID">Returns the slotID if one was created.</param> /// <param name="SaveGameID">Returns the save game ID if one was created.</param> /// <param name="SceneName">Name of the scene saved.</param> /// <param name="Data">List of header attributes to save.</param> protected override void SaveHeader(ref int SlotID, ref int SaveGameID, string SceneName, List <SimpleDataHeader> Data) { // new save slot? if (SlotID == 0) { // load slot data list var AllSlots = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveSlots")) { AllSlots = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveSlots"); } // build new slot header if (AllSlots.Count == 0) { // 1st ever slot SlotID = 1; } else { // find the highest key+1 SlotID = AllSlots.Max(s => s.Key) + 1; } AllSlots[SlotID] = @"{""CreatedOn"":""" + DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss") + @"""," + HeaderToJSON(Data.Where(d => d.Level == SimpleDataLevel.Slot).ToList()) + "}"; // save the slot data list ES2.Save(AllSlots, localDB + "?tag=SaveSlots"); } // find scene id var AllScenes = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=Scenes")) { AllScenes = ES2.LoadDictionary <int, string>(localDB + "?tag=Scenes"); } int SceneID = 1; bool bFound = false; if (AllScenes.Count > 0) { try { SceneID = AllScenes.FirstOrDefault(x => x.Value == SceneName).Key; // find scene id bFound = true; } catch { // fail SceneID = AllScenes.Max(s => s.Key) + 1; } } // write the scene name (if new) if (!bFound) { AllScenes[SceneID] = SceneName; ES2.Save(AllScenes, localDB + "?tag=Scenes"); } // load the save games for this slot var AllSaveGames = new Dictionary <int, string>(); if (ES2.Exists(localDB + "?tag=SaveGames")) { AllSaveGames = ES2.LoadDictionary <int, string>(localDB + "?tag=SaveGames"); } // create new save game id if (SaveGameID == -1) { // ID not assigned if (AllSaveGames.Count == 0) { SaveGameID = 1; } else { SaveGameID = AllSaveGames.Max(s => s.Key) + 1; } } // write save game data AllSaveGames[SaveGameID] = @"{""CreatedOn"":""" + DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss") + @"""," + @"""SceneID"":" + SceneID + "," + @"""SlotID"":" + SlotID + "," + HeaderToJSON(Data.Where(d => d.Level == SimpleDataLevel.SaveGame).ToList()) + "}"; ES2.Save(AllSaveGames, localDB + "?tag=SaveGames"); // update last save game/slot id for continue menu option ES2.Save(SlotID.ToString() + "~" + SaveGameID.ToString(), localDB + "?tag=Continue"); }
IEnumerator Start() { Application.RegisterLogCallback(HandleLog); print("开始检查软件更新"); WWW www = new WWW(serverurl + "filesClient.txt" + "?time=" + UnityEngine.Random.Range(0.1f, 1000f)); print(www.url); yield return(www); if (www.error != null) { //0.net off ,Open the App //StartCoroutine(StartApp()); print(www.error); print("更新完成,正在启动中"); StartCoroutine(StartApp()); } if (www.isDone) { //0.net on , Check Update appPath = MyPath.Combine(Application.dataPath, "Application"); ES2.SaveRaw(www.bytes, MyPath.Combine(appPath, "filesServer.txt")); GetDirs(appPath); //1.get Local file saveFileDictionary(filesClient); print("======fileClient======"); string temp = ""; foreach (var i in filesClient) { temp += i; temp += "\n\r\n\r"; } print(temp); //2.get server file print("======fileServer======"); filesServer = ES2.LoadDictionary <string, string>(MyPath.Combine(appPath, "filesServer.txt")); temp = ""; foreach (var i in filesServer) { temp += i; temp += "\n\r\n\r"; } print(temp); //3.compare with file print("======Server don't have Client have,Should Delete======"); IEnumerable <string> filesDelete = filesClient.Keys.Except(filesServer.Keys); temp = ""; foreach (var i in filesDelete) { temp += i; temp += "\n\r\n\r"; File.Delete(MyPath.Combine(appPath, filesClient[i])); } print(temp); //4.compare with file print("======Server have Client don't have,Should Download======"); IEnumerable <string> filesDownload = filesServer.Keys.Except(filesClient.Keys); temp = ""; mTotalBundleCount = filesDownload.Count(); foreach (var i in filesDownload) { temp += i; temp += "\n\r\n\r"; StartCoroutine(CoDownloadAndWriteFile(MyPath.Combine(serverurl, filesServer[i]), MyPath.Combine(appPath, filesServer[i]))); } print(temp); //5.检查是否下载完毕 StartCoroutine(CheckLoadFinish()); } }
public void LoadData() { Debug.Log("データのロード"); GAMEDATA = new VBFData(); GAMEDATA.Liked = ES2.Load <bool>(DataFilename + "?tag=isLiked"); GAMEDATA.expOnLevel = ES2.Load <int>(DataFilename + "?tag=expOnLevel"); GAMEDATA.totalWins = ES2.Load <int>(DataFilename + "?tag=totalWins"); GAMEDATA.earnedLoginBonus = ES2.Load <bool>(DataFilename + "?tag=earnedLoginBonus"); GAMEDATA.playerLevel = ES2.Load <int>(DataFilename + "?tag=playerLevel"); GAMEDATA.lastLoginTime = ES2.Load <string>(DataFilename + "?tag=lastLoginTime"); GAMEDATA.SPOfferLeft = ES2.Load <float>(DataFilename + "?tag=SPOfferLeft"); GAMEDATA.RenzokuLogin = ES2.Load <int>(DataFilename + "?tag=RenzokuLogin"); GAMEDATA.DayFromInstall = ES2.Load <int>(DataFilename + "?tag=DayFromInstall"); GAMEDATA.Countly = ES2.Load <string>(DataFilename + "?tag=Countly"); GAMEDATA.Gold = ES2.Load <long>(DataFilename + "?tag=Currency_Gold"); GAMEDATA.Doller = ES2.Load <long>(DataFilename + "?tag=Currency_Doller"); GAMEDATA.isAdFree = ES2.Load <bool>(DataFilename + "?tag=isAdFree"); GAMEDATA.lureHas_Hard = ES2.LoadDictionary <string, int>(DataFilename + "?tag=lureHas_Hard"); for (int i = 0; i < Constants.LureDatas.itemTittles.Length; i++) { if (!GAMEDATA.lureHas_Hard.ContainsKey(Constants.LureDatas.itemTittles[i])) { Debug.LogError("追加のルアーあり " + Constants.LureDatas.itemTittles[i]); GAMEDATA.lureHas_Hard.Add(Constants.LureDatas.itemTittles[i], 0); } } foreach (string value in GAMEDATA.lureHas_Hard.Keys) { GAMEDATA.lureHasDebug.Add(value + "/" + GAMEDATA.lureHas_Hard[value]); } GAMEDATA.lureHas_Soft = ES2.LoadDictionary <string, int>(DataFilename + "?tag=lureHas_Soft"); GAMEDATA.RigHas = ES2.LoadDictionary <string, bool>(DataFilename + "?tag=rigHas"); GAMEDATA.SettedRig = ES2.LoadDictionary <string, int>(DataFilename + "?tag=settedRig"); for (int i = 0; i < Constants.SoftLureDatas.itemTittles.Length; i++) { if (!GAMEDATA.lureHas_Soft.ContainsKey(Constants.SoftLureDatas.itemTittles[i])) { Debug.LogError("追加のSoftあり " + Constants.SoftLureDatas.itemTittles[i]); GAMEDATA.lureHas_Soft.Add(Constants.SoftLureDatas.itemTittles[i], 0); GAMEDATA.SettedRig.Add(Constants.SoftLureDatas.itemTittles[i], 0); } } for (int i = 0; i < Constants.RigDatas.itemTittles.Length; i++) { if (!GAMEDATA.RigHas.ContainsKey(Constants.RigDatas.itemTittles[i])) { Debug.LogError("追加のRigあり " + Constants.RigDatas.itemTittles[i]); GAMEDATA.RigHas.Add(Constants.RigDatas.itemTittles[i], false); } } foreach (string value in GAMEDATA.lureHas_Soft.Keys) { GAMEDATA.lureSoftHasDebug.Add(value + "/" + GAMEDATA.lureHas_Soft[value]); } foreach (string value in GAMEDATA.RigHas.Keys) { GAMEDATA.RigHasDebug.Add(value + "/" + GAMEDATA.RigHas[value]); } GAMEDATA.lureHas_Line = ES2.LoadDictionary <string, int>(DataFilename + "?tag=lureHas_Line"); for (int i = 0; i < Constants.LineDatas.itemTittles.Length; i++) { if (!GAMEDATA.lureHas_Line.ContainsKey(Constants.LineDatas.itemTittles[i])) { Debug.LogError("追加のLineあり " + Constants.LineDatas.itemTittles[i]); GAMEDATA.lureHas_Line.Add(Constants.LineDatas.itemTittles[i], 0); } } foreach (string value in GAMEDATA.lureHas_Line.Keys) { GAMEDATA.lureLineHasDebug.Add(value + "/" + GAMEDATA.lureHas_Line[value]); } GAMEDATA.lureHas_Rods = ES2.LoadDictionary <string, int>(DataFilename + "?tag=lureHas_Rods"); for (int i = 0; i < Constants.RodsDatas.itemTittles.Length; i++) { if (!GAMEDATA.lureHas_Rods.ContainsKey(Constants.RodsDatas.itemTittles[i])) { Debug.LogError("追加のRodsあり " + Constants.RodsDatas.itemTittles[i]); GAMEDATA.lureHas_Rods.Add(Constants.RodsDatas.itemTittles[i], 0); } } GAMEDATA.tackleSlots = new List <CurrentTackle>(); string[] tackles = ES2.LoadArray <string>(DataFilename + "?tag=tackleSlots"); for (int i = 0; i < Constants.RodsDatas.itemTittles.Length; i++) { CurrentTackle tcke = new CurrentTackle(); if (i >= tackles.Length) { Debug.LogError("追加のRodsあり " + Constants.RodsDatas.itemTittles[i]); tcke.name = Constants.RodsDatas.itemTittles[i]; GAMEDATA.tackleSlots.Add(tcke); } else { if (tcke.SetStringData(tackles[i])) { GAMEDATA.tackleSlots.Add(tcke); } else { Debug.LogError("Error:NO Data FAILURE"); } } } foreach (string value in GAMEDATA.lureHas_Rods.Keys) { GAMEDATA.lureRodsHasDebug.Add(value + "/" + GAMEDATA.lureHas_Rods[value]); } currentCategory = 0; previousCategory = 0; if (ES2.Load <string>(DataFilename + "?tag=culEntry") == "") { Debug.Log("Entry ==null"); GAMEDATA.currentEntry = null; } else { GAMEDATA.currentEntry = null; GAMEDATA.currentEntry = new EntryData(); if (GAMEDATA.currentEntry.SetFromStringData(ES2.Load <string>(DataFilename + "?tag=culEntry"))) { currentCategory = GAMEDATA.currentEntry.category; } else { Debug.Log("Error:NO ENTRY FAILURE"); } } if (ES2.Load <string>(DataFilename + "?tag=prevEntry") == "") { Debug.Log("Entry2 ==null"); GAMEDATA.prevEntry = null; } else { GAMEDATA.prevEntry = null; GAMEDATA.prevEntry = new EntryData(); if (GAMEDATA.prevEntry.SetFromStringData(ES2.Load <string>(DataFilename + "?tag=prevEntry"))) { previousCategory = GAMEDATA.prevEntry.category; } else { Debug.Log("Error:NO ENTRY FAILURE 2"); } } isDataLoaded = true; }