Beispiel #1
0
        public GameForm(int i_numOfBlocks, List <Color> i_computerGuessColor, Game i_gameObject)
        {
            m_gameObject  = i_gameObject;
            this.AutoSize = true;
            this.Text     = "Bulls Eye";
            this.CenterToScreen();

            m_blockCollection    = new List <GuessBlock>();
            m_computerGuessBlock = new ComputerGuessBlock(i_computerGuessColor, 20, 20);
            foreach (Button btn in m_computerGuessBlock.VisibleComputerGuess)
            {
                this.Controls.Add(btn);
            }

            int YOfBlock = 100; ///it's the Y of the first block, the rest are set according to it

            for (int i = 0; i < i_numOfBlocks; i++)
            {
                GuessBlock blockToAdd = new GuessBlock(20, YOfBlock);
                AddSingleBlockToForm(blockToAdd);
                blockToAdd.ConfirmSelectionButton.Name = i.ToString();
                m_blockCollection.Add(blockToAdd);
                YOfBlock += blockToAdd.PickColorButtons[0].Height + 10;
            }
            this.EnableBlock(0);
        }
Beispiel #2
0
        private void AddSingleBlockToForm(GuessBlock i_blockToAdd)
        {
            foreach (Button buttonToAdd in i_blockToAdd.PickColorButtons)
            {
                this.Controls.Add(buttonToAdd);
            }

            foreach (Button buttonToAdd in i_blockToAdd.UserSelectionButtons)
            {
                this.Controls.Add(buttonToAdd);
            }

            this.Controls.Add(i_blockToAdd.ConfirmSelectionButton);
            i_blockToAdd.ConfirmSelectionButton.Click += ConfirmSelectionButton_Click;
        }