/// <summary> /// 指定された駒を空いたマスに移動する. /// </summary> /// <param name="movingPiece"></param> /// <param name="endWorldPosition"></param> /// <param name="isForceMove"></param> /// <returns></returns> public bool MovePiece(IPiece movingPiece, PublicDataType.IntegerVector2 endWorldPosition, bool isForceMove = false) { PublicDataType.IntegerVector2 startWorldPosition = movingPiece.Position; if (pieceMap.Read(endWorldPosition) != null) { return(false); } if (!movingPiece.MoveTo(endWorldPosition, isForceMove)) { return(false); } //この順で書きまないと現在いる座標と同じ座標をendWorldPositionに指定されたとき盤上から駒の判定がなくなる pieceMap.Write(startWorldPosition, null); pieceMap.Write(endWorldPosition, movingPiece); return(true); }
public bool SetPiece(PublicDataType.IntegerVector2 position, IPiece piece) { if (!IsOnBoard(position) || pieces.Read(position) != null) { return(false); } if (piece.Position != new PublicDataType.IntegerVector2(-1, -1)) { return(false); } piece.SetOnBoard(position); pieces.Write(position, piece); onEveryValueChanged.OnNext(Unit.Default); return(true); }
public CaptureResult CapturePiece(IPlayer player, IPiece capturer, PublicDataType.IntegerVector2 targetPosition) { IPiece targetPiece = pieces.Read(targetPosition); if (targetPiece == null) { return(new CaptureResult(true, capturer, null, null, targetPosition)); } if (!IsCapturable(player, capturer, targetPiece) || !targetPiece.CaptureFromBoard()) { return(new CaptureResult(false, capturer, null, null, targetPosition)); } IPlayer formerOwner = targetPiece.Owner; targetPiece.SetOwner(player); pieces.Write(targetPosition, null); return(new CaptureResult(true, capturer, targetPiece, formerOwner, targetPosition)); }