private void AssignRoomTerrain(JSONObject obj) { ConnectParsedTerrain t = JsonUtility.FromJson<ConnectParsedTerrain>(obj["terrain"].list[0].ToString()); Debug.Log("Assign Room : " + t); ConnectParsedTerrain[] tt = { t }; recTer = new ConnectRecievedTerrain { ok = obj["ok"].str, terrain = tt }; UpdateTerrainFromConnection(); }
RoomTerrain LoadTerrainFromConnection(ConnectRecievedTerrain t) { //{ "ok":1,"terrain":[ // {"_id":"5982ff33b097071b4adc23cb", // "room":"E20N6", // "terrain":"1111111111111111110000000000000000000000000111111111111111111111111000000000000000000000000001111111111111111111111100000000000000000000000000011111111111111111111110000000000000000000000000000111111111111111111111000000000000000000000000000001111111111111111111100000000000000000000000000000011111111111111111100000000000000000000000000000000111111111111111110000000000000000000000000000000001111111111111111000000000000000000000000000000000011111111111111100000000000000000000000000000000000111111111111110000000000000000000000000000000000001111111111111000000000000000000000000000000000000011111111111110000000000000000000000000000000000000111111111111000000000000000000000000000000000000001111111111110000000000000000000000000000000000000011111111111000000000000000000000000000000000000000011111111110000000000000000000000000000000000000000111111111000000000000000000000000000000000000000001111111100000000000000000000000000000000000000000011111110000000000000000000000000000000000000000000111111000000000000000000000000000000000000000000001111110000000000000000000000000011100000000000000001111100000000000000000000000000111000000000000000011111000000000000000000000000000000000000000000000011110000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000111100000000000000000000011100000000000000000000001111000000000000000000001111100000000000000000000011110000011100000000000111111000000000000000000000111100000111000000000001111110000000000000000100001111000000000000000000001111000000000000000011100011110000000000000000000001100000000000000000110001111100000000000000000000000000000000000000000000011111000000000000000000000000000011000000000000001111110000000000000000000000000000110000000000000011111100000000000000000000000000000000000000000001111110000000000000000000000000000000000011000000011111100000000000000000000000000000000000111000001111111000000000000000000000000000000000001111000011111110000000000000000000000000000000000011100001111111100000000000000000000000000000000000000000011111111000000000111111111000000000000000000000001111111110000000011111111110000000000000000000000011111111110000001111111111000000000000000000000001111111111110000001111111100000100000000000000000011111111111110000001111110000011100000000000000000111111111111110000000000000000111100000000000000001111111111111100000000000000000110000000000000000001111111111111000000000000000000000000000000000000001111111111110000000000000000000000000000000000000011111111", // "type":"terrain"} // ] //} //string terrainFile = "{\"result\": null}"; RoomTerrain terr = new RoomTerrain(); Terrain[] result = new Terrain[2500]; //terr.result = result; //ConnectRecievedTerrain t = JsonUtility.FromJson<ConnectRecievedTerrain>(terrainIn.ToString()); Debug.Log("load terrain : " + t); char[] c = t.terrain[0].terrain.ToCharArray(); for (int i = 0; i < 2500; i++) { result[i] = new Terrain(); //Debug.Log(result[i]); int x = i % 50; int y = Mathf.FloorToInt(i / 50); result[i].x = x; result[i].y = y; result[i].roomName = t.terrain[0].room; if (c[i] == '1' || c[i] == '3') { result[i].type = "wall"; } else if (c[i] == '2') { result[i].type = "swamp"; } else { result[i].type = "plains"; } } terr.result = result; return(terr); }