private void GetLeftCollision() { Rect leftRect = new Rect(); for (int col = 0; col < mapData.Width; ++col) { for (int row = 0; row < mapData.Height; ++row) { Tile currentTile = mapData[row, col]; if (IsNormalCollision(currentTile)) { if (col - 1 >= 0) { Tile leftTile = mapData[row, col - 1]; if (IsNormalCollision(leftTile)) { continue; } } else { continue; } leftRect.x = col; leftRect.y = row; while (row + 1 < mapData.Height) { currentTile = mapData[row + 1, col]; if (col - 1 >= 0) { Tile leftTile = mapData[row, col - 1]; if (IsNormalCollision(leftTile)) { --row; break; } } if (IsNormalCollision(currentTile)) { ++row; } else { break; } } leftRect.width = 0; leftRect.height = row - leftRect.y + 1; RectangleMesh leftMesh = new RectangleMesh(leftRect); leftMesh.BuildVerticalMesh(); meshes.Add(leftMesh.Mesh); } } } }
private void GetRightCollision() { Rect rightRect = new Rect(); for (int col = 0; col < mapData.Width; ++col) { for (int row = 0; row < mapData.Height; ++row) { Tile currentTile = mapData[row, col]; if (IsNormalCollision(currentTile)) { if (col + 1 < mapData.Width) { Tile rightTile = mapData[row, col + 1]; if (IsNormalCollision(rightTile)) { continue; } } else { return; } rightRect.x = col + 1; rightRect.y = row; while (row + 1 < mapData.Height) { currentTile = mapData[row + 1, col]; if (col + 1 < mapData.Width) { Tile rightTile = mapData[row, col + 1]; if (IsNormalCollision(rightTile)) { --row; break; } } if (IsNormalCollision(currentTile)) { ++row; } else { break; } } rightRect.width = 0; rightRect.height = row - rightRect.y + 1; RectangleMesh rightMesh = new RectangleMesh(rightRect); rightMesh.BuildVerticalMesh(); rightMesh.InvertMesh(); meshes.Add(rightMesh.Mesh); } } } }
private void GetRightCollision () { Rect rightRect = new Rect(); for (int col = 0; col < mapData.Width; ++col) { for (int row = 0; row < mapData.Height; ++row) { Tile currentTile = mapData[row, col]; if (IsNormalCollision(currentTile)) { if (col + 1 < mapData.Width) { Tile rightTile = mapData[row, col + 1]; if (IsNormalCollision(rightTile)) { continue; } } else { return; } rightRect.x = col + 1; rightRect.y = row; while (row + 1 < mapData.Height) { currentTile = mapData[row + 1, col]; if (col + 1 < mapData.Width) { Tile rightTile = mapData[row, col + 1]; if (IsNormalCollision(rightTile)) { --row; break; } } if (IsNormalCollision(currentTile)) { ++row; } else { break; } } rightRect.width = 0; rightRect.height = row - rightRect.y + 1; RectangleMesh rightMesh = new RectangleMesh(rightRect); rightMesh.BuildVerticalMesh(); rightMesh.InvertMesh(); meshes.Add(rightMesh.Mesh); } } } }
private void GetLeftCollision () { Rect leftRect = new Rect(); for (int col = 0; col < mapData.Width; ++col) { for (int row = 0; row < mapData.Height; ++row) { Tile currentTile = mapData[row, col]; if (IsNormalCollision(currentTile)) { if (col - 1 >= 0 ) { Tile leftTile = mapData[row, col - 1]; if (IsNormalCollision(leftTile)) { continue; } } else { continue; } leftRect.x = col; leftRect.y = row; while (row + 1 < mapData.Height) { currentTile = mapData[row + 1, col]; if (col - 1 >= 0 ) { Tile leftTile = mapData[row, col - 1]; if (IsNormalCollision(leftTile)) { --row; break; } } if (IsNormalCollision(currentTile)) { ++row; } else { break; } } leftRect.width = 0; leftRect.height = row - leftRect.y + 1; RectangleMesh leftMesh = new RectangleMesh(leftRect); leftMesh.BuildVerticalMesh(); meshes.Add(leftMesh.Mesh); } } } }