private int DrawFromVertex3(IntVector2 topLeftCell, HexSprite currentSprite, IntVector2 currentCell, List <IntVector2> gridCells, List <Vector3> vertexList) { IntVector2 nextCell; // compare the coordinates of the next // if current x even, the next cell on the same y level is up; if odd, it's down // if even and x, y or if odd and x, y-1 if (currentCell.x % 2 == 0) { nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x + 1 && c.y == currentCell.y + 1); } else { nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x + 1 && c.y == currentCell.y); } if (nextCell != null) { // we need 1->2 of the next cell HexSprite nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>(); vertexList.Add(nextSprite.FindVertex2()); //gridCells.Remove(nextCell); return(DrawFromVertex2(topLeftCell, nextSprite, nextCell, gridCells, vertexList)); } else { // vertex 3 should not touch the topLeftHex, so draw 3 -> 4 on this cell and continue vertexList.Add(currentSprite.FindVertex4()); return(DrawFromVertex4(topLeftCell, currentSprite, currentCell, gridCells, vertexList)); } }
private int DrawFromVertex5(IntVector2 topLeftCell, HexSprite currentSprite, IntVector2 currentCell, List <IntVector2> gridCells, List <Vector3> vertexList) { IntVector2 nextCell; // compare the coordinates of the next // if current x even, the next cell on the same y level is up; if odd, it's down // if even and x, y or if odd and x, y-1 if (currentCell.x % 2 == 0) { nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x - 1 && c.y == currentCell.y + 1); } else { nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x - 1 && c.y == currentCell.y); } if (nextCell != null) { // we need 3->4 of the next cell HexSprite nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>(); vertexList.Add(nextSprite.FindVertex4()); return(DrawFromVertex4(topLeftCell, nextSprite, nextCell, gridCells, vertexList)); } else { // see if the top left hex is to our bottom left if ((currentCell.x % 2 == 0 && topLeftCell.x == currentCell.x - 1 && topLeftCell.y == currentCell.y + 1) || (currentCell.x % 2 == 1 && topLeftCell.x == currentCell.x - 1 && topLeftCell.y == currentCell.y)) { return(2); } else { // draw 5->6 on this cell and continue vertexList.Add(currentSprite.FindVertex6()); return(DrawFromVertex6(topLeftCell, currentSprite, currentCell, gridCells, vertexList)); } } }