Я разрабатываю карточную игру, но мне нужна функция, которая останавливает программу до тех пор, пока игрок не щелкнет в PictureBox своей карты, чтобы отказаться от нее. Алгоритм моей игры таков:
int nextDrawer = 0; // the players which will discard a card are determinated in counterclockwise starting from the human player
for (int i = 0; i < players; i++) // untill all the players hasn't drawed a card
{
if (i == 0) .... // the human player has to click on a picture box to discard a card
else .... // an AI player will discard a card which is selected randomly from the 3 cards which AI has got in its hand
}
Проблема в том, что когда манс заканчивается, может измениться тот, кто сбросит карту первым. Если игроки пронумерованы 0 (игрок-человек), 1 (первый ИИ-игрок), 2 (второй ИИ-игрок) и 3 (третий ИИ-игрок), при первом шаге первым сбрасывает карту игрок-человек, но при вторым человеком, который первым сбрасывается, может быть 2 ИИ-игрока, а игрок-человек должен ждать, пока все ИИ-игроки перед ним сбросят карту (в этом случае раунд будет 2-3-0-1).
Как я могу отменить событие щелчка, если игроки ИИ еще не сбросили карту?
ОБНОВЛЕНИЕ
Мне не всегда нужно ждать, пока все ИИ-игроки вытянут карты: если победителем манса является номер 2, раунд будет 2-3-0-1: это означает, что Игрок должен дождаться, когда ИИ-игроки 2 и 3 вытянут карты, затем игрок должен щелкнуть один PictureBox, и цикл вернется обратно к ИИ-игрокам, а затем ИИ-игроку 1 разрешено сбросить свою карту.
ОБНОВЛЕНИЕ 2
Я подумал что-то вроде этого:
int leader = 0; // who is going to discard first
int nextDiscarder = leader; // next player who's going to discard
for (int i = 0; i < nPlayers; i++) // until all the players hasn't discarded
{
if (nextDiscarder == 0) // the human has to discard
{
enablePictureBoxClickEvent;
// now before the loop continue the program has to wait the event click on a picture box
}
else
{
AI[nextDiscarder].discard(); // the ai player will discard
}
if (nextDiscarder == players - 1) // if nextDiscarder has reached the end of the table
nextDiscarder = 0; // return to the begin until all player has discarded a card
else
++nextDiscarder; // continue to discard with the next player
}
и в моем событии нажмите, я бы сделал что-то вроде этого:
private myEventClick(object sender, EventArgs e)
{
.... // do the instructions needed to discard a card
disableMyEventClick;
returnToLoop;
}
но главная проблема в том, что я не знаю как написать в коде мою инструкцию returnToLoop
.