// Use this for initialization void Start() { AnyInfo info = GameObject.Find("InfoObject").GetComponent <AnyInfo>(); ConnectCodeTextMesh.text = "Connect Code: " + info.Someinfo; StartCoroutine(DisplayForSeconds(10)); }
private void InterpretRoomFromJson(string leveljson) { Debug.Log(leveljson); var leveldata = JsonUtility.FromJson <JsonLevelData>(leveljson); var level = leveldata.data; // Add connect code to InfoObject that remains throughout scenes - It is used in the GamePlay Scene AnyInfo Info = GameObject.Find("InfoObject").GetComponent <AnyInfo>(); Info.Someinfo = level.connect_code; // Initialise each clue foreach (var clue in level.clues) { Debug.Log(clue.name); // Use the identifier to loacte the clue in the Assets folder string identifier = clue.identifier; string path = IdentifierToPath(identifier); // Create an instance of the required clue prefab try { var clueObject = Instantiate(Resources.Load(path, typeof(GameObject))) as GameObject; // Set the initial properties by broadcasting a message to make use the clue's SetProperty method foreach (var property in clue.initial_properties) { Debug.Log(property.name); Debug.Log(property.type); Debug.Log(property.value); clueObject.BroadcastMessage("SetProperty", property); } clueObject.BroadcastMessage("Initialise"); // Add the initialised clue object to a dictionary that is later used to make connections between the clues _clueObjects.Add(clue.id, clueObject); } catch (ArgumentException e) { // If any one clue fails, destroy all the others before showing the error panel foreach (var clueObjectPair in _clueObjects) { Destroy(clueObjectPair.Value); } // Display Error Message ChangeActivePanel(ErrorPanel); _errorText.text = "There seems to be a problem with the " + clue.name + " clue. Please check that the correct identifier is being used"; } } // Only proceed if the ErroPanel isn't active (there were no previous errors) if (ErrorPanel.active == false) { // Connect event outlets foreach (var clue in level.clues) { foreach (var events in clue.event_outlets) { foreach (var outlet in events.outlets) { // Add an action the clue object in question - this connects one of its methods to trigger an action in another object _clueObjects[clue.id].BroadcastMessage("AddAction", new TriggerAction(events.event_name, _clueObjects[outlet.clue_id], outlet.action_name)); } } _cluesToPlace.Add(new ClueToPlace(_clueObjects[clue.id], clue.placement)); } // Place objects by passing _cluesToPlace.ToArray() to Daniel using LoadClues ClueToPlace[] clueArray = _cluesToPlace.ToArray(); // Wrap clues array so it can be used by the LoadClues WrapClues lWC = GameObject.Find("Placements").GetComponent <WrapClues>(); lWC.LoadClues(clueArray); SceneManager.LoadScene(3); } }