Exemplo n.º 1
0
    private void OnPieceTouch(Piece currentPiece, string id)
    {
        //Debug.Log("PositionOnBoard: " + currentPiece.tile.posOnBoard);

        MeshRenderer mrCurrent = currentPiece.GetComponent<MeshRenderer>();
        string selectedPieceColor = mrCurrent.material.color.ToHexStringRGB();

        Debug.Log("currentPiece-> color: " + currentPiece.color + " size: " + currentPiece.size + " symbol: " + currentPiece.symbol);
        if(selectedPiece != null)
        {
            if(currentPiece.MeetsPreconditions(selectedPiece)){
                //Debug.Log("MeetsPreconditions...");
                if(IsValidMove(currentPiece)){
                    /***if level = hard ****
                    MakeMovement(selectedPiece, currentPiece.tile);
                    MeshRenderer mr = selectedPiece.GetComponent<MeshRenderer>();
                    mr.material = currentMaterial;
                    */

                    //if level = easy
                    MakeMovementPath(currentPiece.tile);

                }
            }
        }
        else
        {
            if(selectedPieceColor.Equals(activeBoardColor)){

                if(currentPiece.MeetsPreconditions(selectedPiece))
                {
                    selectedPiece = currentPiece;
                    initialPieceTile = currentPiece.tile;
                    initialPiece = currentPiece;

                    /* Set piece transparency*/
                    selectedPiece.SetSelectionTransparency();
                    MeshRenderer mr = selectedPiece.GetComponent<MeshRenderer>();
                    currentMaterial = mr.material;

                    /* Set selected color to piece*/
                    /*MeshRenderer mr = selectedPiece.GetComponent<MeshRenderer>();
                    currentMaterial = mr.material;
                    mr.material = Resources.Load("Material/OriginalTheme/selected") as Material;*/
                }
            }
        }
    }