internal VerifiedMove(IReadOnlyPiece movingPiece, IReadOnlyPlayer player, IEnumerable <IntegerVector2> worldPath, IntegerVector2 viaPositionNode) { MovingPiece = movingPiece; Player = player; WorldPath = worldPath; ViaPositionNode = viaPositionNode; }
public void SetOnBoard(PublicDataType.IntegerVector2 position) { if (this.Position == new PublicDataType.IntegerVector2(-1, -1)) { this.Position = position; } }
/// <summary> /// 初期座標を設定する. /// </summary> /// <param name="position"></param> /// <param name="normalPieceMovements"></param> /// <param name="expansionPieceMovements"></param> public DefaultPiece(PublicDataType.IntegerVector2 position, Terminologies.PieceColor color, IPlayer owner, Terminologies.PieceName name, IExpandingMoveFieldChecker fieldChecker) { this.Name = name; this.Position = position; this.Color = color; this.Owner = owner; this.fieldChecker = fieldChecker; }
public bool MoveTo(PublicDataType.IntegerVector2 position, bool isForceMove = false) { if (!isForceMove && !IsMoveable(position)) { return(false); } this.Position = position; return(true); }
public virtual bool CaptureFromBoard() { if (!IsCapturable()) { return(false); } Position = new PublicDataType.IntegerVector2(-1, -1); return(true); }
PublicDataType.IntegerVector2 ConvertRelativePositionToWorldPosition(PublicDataType.IntegerVector2 relativePosition) { bool isFrontPlayer = Owner != null && Owner.Encampment == Terminologies.Encampment.Front;//仮の条件 if (isFrontPlayer) { relativePosition *= -1; //逆にしたい(!isLocalPlayerのとき-1をかける) } PublicDataType.IntegerVector2 worldPosition = relativePosition + this.Position; return(worldPosition); }
public bool TryToGetPieceMovementByRelativePosition(PublicDataType.IntegerVector2 relativePosition, out PieceMovement pieceMovement) { bool isExpanded = fieldChecker != null && fieldChecker.IsExpandedMoveField(this.Position); foreach (PieceMovement moveable in GetMoveablePosition(isExpanded)) { if (moveable.IsMoveable(relativePosition)) { pieceMovement = moveable; return(true); } } pieceMovement = PieceMovement.Default; return(false); }
public IEnumerable <PublicDataType.IntegerVector2> PredictMoveableColumns(PublicDataType.IntegerVector2 hypotheticalPosition, IReadOnlyPiece movingPiece) { if (movingPiece == null || !board.IsOnBoard(hypotheticalPosition)) { return(Enumerable.Empty <PublicDataType.IntegerVector2>()); } bool isFrontPlayer = movingPiece.Owner != null && movingPiece.Owner.Encampment == Terminologies.Encampment.Front; PieceMovement unused; IEnumerable <PublicDataType.IntegerVector2> allColumn = Enumerable.Range(0, board.Width * board.Height) .Select(x => new PublicDataType.IntegerVector2(x / board.Height, x % board.Height)); IEnumerable <PublicDataType.IntegerVector2> moveable = allColumn .Select(absolutePosition => (absolutePosition - hypotheticalPosition) * (isFrontPlayer ? -1 : 1)) .Where(relativePosition => movingPiece.TryToGetPieceMovementByRelativePosition(relativePosition, out unused)) .Select(relativePosition => relativePosition * (isFrontPlayer ? -1 : 1) + hypotheticalPosition); return(moveable); }
public T Read(IntegerVector2 position) { return(array[position.y, position.x]); }
public void Write(IntegerVector2 position, T item) { array[position.y, position.x] = item; }
public bool TryToGetPieceMovement(PublicDataType.IntegerVector2 worldPosition, out PieceMovement pieceMovement) { var relativePosition = ConvertWorldPositionToRelativePosition(worldPosition); return(TryToGetPieceMovementByRelativePosition(relativePosition, out pieceMovement)); }
public bool IsMoveable(PublicDataType.IntegerVector2 worldPosition) { PieceMovement pieceMovement; return(TryToGetPieceMovement(worldPosition, out pieceMovement)); }