private void CreateTeleport(Room room) { Vector2 tmp = Vector2.zero; bool ok = false; List <Vector2> tiles = new List <Vector2>(); foreach (Wall wall in room.smartGrid.UpWalls) { if (wall.gameObject.transform.position.x > room.start.x + 2) { tmp = wall.gameObject.transform.position; Wall checkDoor1 = room.GetWallAtPosition(new Vector3(tmp.x + 2, tmp.y)); Wall checkDoor2 = room.GetWallAtPosition(new Vector3(tmp.x - 2, tmp.y)); if (checkDoor1 != null && checkDoor2 != null) { Wall w1 = room.GetWallAtPosition(new Vector3(tmp.x + 1, tmp.y)); Wall w2 = room.GetWallAtPosition(new Vector3(tmp.x - 1, tmp.y)); if (w1 != null && w2 != null) { tiles.Add(w1.gameObject.transform.position); tiles.Add(w2.gameObject.transform.position); tiles.Add(wall.gameObject.transform.position); ok = true; break; } } } } if (ok) { Vector2 lowest = tiles[0]; Vector2 highest = tiles[0]; foreach (Vector2 v in tiles) { lowest = SimpleFunctions.LowestVector(lowest, v); } foreach (Vector2 v in tiles) { highest = SimpleFunctions.HighestVector(highest, v); } List <Wall> walls = room.smartGrid.GetWallsRange(lowest, highest); for (int i = 0; i < walls.Count; i++) { room.smartGrid.RemoveWall(walls[i]); } List <Vector2> rect = SimpleFunctions.GetRectangle(lowest, highest); foreach (Vector2 r in rect) { room.CreateTile(r, FloorType.outside); } room.smartGrid.CreateWallAroundTiles(rect.ToArray()); GameObject tel = room.CreateEnvironmentObject(teleport.gameObject, tmp); room.teleport = tel.GetComponent <Teleport>(); room.SetMiniMapIcon(icons.teleportIcon, tmp); } }