コード例 #1
0
        /// <summary>
        /// Adjust the size of the Game Board this then calls in to AdjustGameBlockSize (debate the need for seperate functions...)
        /// </summary>
        /// <returns></returns>
        public bool AdjustGameBoardSize(CInt2D GameBoardSize)
        {
            //Validate input settings
            if ((GameBoardSize.X > 2048 || GameBoardSize.X < 100) ||
                (GameBoardSize.Y > 2048 || GameBoardSize.Y < 100))
            {
                //Won't adjust the game board with outrageous dimensions
                return(false);
            }

            //Set the game board size to the input of GameBoardSize
            GameSettings.GameBoardSize = GameBoardSize;

            //Adjust the game block size based upon the game board size
            GameSettings.GameBlockSize = new CInt2D((GameBoardSize.X / GameSettings.iCols),
                                                    (GameBoardSize.Y / GameSettings.iRows));

            //Adjust all the GameBlocks
            if (AdjustGameBlocks() == false)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        }//end of EqualX(int iCompare)

        /// <summary>
        /// Compares input i2dCompare for only y value and returns true if input and this are equal
        /// </summary>
        /// <param name="i2dCompare"></param>
        /// <returns></returns>
        public bool EqualsY(CInt2D i2dCompare)
        {
            if (i2dCompare.y == y)
            {
                return(true);
            }

            return(false);
        }//end of EqualY(CInt2D i2dCompare)
コード例 #3
0
        }//end of Equal2D

        /// <summary>
        /// Compares input i2dCompare for only x value and returns true if input and this are equal
        /// </summary>
        /// <param name="i2dCompare"></param>
        /// <returns></returns>
        public bool EqualsX(CInt2D i2dCompare)
        {
            if (i2dCompare.x == x)
            {
                return(true);
            }

            return(false);
        }//end of EqualX(CInt2D i2dCompare)
コード例 #4
0
        /// <summary>
        /// Compares input i2dCompare to the current structure and returns true if both x, y are equivelant
        /// </summary>
        /// <param name="i2dCompare"></param>
        /// <returns></returns>
        public bool Equals2D(CInt2D i2dCompare)
        {
            if ((i2dCompare.x == x) && (i2dCompare.y == y))
            {
                return(true);
            }

            return(false);
        }//end of Equal2D
コード例 #5
0
        public void CopyFrom(CGameBlock GameBlock)
        {
            if (GameBlock == null)
            {
                //GameBlock doesn't exist, do not copy
                return;
            }

            iContent = GameBlock.iContent;
            Position = GameBlock.Position;
        }
コード例 #6
0
        /// <summary>
        /// Adjust the number of colrows for the board (N (Columns) x M (Rows) )
        ///   changing this value will reset the game
        /// </summary>
        /// <param name="i2dColsRows"></param>
        /// <returns></returns>
        public bool AdjustNumberOfColsAndRows(CInt2D i2dColsRows)
        {
            //Validate the input
            if (i2dColsRows.X < 2 || i2dColsRows.X > 6 || i2dColsRows.Y < 2 || i2dColsRows.Y > 6)
            {
                return(false);
            }

            //Validate the settings have changed (if they haven't, still return true)
            if (i2dColsRows.X == GameSettings.iCols && i2dColsRows.Y == GameSettings.iRows)
            {
                return(true);
            }


            System.Diagnostics.Debug.WriteLine("iColumns:" + i2dColsRows.X.ToString() +
                                               "\tiRows:" + i2dColsRows.Y.ToString());

            return(InitializeGame(i2dColsRows.X,
                                  i2dColsRows.Y,
                                  GameSettings.GameBoardSize.X,
                                  GameSettings.GameBoardSize.Y));
        }
コード例 #7
0
 public CGameBlock()
 {
     iContent = 0;
     Position = new CInt2D(0, 0);
 }