private void DrawWalls(TriGrid grid) { float halfSideSize = sideSize / 2; int halfSideSizeInt = (int)halfSideSize; float height = TriangleHeight; float halfHeight = height / 2.0f; for (int i = 0; i < grid.height; ++i) { int centerY = tex.height - ((int)(halfHeight + i * height)); int north = (int)(centerY + halfHeight); int south = north - (int)height; // upright for (int j = (i % 2); j < grid.width; j += 2) { int centerX = halfSideSizeInt + j * halfSideSizeInt; int west = Mathf.Max(0, centerX - halfSideSizeInt); int east = centerX + halfSideSizeInt; int currentVertex = grid.PositionToVertex(i, j); if (!grid.Graph.AreLinked(currentVertex, grid.EastOf(currentVertex))) { tex.Line(new Vector2Int(east, south), new Vector2Int(centerX, north), wallColor); } if (!grid.Graph.AreLinked(currentVertex, grid.SouthOf(currentVertex))) { tex.HorizontalLine(west, east, south, wallColor); } } // !upright for (int j = ((i + 1) % 2); j < grid.width; j += 2) { int centerX = (int)(halfSideSize + j * halfSideSize); int west = centerX - halfSideSizeInt; int east = centerX + halfSideSizeInt; int currentVertex = grid.PositionToVertex(i, j); if (!grid.Graph.AreLinked(currentVertex, grid.EastOf(currentVertex))) { tex.Line(new Vector2Int(east, north), new Vector2Int(centerX, south), wallColor); } if (!grid.Graph.AreLinked(currentVertex, grid.NorthOf(currentVertex))) { tex.HorizontalLine(west, east, north, wallColor); } } } }