示例#1
0
        public GameForm(User user, StartGameResponse teams)
        {
            InitializeComponent();

            this.user  = user;
            Text       = user.username;
            chosedWord = null;
            board      = new List <List <CardLabel> >();
            for (int r = 0; r < 5; r++)
            {
                board.Add(new List <CardLabel>());
                for (int c = 0; c < 5; c++)
                {
                    CardLabel cardLabel = new CardLabel(r, c)
                    {
                        BorderStyle = BorderStyle.FixedSingle,
                        Margin      = new Padding(3),
                        Size        = new Size(104, 61),
                        TextAlign   = ContentAlignment.MiddleCenter,
                        Location    = new Point(202 + 110 * c, 13 + 67 * r)
                    };
                    cardLabel.Click += CardLabel_Click;
                    board[r].Add(cardLabel);
                    Game_Panel.Controls.Add(cardLabel);
                }
            }
            Utils.AddTextsToPanel(RedPlayers_Panel, teams.reds);
            Utils.AddTextsToPanel(BluePlayers_Panel, teams.blues);
            team    = teams.reds.Contains(user.username) ? CardType.RED : CardType.BLUE;
            manager = (team == CardType.RED ? teams.reds : teams.blues)[0] == user.username;
        }
示例#2
0
        private void CardLabel_Click(object sender, EventArgs e)
        {
            CardLabel cardLabel = sender as CardLabel;

            if (GuessWord_Panel.Visible && !cardLabel.revealed)
            {
                if (chosedWord != null)
                {
                    chosedWord.BorderStyle = BorderStyle.FixedSingle;
                }
                else
                {
                    GuessWord_Button.Visible = true;
                }
                cardLabel.BorderStyle = BorderStyle.Fixed3D;
                ChosenWord_Label.Text = cardLabel.Text;
                chosedWord            = cardLabel;
            }
        }
示例#3
0
        private void GuessWord_Button_Click(object sender, EventArgs e)
        {
            GuessWordRequest request = new GuessWordRequest(chosedWord.r, chosedWord.c);

            chosedWord.BorderStyle   = BorderStyle.FixedSingle;
            ChosenWord_Label.Text    = "";
            GuessWord_Panel.Visible  = false;
            GuessWord_Button.Visible = false;
            chosedWord = null;
            try
            {
                StreamHelper.Communicate(user.clientStream, RequestCodes.REVEAL_CARD, request);
            }
            catch (IOException)
            {
                Utils.ConnectionAbortMessageBox();
                Close();
            }
        }