//Load JsonFile (Bridges and teleporters) void LoadData() { /* Load Switches And Bridges */ SetSpawnPoint(); try { foreach (string DataBridge in loadedData.ListBridges) { bool SwitchToLoadNormal = true; bool BridgeOpen = false; List <GameObject> CaseBridgeTemp = new List <GameObject>(); int indexXSwitch; int indexZSwitch; if (DataBridge[0].ToString() == "S") { SwitchToLoadNormal = false; } else if (DataBridge[0].ToString() == "N") { SwitchToLoadNormal = true; } if (DataBridge[1].ToString() == "0") { BridgeOpen = false; } else if (DataBridge[1].ToString() == "1") { BridgeOpen = true; } string[] SplitsData = DataBridge.Split('-'); string Coord = SplitsData[0]; int indexTemp = Coord.IndexOf("(") + 1; string RawCoord = Coord.Substring(indexTemp, Coord.Length - indexTemp - 1); string[] SplitsCoord = RawCoord.Split(','); indexXSwitch = Int32.Parse(SplitsCoord[0]); indexZSwitch = Int32.Parse(SplitsCoord[1]); string ListCaseBridge = SplitsData[1]; ListCaseBridge = ListCaseBridge.Substring(1, ListCaseBridge.Length - 2); string[] SplitsCoordData = ListCaseBridge.Split(';'); int indexXCase; int indexZCase; foreach (string dataCoord in SplitsCoordData) { int indexTemp2 = dataCoord.IndexOf("(") + 1; string RawCaseCoord = dataCoord.Substring(indexTemp2, dataCoord.Length - indexTemp2 - 1); string[] SplitCoordCase = RawCaseCoord.Split(','); indexXCase = Int32.Parse(SplitCoordCase[0]); indexZCase = Int32.Parse(SplitCoordCase[1]); float ScaleY = WoodCasePrefab.transform.localScale[1]; float IndexY = -(ScaleY / 2); float postionX = (indexXCase * WoodCasePrefab.transform.localScale[0]) - (WoodCasePrefab.transform.localScale[0] / 2); float postionZ = (indexZCase * WoodCasePrefab.transform.localScale[2]) - (WoodCasePrefab.transform.localScale[2] / 2); GameObject TempCase; if (BoardList[indexZCase - 1][indexXCase - 1].ToString() == "3") { TempCase = Instantiate(BrickCasePrefab, new Vector3(postionX, IndexY, postionZ), transform.rotation); CaseBridgeTemp.Add(TempCase); if (!BridgeOpen) { TempCase.SetActive(false); } else { string CoordinateTemp = "(" + indexXCase.ToString() + "," + indexZCase.ToString() + ")"; CurrentlyActivatedCasesBridge.Add(CoordinateTemp); } } else if (BoardList[indexZCase - 1][indexXCase - 1].ToString() == "4") { TempCase = Instantiate(WoodCasePrefab, new Vector3(postionX, IndexY, postionZ), transform.rotation); CaseBridgeTemp.Add(TempCase); if (!BridgeOpen) { TempCase.SetActive(false); } else { string CoordinateTemp = "(" + indexXCase.ToString() + "," + indexZCase.ToString() + ")"; CurrentlyActivatedCasesBridge.Add(CoordinateTemp); } } } string CoordSwitchForList = indexXSwitch.ToString() + "," + indexZSwitch.ToString(); try { if (SwitchToLoadNormal) { NormalSwitches.Add(CoordSwitchForList, CaseBridgeTemp); } else { StrongSwitches.Add(CoordSwitchForList, CaseBridgeTemp); } } catch { } } } catch { } /* Load Teleporter */ arrivalTeleport = loadedData.arrivalTeleport; }