public override void UpdateGameObject(IGameObject gameObject) { if (!this.Equals(gameObject)) { this.chessPiece = gameObject as IChessPiece; } }
/// <summary> /// The Constructor which sets the color to nothing and initializes the CanEatHere and CanMoveHere lists /// </summary> /// <param name="currentChessChessPiece">The Chesspiece, which will be on this CellViewModel</param> /// <param name="board">The Board this CellViewModel is on</param> public CellViewModel(IChessPiece currentChessChessPiece, [NotNull]IBoard board) { CurrentChessPiece = currentChessChessPiece; Board = board; Bgc = NothingColor; CanEatHere = new List<Path.Path>(); CanMoveHere = new List<Path.Path>(); }
public Position GetPiecePosition(IChessPiece piece) { throw new NotImplementedException(); }
public void Render(IChessPiece chessRoot) { throw new System.NotImplementedException(); }
private bool AttributesAreSame(IChessPiece other) { return this.Attack.Equals(other.Attack) && this.Defence.Equals(other.Defence) && this.IsDead == other.IsDead && this.Health == other.Health && this.Mana == other.Mana && this.Color == other.Color && this.MovePattern == other.MovePattern; }
private bool ObjectIsSame(IChessPiece other) { return this.chessPiece.Equals(other); }
public DrawableChessPiece(GameEngine game, IChessPiece gameObject) : base(game, gameObject) { this.chessPiece = gameObject; }
private bool IsOtherPieceBlockingMove(IChessPiece chessPieceMoved, int finalColumnPosition, int finalRowPosition, List <IChessPiece> chessPiecesList) { //Check if there are other pieces on board if (chessPiecesList.Count < 1) { return(false); } //Filter away all pieces that rook could not even touch var PiecesInTheWay = chessPiecesList.Where(cp => IsRookMovement(chessPieceMoved, cp.Position.ColumnPosition, cp.Position.RowPosition)); //Check for direction of movement RookMovementDirection?direction = null; if (chessPieceMoved.Position.ColumnPosition < finalColumnPosition) { direction = RookMovementDirection.Right; } else if (chessPieceMoved.Position.ColumnPosition > finalColumnPosition) { direction = RookMovementDirection.Left; } else if (chessPieceMoved.Position.RowPosition < finalRowPosition) { direction = RookMovementDirection.Up; } else if (chessPieceMoved.Position.RowPosition > finalRowPosition) { direction = RookMovementDirection.Down; } switch (direction) { case RookMovementDirection.Up: PiecesInTheWay = PiecesInTheWay.Where(cp => chessPieceMoved.Position.RowPosition < cp.Position.RowPosition); break; case RookMovementDirection.Right: PiecesInTheWay = PiecesInTheWay.Where(cp => chessPieceMoved.Position.ColumnPosition < cp.Position.ColumnPosition); break; case RookMovementDirection.Down: PiecesInTheWay = PiecesInTheWay.Where(cp => chessPieceMoved.Position.RowPosition > cp.Position.RowPosition); break; case RookMovementDirection.Left: PiecesInTheWay = PiecesInTheWay.Where(cp => chessPieceMoved.Position.ColumnPosition > cp.Position.ColumnPosition); break; } if (PiecesInTheWay.ToList().Count < 1) { return(false); } var closestPieceComparer = new ClosestChessPieceComparer(chessPieceMoved); IChessPiece closestPieceInTheWay = PiecesInTheWay.OrderBy(cp => cp, closestPieceComparer).First(); var distanceBetweenDestinationAndClosets = closestPieceComparer.FloatCompare(new Rook(0, finalColumnPosition, finalRowPosition), closestPieceInTheWay); //Check if it blocks the move to final destination or is too far to interrupt movement bool isPieceInTheWay = distanceBetweenDestinationAndClosets >= 0; //Check if final destination and closest piece are on the same tile and different colors (Main piece tries to attack) bool isMainAttacking = distanceBetweenDestinationAndClosets == 0 && closestPieceInTheWay.Color != chessPieceMoved.Color; //If there is no piece in the way or main piece attacks the other allow move if (!isPieceInTheWay || isMainAttacking) { return(false); } return(true); }
//***End Drag and Drop public UiChessPiece(IChessPiece piece) { this._piece = piece; //this._chessboard = chessboard; }
private void RemoveFromBoard(IChessPiece piece) { piece.XCoordinate = OffBoardCoordinate; piece.YCoordinate = OffBoardCoordinate; piece.SetBoard(null); }