Beispiel #1
0
        public ChessHalfSet GetHalf(PieceColor color)
        {
            if (color.IsWhite())
            {
                return(whiteHalf);
            }

            return(blackHalf);
        }
Beispiel #2
0
 public HelperData(Position position, PieceColor color)
 {
     this.color    = color;
     this.position = position;
     if (color.IsWhite())
     {
         this.pieces = position.GetWhitePieces();
     }
     else
     {
         this.pieces = position.GetBlackPieces();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Start playground in a regular fashion when a match is known
        /// </summary>
        private async void StartRegular(MatchEntity match)
        {
            // which player are we?
            playerColor = match.WhitePlayer == Auth.Player
                ? PieceColor.White : PieceColor.Black;

            // who is the opponent
            UnisavePlayer opponentPlayer = playerColor.IsWhite()
                ? match.BlackPlayer : match.WhitePlayer;

            // connect to the opponent
            if (opponentPlayer == null)
            {
                // AI
                Debug.Log("Starting computer opponent...");
                opponent = new ComputerOpponent(
                    playerColor.Opposite(),
                    board,
                    match.Duration
                    );
            }
            else
            {
                // Real person
                Debug.Log("Connecting to photon opponent...");
                opponent = PhotonOpponent.CreateInstance(match.EntityId);
            }

            // create and setup the board
            board.CreateBoard(
                playerColor.IsWhite(),
                match.WhitePlayerSet,
                match.BlackPlayerSet
                );

            // create the clock
            clock = new Clock(match.Duration);

            // register opponent events
            opponent.OnMoveFinish += OpponentsMoveWasFinished;
            opponent.OnGiveUp     += OnOpponentGaveUp;
            opponent.OnOutOfTime  += OnOpponentTimeOver;

            // wait for the opponent
            Debug.Log("Waiting for the opponent...");
            await opponent.WaitForReady();

            // === start the game ===

            // if we are white, we are the one to start
            Debug.Log("Game has started.");
            if (playerColor.IsWhite())
            {
                PerformOurMove();
            }
            else
            {
                // it's the opponents turn so just wait
                clock.StartOpponent();
            }
        }