コード例 #1
0
 internal VerifiedMove(IReadOnlyPiece movingPiece, IReadOnlyPlayer player, IEnumerable <IntegerVector2> worldPath, IntegerVector2 viaPositionNode)
 {
     MovingPiece     = movingPiece;
     Player          = player;
     WorldPath       = worldPath;
     ViaPositionNode = viaPositionNode;
 }
コード例 #2
0
 public void SetOnBoard(PublicDataType.IntegerVector2 position)
 {
     if (this.Position == new PublicDataType.IntegerVector2(-1, -1))
     {
         this.Position = position;
     }
 }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
 public bool MoveTo(PublicDataType.IntegerVector2 position, bool isForceMove = false)
 {
     if (!isForceMove && !IsMoveable(position))
     {
         return(false);
     }
     this.Position = position;
     return(true);
 }
コード例 #5
0
        public virtual bool CaptureFromBoard()
        {
            if (!IsCapturable())
            {
                return(false);
            }

            Position = new PublicDataType.IntegerVector2(-1, -1);
            return(true);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 public T Read(IntegerVector2 position)
 {
     return(array[position.y, position.x]);
 }
コード例 #10
0
 public void Write(IntegerVector2 position, T item)
 {
     array[position.y, position.x] = item;
 }
コード例 #11
0
        public bool TryToGetPieceMovement(PublicDataType.IntegerVector2 worldPosition, out PieceMovement pieceMovement)
        {
            var relativePosition = ConvertWorldPositionToRelativePosition(worldPosition);

            return(TryToGetPieceMovementByRelativePosition(relativePosition, out pieceMovement));
        }
コード例 #12
0
        public bool IsMoveable(PublicDataType.IntegerVector2 worldPosition)
        {
            PieceMovement pieceMovement;

            return(TryToGetPieceMovement(worldPosition, out pieceMovement));
        }