示例#1
0
    public void Horizontal(Vector3Int square, Color color)
    {
        int z = square.z;

        for (int x = 0; x < chessBoard.size.x; x++)
        {
            for (int y = 0; y < chessBoard.size.y; y++)
            {
                sqScriptClass = chessBoard.squares[x, y, z].GetComponent <HighlightSquareByRayCasting>();
                theMat        = sqScriptClass.GetComponent <MeshRenderer>().materials;
                if (color == Color.clear)
                {
                    theMat[0].SetColor("_Color", sqScriptClass.baseColor);
                }
                else
                {
                    if (square.x == x && square.y == y)
                    {
                        rookColor = (sqScriptClass.baseColor == Color.white) ? RookPointWhite : RookPointBlack;                         // Point.
                    }
                    else if (square.x == x || square.y == y)
                    {
                        rookColor = (sqScriptClass.baseColor == Color.white) ? RookLineWhite : RookLineBlack;                           // Line.
                    }
                    else
                    {
                        rookColor = (sqScriptClass.baseColor == Color.white) ? RookQuadWhite : RookQuadBlack;                           // Quadrant.
                    }
                    theMat[0].SetColor("_Color", rookColor);
                }
            }
        }
    }
示例#2
0
    private void EraseAdvSqs()     // Called by Update().
    {
        if (doneErasing)
        {
            return;
        }

        dstSquare = nullSquare;

        if (frameDelay == 0)
        {
            frameDelay = 20;
            print("Erasing Rook perimeter = " + perimeter);

            // Unhighlight squares.
            float xPos = (dstSquare.x > srcSquare.x) ? 0.1f : -0.1f;
            float yPos = (dstSquare.y > srcSquare.y) ? 0.1f : -0.1f;

            if (perimeter >= 0)
            {
                for (int i = 0; i < advSq.perimeters[perimeter].Length; i++)
                {
                    Vector3Int sq = advSq.perimeters[perimeter][i];

                    // Skip squares off the board.
                    if (IsOffBoard(sq, chessBoard.size))
                    {
                        continue;
                    }

                    // Unhighlight next square.
                    sqScriptClass = chessBoard.squares[sq.x, sq.y, sq.z].GetComponent <HighlightSquareByRayCasting>();
                    theMat        = sqScriptClass.GetComponent <MeshRenderer>().materials;
                    theMat[0].SetColor("_Color", sqScriptClass.baseColor);
                }

                if (--perimeter < 0)
                {
                    print("Last perimeter");
                    doneErasing = true;
                }
            }
        }
        else
        {
            frameDelay--;
        }
    }
示例#3
0
    public void LeftSlant(Vector3Int square, Color color)
    {
        MaxDist();
        int offTheBoard = 0;

        for (int i = -maxDist; i < maxDist; i++)
        {
            for (int j = -maxDist; j < maxDist; j++)
            {
                int x = square.x + (i + j);                 // works.
                int y = square.y + i;
                int z = square.z + j;

                if (OffTheBoard(x, y, z))                   // TODO: pull offTheBoard once for loop limits more efficient.
                {
                    offTheBoard++;
                    continue;
                }

                theMat        = chessBoard.squares[x, y, z].GetComponent <MeshRenderer>().materials;
                sqScriptClass = chessBoard.squares[x, y, z].GetComponent <HighlightSquareByRayCasting>();
                if (color == Color.clear)
                {
                    theMat[0].SetColor("_Color", sqScriptClass.baseColor);
                }
                else
                {
                    if (square.x == x && square.y == y && square.z == z)
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopPointWhite : BishopPointBlack; // Point.
                    }
                    else if ((z == square.z && (x - square.x) == (y - square.y)) ||                                   // Horizontal.
                             (x == square.x && (z - square.z) == -(y - square.y)) ||                                  // RightVertical.
                             (y == square.y && (x - square.x) == (z - square.z)))                                     // LeftVertical.
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopLineWhite : BishopLineBlack;   // Line.
                    }
                    else
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopQuadWhite : BishopQuadBlack;                           // Quadrant.
                    }
                    theMat[0].SetColor("_Color", bishopColor);
                }
            }
        }

        print("LeftSlant Bishop squares off board = " + offTheBoard + "/" + (2 * maxDist * 2 * maxDist));   // 208-255/256, sigh.
    }
示例#4
0
 public void HighlightSquare(Vector3Int sq, bool line, string point = "")
 {
     sqScriptClass = chessBoard.squares[sq.x, sq.y, sq.z].GetComponent <HighlightSquareByRayCasting>();
     theMat        = sqScriptClass.GetComponent <MeshRenderer>().materials;
     if (point == "Point")
     {
         rookColor = (sqScriptClass.baseColor == Color.white) ? RookPointWhite : RookPointBlack;             // Point.
     }
     else if (line)
     {
         rookColor = (sqScriptClass.baseColor == Color.white) ? RookLineWhite : RookLineBlack;               // Line.
     }
     else
     {
         rookColor = (sqScriptClass.baseColor == Color.white) ? RookQuadWhite : RookQuadBlack;               // Quadrant.
     }
     theMat[0].SetColor("_Color", rookColor);
 }
示例#5
0
    public void RightSlant(Vector3Int square, Color color)
    {
        MaxDist();

        for (int i = -maxDist; i < maxDist; i++)
        {
            for (int j = -maxDist; j < maxDist; j++)
            {
                int x = square.x + i - j;                 // works.
                int y = square.y + i;
                int z = square.z + j;

                if (OffTheBoard(x, y, z))
                {
                    continue;
                }

                theMat        = chessBoard.squares[x, y, z].GetComponent <MeshRenderer>().materials;
                sqScriptClass = chessBoard.squares[x, y, z].GetComponent <HighlightSquareByRayCasting>();
                if (color == Color.clear)
                {
                    theMat[0].SetColor("_Color", sqScriptClass.baseColor);
                }
                else
                {
                    if (square.x == x && square.y == y && square.z == z)
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopPointWhite : BishopPointBlack; // Point.
                    }
                    else if ((z == square.z && (x - square.x) == (y - square.y)) ||                                   // Horizontal.
                             (x == square.x && (z - square.z) == (y - square.y)) ||                                   // RightVertical.
                             (y == square.y && (x - square.x) == -(z - square.z)))                                    // LeftVertical.
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopLineWhite : BishopLineBlack;   // Line.
                    }
                    else
                    {
                        bishopColor = (sqScriptClass.baseColor == Color.white) ? BishopQuadWhite : BishopQuadBlack;                           // Quadrant.
                    }
                    theMat[0].SetColor("_Color", bishopColor);
                }
            }
        }
    }