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 addBezierPath(NodePrefab origin, NodePrefab destination) { points.Add (origin.transform.position); points.Add (destination.transform.position); // Add control points to get a nice bezier curve??? //BezierInterpolate (); Render (); }
public void addBezierPath(NodePrefab origin, NodePrefab destination) { points.Add(origin.transform.position); points.Add(destination.transform.position); // Add control points to get a nice bezier curve??? //BezierInterpolate (); Render(); }
public void addNewNode() { Debug.Log ("added new node from menu"); // Create a new node prefab and attach it to the mouse cursor NodePrefab instance = Instantiate<NodePrefab>(prefab); instance.tag = "SFNode"; nodes.Add (instance); instance.updateState (NodePrefab.NodeState.DraggingNode); }
public void updateBezierPath(NodePrefab origin, NodePrefab destination) { if (points.Count > 1) { points [0] = origin.transform.position; points [points.Count - 1] = destination.transform.position; Render (); } else { Debug.LogError("There are currently no points in the array"); } }
public void updateBezierPath(NodePrefab origin, NodePrefab destination) { if (points.Count > 1) { points [0] = origin.transform.position; points [points.Count - 1] = destination.transform.position; Render(); } else { Debug.LogError("There are currently no points in the array"); } }
public void RegisterNewNodeObject(NodePrefab node) { if (allNodes == null) { allNodes = new Dictionary<int, GameObject>(); GameObject[] allNodeObjects = GameObject.FindGameObjectsWithTag("SFNode"); foreach(GameObject obj in allNodeObjects) { NodePrefab p = obj.GetComponent<NodePrefab>(); allNodes.Add(p.nodeId, obj); } } if (this.allNodes.ContainsKey(node.nodeId)) { this.allNodes[node.nodeId] = node.gameObject; } else { this.allNodes.Add(node.nodeId, node.gameObject); } }
public void SetupAllNodes() { if (allNodes == null) { allNodes = new Dictionary <int, GameObject>(); GameObject[] allNodeObjects = GameObject.FindGameObjectsWithTag("SFNode"); foreach (GameObject obj in allNodeObjects) { NodePrefab p = obj.GetComponent <NodePrefab>(); allNodes.Add(p.nodeId, obj); } } foreach (int nodeId in allNodes.Keys) { INodeBase node = allNodes[nodeId].GetComponent <INodeBase>(); node.SetupConnections(); } }
public GameObject getGameObjectNodeWithNodeId(int nodeId) { if (allNodes == null) { allNodes = new Dictionary <int, GameObject>(); GameObject[] allNodeObjects = GameObject.FindGameObjectsWithTag("SFNode"); foreach (GameObject obj in allNodeObjects) { NodePrefab p = obj.GetComponent <NodePrefab>(); allNodes.Add(p.nodeId, obj); } } if (allNodes.ContainsKey(nodeId)) { return(allNodes[nodeId]); } return(null); }
public void RegisterNewNodeObject(NodePrefab node) { if (allNodes == null) { allNodes = new Dictionary <int, GameObject>(); GameObject[] allNodeObjects = GameObject.FindGameObjectsWithTag("SFNode"); foreach (GameObject obj in allNodeObjects) { NodePrefab p = obj.GetComponent <NodePrefab>(); allNodes.Add(p.nodeId, obj); } } if (this.allNodes.ContainsKey(node.nodeId)) { this.allNodes[node.nodeId] = node.gameObject; } else { this.allNodes.Add(node.nodeId, node.gameObject); } }