Exemplo n.º 1
0
 /// <summary>
 /// Stops the timers and disable the possibily to place pawns.
 /// If game was paused it is resumed and timers are restarted.
 /// </summary>
 public void Pause()
 {
     paused = !paused;
     if (paused)
     {
         CurrentPlayerInstance.StopTimer();
     }
     else
     {
         CurrentPlayerInstance.StartTimer();
     }
     raisePropertyChanged("Paused");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initialise players and board for a new game.
        /// </summary>
        public void NewGame()
        {
            boardStack.Clear();
            foreach (var player in players)
            {
                player.Value.reset();
            }
            foreach (var tile in board)
            {
                board[tile.X, tile.Y].Value = -1;
            }

            board[3, 3].Value = 0;
            board[4, 3].Value = 1;
            board[3, 4].Value = 1;
            board[4, 4].Value = 0;

            updateScore();

            isWhiteTurn       = false;
            currentPlayerName = isWhiteTurn ? "White" : "Black";

            foreach (var player in players)
            {
                player.Value.Score = 2;
                //player.Value.Time = 1800000;
            }

            ///time = DateTime.Now.Millisecond;
            //BlackPlayer.reset();
            //WhitePlayer.reset();
            ShowBoard();
            GetPlayableTile(isWhiteTurn);
            CurrentPlayerInstance.StartTimer();
            paused = false;
            winner = "";

            //boardStack.Push((Tile[,])Board.Clone());
            boardStack.Push(CopyBoard());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Play the move if it is playable and valid.
        /// </summary>
        /// <param name="column">Move's X position</param>
        /// <param name="line">Move's Y position</param>
        /// <param name="isWhite">Player who's trying to place the tile</param>
        /// <returns></returns>
        public bool playMove(int column, int line, bool isWhite)
        {
            if (Paused)
            {
                return(false);
            }
            GetPlayableTile(isWhite);
            if (!isPlayable(column, line, isWhite))
            {
                return(false);
            }
            CurrentPlayerInstance.StopTimer();

            board[line, column].Value = isWhite ? 1 : 0;
            FlipTiles(board[line, column], isWhite);
            isWhiteTurn = !isWhiteTurn;

            updateProperties();
            GetPlayableTile(isWhiteTurn);
            if (this.Playable.Count == 0)
            {
                isWhiteTurn = !isWhiteTurn;
                updateProperties();
            }
            CurrentPlayerInstance.StartTimer();
            GetPlayableTile(isWhiteTurn);
            updateScore();
            ShowBoard();
            if (totalScore == 64)
            {
                //fin du jeux
                GameOver("All the pawns have been placed.");
            }
            boardStack.Push(CopyBoard());
            //boardStack.Push((Tile[,])Board.Clone());
            return(true);
        }