Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            if (isMyTurn)
            {
                passedTime += (long)gameTime.ElapsedGameTime.TotalMilliseconds;
            }
            if (isMyTurn && !isMovingPiece)
            {
                isMovePieceCompleted = false;
                AIPosition           = reversiAI.GetNextpiece();
                AIReversePositions   = reversiGame.GetReversePositions(AIPosition);
                MovePiece(AIPosition);
            }
            if (isMovePieceCompleted && isMyTurn && passedTime > waitTime)
            {
                passedTime = 0;
                curGame.board.CurrentBoardState = BoardState.FreshGame;
                if (!reversiGame.IsGameOver && reversiGame.CurrentPiece == reversiGame.LastPiece)
                {
                    // TODO: 添加无子可下的显示
                }
                isMyTurn             = false;
                isMovingPiece        = false;
                isMovePieceCompleted = true;
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 执行下棋操作. 没有参数, 交给 AI 完成.
 /// </summary>
 private void MovePiece()
 {
     changeWaitingState(WaitingState.WaitingMovePieceConfirmed);
     reversiGame.SetPieceMoveArgs(reversiAI.GetNextpiece(), MovePiece_Confirmed, MovePiece_Completed);
     if (movePieceThread != null && movePieceThread.IsAlive)
     {
         movePieceThread.Abort();
     }
     movePieceThread = new Thread(new ThreadStart(reversiGame.PieceMoves));
     movePieceThread.Start();
 }