Exemplo n.º 1
0
    private bool IsFront(PieceObject hit)
    {
        if (hit == null)
            return false;
        else if(hit.GetPieceType() != Piece.PieceType.Mirror)
            return true;
        else {
            var flipped = hit.GetComponent<Mirror>().IsFlipped();

            var front = false;
            var facing = this.lazerIn.GetFacing();

            if(facing.y != 0){
                front = facing.y > 0;
            } else {
                front = facing.x > 0;
                front = flipped ? !front : front;
            }
            return front;
        }
    }
Exemplo n.º 2
0
    int isEnemyKing(

        /*
         *  0: Empty, continue;
         *  1: Friendly, stop;
         *  2: Enemy King;
         *  3: Enemy Piece; (Other)
         */
        int row, int col, int[,] boardArray)
    {
        int piece = boardArray[row, col];

        if (piece == 0) // Empty
        {
            return(0);
        }

        GameObject PieceObject;
        string     type;

        WHITE_ID.TryGetValue(piece, out PieceObject);
        if (PieceObject == null) // BLACK PIECE
        {
            if (turn == "black") // Friendly Object, must stop
            {
                return(1);
            }
            type = BLACK_ID[piece].GetComponent <pieceCode>().type;
        }
        else
        {
            pieceCode code = PieceObject.GetComponent <pieceCode>();
            int[]     localCords;
            if (turn == "black") // transform black cords to white because code's cords is in white
            {
                localCords = this.BlackToWhite(row, col);
            }
            else
            {
                localCords = new int[2] {
                    row, col
                }
            };

            Debug.Log($"Piece Info: ({code.row}, {code.col})");

            if (code.row == localCords[0] && code.col == localCords[0])   // WHITE PIECE
            {
                Debug.Log("White piece found");
                if (turn == "white")
                {
                    return(1); // Stop Because Friendly piece
                }
                type = code.type;
            }
            else   // BLACK PIECE
            {
                Debug.Log("Black Piece Found");
                if (turn == "black")
                {
                    return(1); // stop
                }
                type = BLACK_ID[piece].GetComponent <pieceCode>().type;
            }
        }


        if (type == "king")
        {
            Debug.Log("KING FOUND");
            return(2);
        }
        Debug.Log($"ENEMY FOUND {type}");
        return(3);
    }