예제 #1
0
    //Handles what happens when a piece is dropped into the puzzle
    void HandlePuzzleDrop(Vector3 pointDrop)
    {
        //get the cell col and row positions
        Vector2 cell = puzzle.GetCellFromPoint(pointDrop);

        //Check the cell is not taken
        if (!puzzle.IsTaken(cell))
        {
            //Position the piece at the center of the cell
            Vector3 newPos = puzzle.GetCellPosition(cell);


            //Position piece on that point
            transform.position = newPos;

            //Make them face to opposite to the panels forward (Fixes the rotation of the object so they lie flat on the panel)
            transform.forward = puzzle.transform.forward;

            //update cell information
            isPlaced    = true;
            currentCell = cell;



            //Check puzzle completion
            puzzle.CheckCompletion();
        }

        //If cell is taken send the piece back to its original position
        else
        {
            SendToSpawnPos();
        }
    }