Exemple #1
0
        /// <summary>
        /// Resets the game piece back to its original position/orientation.
        /// </summary>
        /// <param name="board">The board to remove piece from, if necessary</param>
        public void Reset(GameBoard board = null)
        {
            if (IsPlaced)
            {
                if (board != null)
                {
                    RemoveFromBoard(board);
                }

                IsPlaced = false;
            }

            _originCell           = _cells.First();
            _indexOfCellUnderTest = -1;

            MoveTo(0, 0);

            if (_isFlipped)
            {
                Flip();
            }

            while (_rotationDeg != 0)
            {
                RotateCw90();
            }

            foreach (var cell in _cells)
            {
                cell.HasBeenTested = false;
            }

            HasBeenCompletelyTested = false;
        }
Exemple #2
0
        // ***************************************************************************
        // *                           Private Methods                               *
        // ***************************************************************************

        /// <summary>
        /// Sets the origin cell to the next available game piece cell of the given type
        /// </summary>
        /// <remarks>
        /// The origin can not be changed if the piece is placed on a board.
        /// </remarks>
        /// <param name="type">Cell type</param>
        /// <returns>True if successful; false otherwise.</returns>
        private bool SetOriginToNextCellOfType(Cell.CellType type)
        {
            if (!IsPlaced)
            {
                GamePieceCell cell;

                for (_indexOfCellUnderTest = _indexOfCellUnderTest + 1; _indexOfCellUnderTest < _cells.Count; _indexOfCellUnderTest++)
                {
                    cell = _cells[_indexOfCellUnderTest];

                    if (cell.Type == type)
                    {
                        _originCell = cell;
                        return(true);
                    }
                }
            }

            return(false);
        }