コード例 #1
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        internal void DrawGameOver(Player player, Graphics graphics, Rectangle bounds)
        {
            RectangleF newRect = new RectangleF(0.25F * bounds.Width + bounds.X, 0.25F * bounds.Height + bounds.Y, 0.5F * bounds.Width, 0.2F * bounds.Height);

            graphics.FillRectangle(_gameOverBrush, newRect);

            string message = String.Format("Game Over!\r\n{0} is a Winner!", player.PlayerId);
            Font drawFont = new Font("Courier New", 20);
            graphics.DrawString(message, drawFont, Brushes.Black, newRect, new StringFormat() { Alignment = StringAlignment.Center });
        }
コード例 #2
0
ファイル: BoardDrawer.cs プロジェクト: AntonSh/Qu0rid0r
        internal void MarkCurrentPlayer(Player player, int boardSize, Graphics graphics, Rectangle canvasRectangle)
        {
            Brush brush = _playerColors[player.PlayerId];
            Square position = player.Position;

            RectangleF squareRectangle = GetSquareRectangleF(canvasRectangle, boardSize, position);
            graphics.DrawEllipse(_currentPlayerPen, squareRectangle);

            var links = GameEngine.Instance.Board.GetLinksFromSquare(position).ToList();

            foreach (var link in links)
            {
                Rectangle tgtRect = GetSquareRectangle(canvasRectangle, boardSize, link.LinkedSquare(position));
                graphics.FillRectangle(Brushes.SeaGreen, tgtRect);
            }
        }
コード例 #3
0
ファイル: Board.cs プロジェクト: AntonSh/Qu0rid0r
        private bool CanReachDestination(Player p)
        {
            try
            {
                p.BuildShortestPath(this);
                return true;
            }
            catch (InvalidOperationException e)
            {
                if (e.Message == "Path to the goal is blocked")
                {
                    return false;
                }

                throw;
            }
        }
コード例 #4
0
ファイル: Board.cs プロジェクト: AntonSh/Qu0rid0r
        /// <summary>
        /// Moves player in by the link. 
        /// </summary>
        /// <param name="player"></param>
        /// <param name="link"></param>
        protected void MovePlayer(Player player, Link link)
        {
            Square currentPosition = player.Position;

            // Validate current -> desired is not bloced by fence and isn't occupied
            if (GetMoveResult(currentPosition, link) != MoveResult.Succesfull)
            {
                throw new InvalidOperationException("Can not jump over the fence or step on the other player.");
            }

            Square newPosition = link.LinkedSquare(currentPosition);

            ((MovablePlayer)player).MoveTo(newPosition);
        }
コード例 #5
0
 public ShortestPathRunner(Player player, Board board)
     : base(player)
 {
     _board = board;
 }
コード例 #6
0
ファイル: GameEngine.cs プロジェクト: AntonSh/Qu0rid0r
 /// <summary>
 /// Moves player by the link.
 /// </summary>
 internal new void MovePlayer(Player player, Link link)
 {
     base.MovePlayer(player, link);
 }
コード例 #7
0
ファイル: AIPlayer.cs プロジェクト: AntonSh/Qu0rid0r
 public AIPlayer(Player player)
 {
     _player = player;
 }