public void AddRoad(RoadType type, int number) { var tileSpawn = grid.CellToLocal(nextTilePosition); var start = tileSpawn - (nextRotation * Vector3.up * grid.cellSize.x / 2); Object prefab = null; Object border = null; RoadTile tile = null; switch (type) { case RoadType.FORWARD: tile = new ForwardRoadTile(start, nextRotation); prefab = objectStorage.GetForward(number); border = objectStorage.forwardComplete; break; case RoadType.LEFT: tile = new LeftRoadTile(start, nextRotation); prefab = objectStorage.GetAngle(number); border = objectStorage.angleComplete; break; case RoadType.RIGHT: tile = new RightRoadTile(start, nextRotation); prefab = objectStorage.GetAngle(number); border = objectStorage.angleComplete; nextRotation *= Quaternion.Euler(0, 180, 0); break; } GameObject.Instantiate(prefab, grid.CellToWorld(nextTilePosition), nextRotation, grid.gameObject.transform); GameObject.Instantiate(border, grid.CellToWorld(nextTilePosition) + new Vector3(0, 0, -1), nextRotation, grid.gameObject.transform); tiles.Add(tile); nextTilePosition += tile.GetNextTile(); nextRotation = tile.GetNextRotation(); }