Beispiel #1
0
        static private void Vote()
        {
            int voted = 0;

            foreach (ClientNetworking player in CurrentGame.LocalPlayers)
            {
                CurrentPlayer             = player;
                CurrentPlayer.NextCommand = "NEED VOTE";
                CurrentPlayer.NewCommand  = true;
                while (!CurrentPlayer.NewResponse)
                {
                    Application.DoEvents();
                }
                string[] responseP = CurrentPlayer.LastResponse.Split(' ');
                CurrentPlayer.NewResponse = false;
                switch (responseP[0])
                {
                case "YES":
                    if (CurrentGame.LocalPlayers.Count > 1)
                    {
                        MessageBox.Show("Pass to " + CurrentPlayer.Owner.Name, "Next Player", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    Voting vote = new Voting();
                    if (vote.ShowDialog() == DialogResult.Abort)
                    {
                        break;
                    }
                    voted++;
                    break;

                case "NO":
                    break;

                default:
                    MessageBox.Show("Unexpected Error! Unknown NEED VOTE Response, Application will exit!", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    Exit();
                    break;
                }
            }
            if (CurrentGame.Stage == 'V' && voted < 1)
            {
                waiting.Update("Waiting for other players to submit their votes...");
                waiting.ShowDialog();
            }
        }