FAQ

Answer :

Under TilesEffectManager.cs, in the LightUpTile(int, ChessSquare[]) function, add two of the suggested lines of code

        if (squares.Length > 0)
        {
            foreach (ChessSquare square in squares)
            {
            ...
            }

            tilesChangedColor[currentTargetTileIndex] = originalColor;//Add this line
            ChangeTileColor(currentTargetTileIndex, legalMoveColor);//Add this line
        }
        ...

And also do the same in the LightUpNonCurrentTurnTile(int, ChessSquare[]) function

        if (squares.Length > 0)
        {
            foreach (ChessSquare square in squares)
            {
            ...
            }

            tilesChangedColor[currentTargetTileIndex] = originalColor;//Add this line
            ChangeTileColor(currentTargetTileIndex, illegalMoveColor);//Add this line
        }
        ...

Additionally, for multitouch(Two Player) scene to work the same, under MultiControlTilesEffectManager.cs, in the LightUpTile(int, ChessSquare[]) function

        if (squares.Length > 0)
        {
            foreach (ChessSquare square in squares)
            {
            ...
            }

            tilesChangedColor[currentTargetTileIndex] = Color.green;//Add this line
            ChangeTileColor(currentTargetTileIndex, Color.green);//Add this line
        }
        ...

Subsequently, in LightUpNonCurrentTurnTile(int, ChessSquare[]) function

        if (squares.Length > 0)
        {
            foreach (ChessSquare square in squares)
            {
            ...
            }

            nonCurrentTurnTilesChangedColor[currentTargetTileIndex] = Color.red;//Add this line
            ChangeTileColor(currentTargetTileIndex, Color.red);//Add this line
        }
        ...

2) Highlight associated tiles while king being checked on moves.

Answers :

Under ChessBaseGUI.cs, in OnControllerActionEnded() function, add below lines

        if (IfKingChecked())//Add this line
                ChessEventManager.InvokeIndicateCheckingKingEvent();//Add this line

        return hasControllerActionEnded;

For tiles being highlighted while AI is checking king, under ChessGameAIGUI.cs, in ThreadedSearch(object) function, add few lines

        ...
        
        if (move != null)
        {
            ChessMove m = (ChessMove)move;
            UnityThread.ExecuteInLateUpdate(() =>
            {
                ...
                ExecutePlayerMoveQueue();
                if (IfKingChecked())//Add this line
                {
                    ReturnPieceToOriginalPosition(controller.SelectedPiece);//Add this line
                    ChessEventManager.InvokeIndicateCheckingKingEvent();//Add this line
                }
            });
        }

In order to change what tile color to display on checking king, find the IndicateCheckingKingSquares() function under ChessGameBaseGUI.cs, change the Color.black or Color.red to any preference.

The ChessEventManager.InvokeIndicateCheckingKingEvent() is equivalent to clicking Check King button.

Last updated