I'm trying to make a puzzle game. Specifically, a clone of the Barrels minigame from Mario & Luigi: Superstar Saga (see here:
https://youtu.be/vYZpsaA66Ug?si=d6aHAMAOtY_oLfSG&t=73). The first thing I wanna nail down is populating the board with different-color blocks, 12 red and 12 blue, and placing them on random spots in the grid without having them overlap. The other mechanics, such as detecting if every block in a column or row is the same then erasing them, incrementing score, etc., are not fully implemented.
Each block belongs to an Actor Group called "Block" that is set to not collide with itself so as to avoid misalignment with the grid. With that said, my approach was to make a 2D List that contains six lists corresponding to each row in the board. Each list contains six values, going from 0 to 5, corresponding to the position of each column within the row. I then created a custom block with a loop that randomly picks a list, then a value within the list, and places the colored block of choice in that position. To (ideally) prevent the same spot from being picked again, the value is removed from the list, then the list is removed from the 2D list once its empty.
Unfortunately, there's a flaw in the code that I can't identify, and blocks are being placed within positions that already have a block in them. I figure if I share it here (in the attachment below), someone else can tell me what I did wrong. I've also thought of using Photon's 2D List Extension, but I wanted to see if I can at least identify the problem before moving on, or perhaps think of a more optimal method.