Пример #1
0
        /// <summary>
        /// Previews a movement of an object on the Board
        /// </summary>
        /// <param name="targetCoordinate">Target Coordinate to be moved</param>
        public void PreviewMoveObject(Coordinate targetCoordinate)
        {
            Tile targetTile = GetTile(targetCoordinate);

            // GameOver.OutOfBounds if tile does not exist
            BoardValidation.ValidateTargetTile(targetTile);

            GameObject targetGameObject = targetTile.CurrentObject;

            BoardValidation.ValidateLegitMovement(targetGameObject, targetCoordinate);
        }
Пример #2
0
        /// <summary>
        /// Moves an object on the Board
        /// </summary>
        /// <param name="targetCoordinate">Target Coordinate to be moved</param>
        /// <param name="sourceCoordinate">Source Coordinate where the object stands currently</param>
        public void MoveObject(Coordinate targetCoordinate, Coordinate sourceCoordinate)
        {
            Tile currentTile = GetTile(sourceCoordinate);
            Tile targetTile  = GetTile(targetCoordinate);

            BoardValidation.ValidateSourceTile(currentTile);
            // GameOver.OutOfBounds if tile does not exist
            BoardValidation.ValidateTargetTile(targetTile);

            GameObject sourceGameObject = currentTile.CurrentObject;
            GameObject targetGameObject = targetTile.CurrentObject;

            BoardValidation.ValidateMovingObject(sourceGameObject);
            BoardValidation.ValidateLegitMovement(targetGameObject, targetCoordinate);

            targetTile.CurrentObject  = sourceGameObject;
            currentTile.CurrentObject = null;
        }