예제 #1
0
        /// <summary>
        /// Checks if the user places the first move in the respective corner
        /// </summary>
        /// <returns><c>true</c>, if board first move was checked, <c>false</c> otherwise.</returns>
        /// <param name="b">The blue component.</param>
        /// <param name="p">P.</param>
        public bool CheckBoardFirstMove(Block b, Player p)
        {
            bool check = false;
            int  x = 0, y = 0;

            if (p.Color == Color.Blue)
            {
                x = 20;
                y = 10;
            }
            else if (p.Color == Color.Red)
            {
                x = 400;
                y = 10;
            }
            else if (p.Color == Color.Green)
            {
                x = 20;
                y = 390;
            }
            else if (p.Color == Color.Gold)
            {
                x = 400;
                y = 390;
            }

            foreach (Square s in _myboard)
            {
                foreach (Square blocksquare in b.Squares)
                {
                    if ((blocksquare.X == x) && (blocksquare.Y == y))
                    {
                        check = true;
                        p.PlayMove();
                    }
                }
            }
            if (check)
            {
                foreach (Square s in _myboard)
                {
                    foreach (Square blocksquare in b.Squares)
                    {
                        if (blocksquare.X == s.X && blocksquare.Y == s.Y && s.Color == Color.AntiqueWhite)
                        {
                            s.Color = b.Color;
                        }
                    }
                }
                return(true);
            }
            return(false);
        }