public static void LoadAll() { // key "classType" is in every saved object // and is used when restoring the game object // we can Load the resource with that type by passing it in via reflection JSON json = new JSON(); using (StreamReader s = new StreamReader("itemList.json")) { try { string rawFile = s.ReadToEnd(); json.serialized = rawFile; } catch (IOException e) { } } foreach (JSON child in json.ToArray <JSON>("nodes")) { JSON node = child["node"] as JSON; string assemblyName = node["classType"] as string; System.Type type = typeof(SaveUtility).Assembly.GetType(assemblyName); System.Collections.ArrayList l = SaveUtility.Load(node, assemblyName, type); } // Now that all the objects are loaded we can go ahead and set up the connections ObjectManager.instance.SetupAllNodes(); foreach (int id in ObjectManager.instance.allNodes.Keys) { GameObject o = ObjectManager.instance.allNodes[id]; NodePrefab node = o.GetComponent <NodePrefab>(); Debug.Log("NodeId: " + node.nodeId + "\n" + "Children: " + node.childNodes.Count + "/n" + "Parents: " + node.connectedFromNodes.Count); } }
public void Load(string creatureName) { Clear(); CreatureData data = JsonUtility.FromJson <CreatureData>(SaveUtility.Load(creatureName + ".json")); for (int i = 0; i < data.bones.Count; i++) { Bone bone = data.bones[i]; Add(i, bone.Position, bone.Rotation, bone.Size); } for (int i = 0; i < data.attachedBodyParts.Count; i++) { AttachedBodyPart attachedBodyPart = data.attachedBodyParts[i]; BodyPartController bpc = Instantiate(DatabaseManager.GetDatabaseEntry <BodyPart>("Body Parts", attachedBodyPart.BodyPartID).Prefab, root.GetChild(attachedBodyPart.BoneIndex)).GetComponent <BodyPartController>(); bpc.gameObject.name = attachedBodyPart.BodyPartID; SerializableTransform.RecurseUpdate(bpc.transform, attachedBodyPart.Transform); SetupBodyPart(bpc); AttachBodyPart(bpc); AddToStatistics(bpc.name); if (Mathf.Abs(bpc.transform.position.x) > settings.MergeThreshold) { bpc.Flipped.transform.position = new Vector3(-bpc.transform.position.x, bpc.transform.position.y, bpc.transform.position.z); bpc.Flipped.transform.rotation = Quaternion.Euler(bpc.transform.rotation.eulerAngles.x, -bpc.transform.rotation.eulerAngles.y, -bpc.transform.rotation.eulerAngles.z); if (bpc is LimbController) { LimbController limb = bpc as LimbController; LimbController flippedLimb = limb.FlippedLimb; for (int j = 0; j < limb.Bones.Length; j++) { float x = -limb.Bones[j].position.x; float y = limb.Bones[j].position.y; float z = limb.Bones[j].position.z; flippedLimb.Bones[j].position = new Vector3(x, y, z); } } } else { bpc.Flipped.gameObject.SetActive(false); } } SetColours(data.primaryColour, data.secondaryColour); SetPattern(data.patternID); SetSelected(false); SetTextured(Textured); SetInteractable(Interactable); }
public void LoadRecordList() { Records.Clear(); string[] paths = Directory.GetFiles(_GAME_RECORD_DATA_PATH); foreach (var recordPath in paths) { if (Path.GetExtension(recordPath) == ".data") { Record theRecord = SaveUtility.Load <Record>(recordPath); theRecord.recordName = Path.GetFileNameWithoutExtension(recordPath); Records.Add(theRecord.recordName, theRecord); } } }
public void LoadGlobalData() { GlobalGameData = SaveUtility.Load <Dictionary <SaveID, SaveData> >(GAME_GLOBAL_DATA_PATH + "GameData.data"); ReadGlobalGameData(); }
public Room LoadRoom(string path) { return(SaveUtility.Load <Room>(path)); }