0

Detection Algorithm

Imagine candy crush game: 3 or more cells of the same item in the grid burst. After swapping two cells in the grid the Check() method is called. The Check algorithm goes like this: Check the grid vertically and horizontally. If there are 3 or more cells with same items add those cells into ToBurst list. Return true if the length of ToBurst list is not zero. If Check() return true the Destroy() method will be called which will destroy every cell in ToBurst list and the grid is refilled. How can I detect combo swap? That is a swap that causes the Check() method return true in both ways. As in cases like: . xox oxo . xox axa bob coc . oxx xab oba ocd . etc . If the o and the x are swapped they would trigger a combo.

28th Aug 2020, 8:15 AM
Fernando Moceces
Fernando Moceces - avatar
1 Resposta
+ 1
I would suggest that if you have already identified x and o then at the very beginning of algorithm first check if it's an x or o i.e is it a candy that may trigger a combo swap. If yes then before calling ToBurst call another function that will check the other candy whether it is an x or o if yes then you can trigger combo or else do the normal check for ToBurst
28th Aug 2020, 7:14 PM
Jazz Hands
Jazz Hands - avatar