IEnumerator BaseSpellWait() { yield return(new WaitForEndOfFrame()); if (forceOverrideSave || groupMode || true) { yield break; } FileStream file = null; try { BinaryFormatter bf = new BinaryFormatter(); file = File.Open(Application.dataPath + "/Spells/Examples/BaseSpell.SpellDic", FileMode.Open); InputManagerSerializer dick = (InputManagerSerializer)bf.Deserialize(file); clipboard = dick.nodes; clipboardPos = dick.PositionsToVector(); Paste(); clipboard = null; clipboardPos = null; } catch (Exception exx) { Debug.LogError(exx.Message + exx.StackTrace); } finally { if (file != null) { file.Close(); } } }
public void Load(string name) { InputManagerSerializer dick = null; if (File.Exists(Application.dataPath + "/Spells/" + name + ".SpellDic")) { FileStream file = null; try { BinaryFormatter bf = new BinaryFormatter(); file = File.Open(Application.dataPath + "/Spells/" + name + ".SpellDic", FileMode.Open); dick = (InputManagerSerializer)bf.Deserialize(file); Load(dick); } catch (Exception exx) { MsgBox.Make("Couldn't load spellDic (" + name + ") from disk because:\n" + exx.Message); } finally { if (file != null) { file.Close(); } } } else { Debug.LogError("spell at Spells/" + name + ".SpellDic" + " doesn't exist"); return; } //dick is filled :3 }
void DoSave(MsgBox msg, object o) { FileStream file = null; try { Directory.CreateDirectory(Application.dataPath + "/Spells"); InputManagerSerializer dick = (InputManagerSerializer)o; BinaryFormatter bf = new BinaryFormatter(); file = File.Create(Application.dataPath + "/Spells/" + saveName + ".SpellDic"); Debug.Log(file.Name); bf.Serialize(file, dick); } catch (Exception e) { MsgBox.Make("Couln't save spell dictionnary (" + saveName + ") to disk because:\n" + e.Message); } finally { if (file != null) { file.Close(); } } GetSpell().SaveSpellToDisk(); forceOverrideSave = true; if (msg != null) { msg.Close(); } }
public void Save() { Debug.Log("save"); InputManagerSerializer dick = new InputManagerSerializer(); for (int i = 0; i < allNodes.Count; i++) { dick.Add(allNodes[i].GetComponent <NodeVisual>().node, new Position2(allNodes[i].position)); } dick.PrepareForSerialization(); if (forceOverrideSave) { DoSave(null, dick); } else { if (File.Exists(Application.dataPath + "/Spells/" + saveName + ".SpellDic")) { //ask player if he wants to override //if not return; MsgBox.Make("A spell with this name: \"" + saveName + "\" already exists !\nDo you want to overwrite it ?\n(the old one will be lost)", new string[] { "JUST DO IT!", "Don't do it bro" }, new MsgBox.OnButtonClick[] { DoSave, DontDoSave }, new object[] { dick }); } else { DoSave(null, dick); } } }
public void Load(InputManagerSerializer dick) { forceOverrideSave = true; for (int i = 0; i < dick.nodes.Length; i++) { //Cree les node visual en settant tout bien les public var puis call CreateLinkVisualsForList() sur allnodes Type type = dick.nodes[i].GetAssociatedVisualClass(); GameObject go = new GameObject(type.ToString()); NodeVisual comp = (NodeVisual)go.AddComponent(type); comp.host = this; // comp.caster = caster; comp.canvas = editorUI; comp.doStart = false; comp.node = dick.nodes[i]; RectTransform rect = comp.gameObject.AddComponent <RectTransform>(); rect.SetParent(editorUI.transform, false); allNodes.Add(rect); } StartCoroutine(LoadWait(allNodes, dick.positions)); StartCoroutine(LinkVisualCreationWait(allNodes)); }
public virtual InputManagerSerializer GetExample() { return(InputManagerSerializer.LoadFromDisk(Application.dataPath + "/Spells/Examples/" + TabMenu.CleanClassName(GetType().ToString()) + ".SpellDic")); }