Private Sub BtnFillClick(sender As Object, e As EventArgs) Handles btnFillKeys.Click,…
- User
Private Sub BtnFill_Click(sender As Object, e As EventArgs) Handles btnFillKeys.Click, btnFillEdge.Click TurnOffSelectionMode() If Not isRestoringState Then SaveStateForUndo()
' Loop through each square in the grid For y As Integer = 0 To SQCOUNTY - 1 For x As Integer = 0 To SQCOUNTX - 1 Dim wallCount As Integer = 0 Dim isFlipperPresent As Boolean = False ' To track if any flippers are present ' Count the walls around the square at (x, y) ' Count vertical walls If x = 0 OrElse (x > 0 AndAlso (verticalWalls(x)(y) OrElse IsFlipperItem(verticalWallItems(x)(y)))) Then wallCount += 1 ' Check vertical wall on the left If IsFlipperItem(verticalWallItems(x)(y)) Then isFlipperPresent = True End If If x = SQCOUNTX - 1 OrElse (x < SQCOUNTX - 1 AndAlso (verticalWalls(x + 1)(y) OrElse IsFlipperItem(verticalWallItems(x + 1)(y)))) Then wallCount += 1 ' Check vertical wall on the right If IsFlipperItem(verticalWallItems(x + 1)(y)) Then isFlipperPresent = True End If ' Count horizontal walls If y = 0 OrElse (y > 0 AndAlso (horizontalWalls(x)(y) OrElse IsFlipperItem(horizontalWallItems(x)(y)))) Then wallCount += 1 ' Check horizontal wall on the top If IsFlipperItem(horizontalWallItems(x)(y)) Then isFlipperPresent = True End If If y = SQCOUNTY - 1 OrElse (y < SQCOUNTY - 1 AndAlso (horizontalWalls(x)(y + 1) OrElse IsFlipperItem(horizontalWallItems(x)(y + 1)))) Then wallCount += 1 ' Check horizontal wall on the bottom If IsFlipperItem(horizontalWallItems(x)(y + 1)) Then isFlipperPresent = True End If ' Logic to place keys If wallCount = 3 AndAlso Not isFlipperPresent AndAlso placedItems(x)(y) Is Nothing Then placedItems(x)(y) = New ItemInfo("picKey", New Point(x, y), Guid.NewGuid().ToString()) End If ' Logic to fill edge style If wallCount = 4 Then floorsUseEdgeStyle(x)(y) = True End If Next NextEnd Sub Private Sub BtnFillEdge_Click(sender As Object, e As EventArgs) Handles btnFillEdge.Click TurnOffSelectionMode() If Not isRestoringState Then SaveStateForUndo()
' Loop through each square in the grid For y As Integer = 0 To SQCOUNTY - 1 For x As Integer = 0 To SQCOUNTX - 1 Dim wallCount As Integer = 0 ' Count the walls around the square at (x, y) If x = 0 OrElse (x > 0 AndAlso verticalWalls(x)(y)) Then wallCount += 1 ' Check vertical wall on the left End If If x = SQCOUNTX - 1 OrElse (x < SQCOUNTX - 1 AndAlso verticalWalls(x + 1)(y)) Then wallCount += 1 ' Check vertical wall on the right End If If y = 0 OrElse (y > 0 AndAlso horizontalWalls(x)(y)) Then wallCount += 1 ' Check horizontal wall on the top End If If y = SQCOUNTY - 1 OrElse (y < SQCOUNTY - 1 AndAlso horizontalWalls(x)(y + 1)) Then wallCount += 1 ' Check horizontal wall on the bottom End If ' Check if the square is surrounded by 4 walls If wallCount = 4 Then floorsUseEdgeStyle(x)(y) = True End If Next Next End Sub Private Sub BtnFillCoins_Click(sender As Object, e As EventArgs) Handles btnFillCoins.Click TurnOffSelectionMode() If Not isRestoringState Then SaveStateForUndo() ' Loop through each square in the grid For y As Integer = 0 To SQCOUNTY - 1 For x As Integer = 0 To SQCOUNTX - 1 Dim wallCount As Integer = 0 Dim isFlipperPresent As Boolean = False ' To track if any flippers are present ' Count the walls around the square at (x, y) If x = 0 OrElse (x > 0 AndAlso (verticalWalls(x)(y) OrElse IsFlipperItem(verticalWallItems(x)(y)))) Then wallCount += 1 ' Check vertical wall on the left If IsFlipperItem(verticalWallItems(x)(y)) Then isFlipperPresent = True End If If x = SQCOUNTX - 1 OrElse (x < SQCOUNTX AndAlso (verticalWalls(x + 1)(y) OrElse IsFlipperItem(verticalWallItems(x + 1)(y)))) Then wallCount += 1 ' Check vertical wall on the right If IsFlipperItem(verticalWallItems(x + 1)(y)) Then isFlipperPresent = True End If If y = 0 OrElse (y > 0 AndAlso (horizontalWalls(x)(y) OrElse IsFlipperItem(horizontalWallItems(x)(y)))) Then wallCount += 1 ' Check horizontal wall on the top If IsFlipperItem(horizontalWallItems(x)(y)) Then isFlipperPresent = True End If If y = SQCOUNTY - 1 OrElse (y < SQCOUNTY AndAlso (horizontalWalls(x)(y + 1) OrElse IsFlipperItem(horizontalWallItems(x)(y + 1)))) Then wallCount += 1 ' Check horizontal wall on the bottom If IsFlipperItem(horizontalWallItems(x)(y + 1)) Then isFlipperPresent = True End If ' Check if the square is not occupied, has three walls, and does not contain a flipper If wallCount = 3 AndAlso Not isFlipperPresent AndAlso placedItems(x)(y) Is Nothing Then placedItems(x)(y) = New ItemInfo("picCoin", New Point(x, y), Guid.NewGuid().ToString()) End If Next Next End Sub - Assistant
- User
- Assistant
- User
We also need to do a check if it was btnFilLEdge. As the other items are fillingedge
- Assistant