Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     UpdateHighlight();
     if (board.initialized)
     {
         for (int i = 0; i < 25; i++)
         {
             if (board.getPieceInSector(i) != null)
             {
                 board.getPieceInSector(i).UpdateCircle();
             }
         }
     }
     if (board.gameEnded || (section != -1 && board.getPieceInSector(section) != null))
     {
         if (board.gameEnded)
         {
             chessOverlay.ShowEndOverlay(board.playerWon);
         }
         else
         {
             if (!chessOverlay.isActive)
             {
                 chessOverlay.ShowChessOverlay(board.getPieceInSector(section).Name);
             }
             else if (!chessOverlay.showing.Equals(board.getPieceInSector(section).Name))
             {
                 chessOverlay.HideChessOverlay();
                 chessOverlay.ShowChessOverlay(board.getPieceInSector(section).Name);
             }
         }
     }
     else
     {
         chessOverlay.HideChessOverlay();
     }
     chessOverlay.UpdateTurn(board.currentTurn);
     if (board.currentTurn != this.Player_Turn)
     {
         highlightAllMoves.HideHighlights();
     }
     else if (board.waitingForPush)
     {
         highlightAllMoves.HideHighlights();
         bool[] possiblePush = new bool[25];
         for (int i = 0; i < 25; i++)
         {
             possiblePush[i] = (BoardManager.AreAdiacent(i, board.pushed.CurrentSector) &&
                                board.getPieceInSector(i) == null);
         }
         highlightAllMoves.HighlightAllowedMoves(possiblePush);
     }
     if (Input.GetKeyUp(KeyCode.Escape))
     {
         Application.Quit();
     }
     if (Input.GetMouseButtonUp(0))
     {
         if (section != -1 && board.currentTurn == this.Player_Turn)
         {
             if (selectedChessPiece == null)
             {
                 //push chesspiece
                 if (board.waitingForPush)
                 {
                     PushChessPiece(section);
                 }
                 //select chesspiece
                 else
                 {
                     SelectChessPiece(section);
                 }
             }
             else if (board.getPieceInSector(section) == null)
             {
                 //move chesspiece
                 MoveChessPiece(section);
             }
             else if (board.getPieceInSector(section).Owner == this.Player_Turn)
             {
                 SelectChessPiece(section);
             }
             else
             {
                 AttackChessPiece(section);
             }
         }
         else
         {
             selectedChessPiece = null;
             highlightAllMoves.HideHighlights();
         }
     }
 }