public void Initialize(DormitoryCell cell, DormitoryCell otherCell, DormitoryDirection direction) { this.cell = cell; this.otherCell = otherCell; this.direction = direction; cell.SetEdge(direction, this); transform.parent = cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); }
public void CreateWall(DormitoryCell cellA, DormitoryCell cellB, DormitoryDirection direction) { DormitoryWall wall = Instantiate(wallPrefab) as DormitoryWall; wall.Initialize(cellA, cellB, direction); if (cellB != null) { wall = Instantiate(wallPrefab) as DormitoryWall; wall.Initialize(cellB, cellA, direction.GetOpposite()); } }
private void CreateCell(IntVector2 coords, int i) { DormitoryCell cell = Instantiate(cellPrefab) as DormitoryCell; cells[coords.x, coords.z] = cell; cell.name = "Dorm cell " + coords.x + ", " + coords.z + "; floor " + i; cell.transform.parent = transform; cell.transform.localPosition = new Vector3(coords.x * 2f - size.x * 1f + 1f, (float)(i * floorHeight), coords.z * 2f - size.z * 1f + 1f); if (i < floors) { CreateWalls(coords, cell, i); } }
public void CreateExternalDoor(DormitoryCell cellA, DormitoryCell cellB, DormitoryDirection direction, bool mirrored) { DormitoryExternalDoor door = Instantiate(extDoorPrefab) as DormitoryExternalDoor; door.Initialize(cellA, cellB, direction); if (cellB != null) { door = Instantiate(extDoorPrefab) as DormitoryExternalDoor; door.Initialize(cellB, cellA, direction.GetOpposite()); } if (mirrored) { door.transform.localPosition = new Vector3(0f, 0f, -1f); door.transform.localRotation = direction.GetOpposite().ToRotation(); } }
private void CreateWalls(IntVector2 coords, DormitoryCell cell, int floor) { if (coords.x == 0) { CreateWall(cell, null, DormitoryDirection.WEST); } if (coords.x == size.x - 1) { CreateWall(cell, null, DormitoryDirection.EAST); } if (coords.z == 0) { if (floor == 0) { if (coords.x == size.x / 2 - 1) { CreateExternalDoor(cell, null, DormitoryDirection.SOUTH, true); } else if (coords.x == size.x / 2) { CreateExternalDoor(cell, null, DormitoryDirection.SOUTH, false); } else { CreateWall(cell, null, DormitoryDirection.SOUTH); } } else { CreateWall(cell, null, DormitoryDirection.SOUTH); } } if (coords.z == size.z - 1) { CreateWall(cell, null, DormitoryDirection.NORTH); } }