Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Create the board
            BoardHandler bh = new BoardHandler();

            gameBoard = bh.GenerateBoard(pnlBoard, Button_DragEnter, Button_DragDrop);

            //Add drag and drop functionality to tile hand buttons
            Game_Modeling.HandCreator.GenerateHand(pnlTiles, Button_MouseDown);
            //
            currentPlayer = Game_Rules.TurnOrder.DetermineTurnOrder(playerOne, playerTwo, currentGame);
            playerOne.DrawFirstHand(currentGame);
            playerTwo.DrawFirstHand(currentGame);
            FirstTurn();
        }
Exemplo n.º 2
0
        //Dropping letter on board
        private void Button_DragDrop(object sender, DragEventArgs e)
        {
            bool   blankTile = false;
            Button btn       = (Button)sender;//The tile the letter is being placed on

            int[] index = BoardHandler.getRowCol(int.Parse(btn.Tag.ToString()));

            //Make sure an adjacent tile contains a letter or is the center piece
            if (!TilePlacement.CheckAdjacent(index[0], index[1], gameBoard))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            //Save premodified values
            boardAtTurnStart.Add(btn, btn.Text);
            handAtTurnStart.Add(currentTile, currentTile.Text);

            if (currentTile.Text == " ")
            {
                InputBox.SetLanguage(InputBox.Language.English);
                DialogResult res = InputBox.ShowDialog("Select a letter for your tile:",
                                                       "Select a letter",                                                                //Text message (mandatory), Title (optional)
                                                       InputBox.Icon.Information,                                                        //Set icon type (default info)
                                                       InputBox.Buttons.Ok,                                                              //Set buttons (default ok)
                                                       InputBox.Type.ComboBox,                                                           //Set type (default nothing)
                                                       new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
                                                                      "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }, //String field as ComboBox items (default null)
                                                       false,                                                                            //Set visible in taskbar (default false)
                                                       new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold));          //Set font (default by system)
                currentTile.SetTileLetter(InputBox.ResultValue);
                blankTile = true;
            }

            //If it's a preimum board tile, record the multiplier
            if (btn.Text.Equals("Double Word Score") || btn.Text.Equals("*"))
            {
                scoreMultiplier *= 2;
            }
            else if (btn.Text.Equals("Triple Word Score"))
            {
                scoreMultiplier *= 3;
            }
            //Calculate value for premium tiles
            score += CalculateScore.CaluclatePlacedTileScore(btn, currentTile);
            tilesThisTurn.Add(currentTile.Text);

            //Potentially useless
            currentTile.SetBoardPosition(int.Parse(btn.Tag.ToString()));
            //Update board tile
            ib.addTile(new LetterTile(currentTile.Text, currentTile.GetBoardPosition()));

            if (blankTile)
            {
                btn.Text = currentTile.Text;
            }
            else
            {
                btn.Text = e.Data.GetData(DataFormats.StringFormat).ToString();
            }

            btn.AllowDrop = false;
            placements.Add(int.Parse(btn.Tag.ToString()));
            currentTile.Text = "";
        }