void createArr(RoomNode ptr) { this.ptr = ptr; if (ptr.getLeftNode() != null) { createArr(ptr.getLeftNode()); } if (ptr.getRightNode() != null) { createArr(ptr.getRightNode()); } grid = ptr.getGrid(); randomFillMap(); calcMap(); }
void makeMap(RoomNode ptr, string whereIs) { if (ptr != null) { makeMap(ptr.getLeftNode(), "left"); makeMap(ptr.getRightNode(), "right"); } else if (ptr == null) { return; } if (ptr.getLeftNode() == null && ptr.getRightNode() == null) { buf = ptr.getGrid(); for (int a = 0; a < ptr.getWidth(); a++) { for (int b = 0; b < ptr.getHeight(); b++) { Debug.Log((a + b) + "," + (a + b) + " = " + buf[a, b] + " getgridvalue = " + ptr.getGridValue(a, b)); } } float floorSize = floor.GetComponent <SpriteRenderer>().sprite.bounds.size.x; for (int i = ptr.getX(); i <= ptr.getWidth() + ptr.getX() - 1; i++) { for (int j = ptr.getY(); j <= ptr.getHeight() + ptr.getY() - 1; j++) { if (buf[i - ptr.getX(), j - ptr.getY()] == 0) { GameObject RoomFloor = Instantiate(floor); RoomFloor.transform.position = new Vector3(floorSize * i, floorSize * j, 0); RoomFloor.name = ptr.getIndex() + "번 노드 바닥" + whereIs; } else if (buf[i - ptr.getX(), j - ptr.getY()] == 1) { GameObject RoomWall = Instantiate(wall); RoomWall.transform.position = new Vector3(floorSize * i, floorSize * j, 0); RoomWall.name = ptr.getIndex() + "번 노드 벽 " + whereIs; } } } } }