I have a few different dialogs in my game. I am having an issue with 2 of them that I use as generic dialogs. One has just an OK button and the other has an OK and a Cancel button. I have an additional event dispatcher in each so I can provide custom behavior if needed. It all works fine except for in some rare occurrences, the dialog is called 2 times in a row. And when its called 2 times in a row the event dispatcher is only called the first time.
Its a farkle game so for example if the player farkles I will show a single button dialog telling the user they farkled and their turn is over. The game then runs through 3 CPU player turns and then passed control back to the user when the CPU players are finished. When the CPU players are done I show a notification that it is now the players turn and then roll the dice automatically to start. If that first roll results in a farkle, when the player hits the ok button this time nothing happens. I placed a debugger and the event is not being called. So I have a feeling it has something to do with how I am using it. I could always try and not roll the dice automatically the first time when its the players turn again but I’d like to find out what is going on here.
Here is the show function of the dialog. I call it when I need to show a dialog with one button.
Here is the event that is called in the dialog when the ok button is pressed. This is called both times the dialog is opened. No issues here.
Here is a spot where I show it. The PlayerFarkled event is only called the first time.
Any ideas on what might be causing the problem?