示例#1
0
 void OnMouseUp()
 {
     beingDragged = false;                                    // stop dragging
     SlidingPuzzleExample.mainGrid.AlignTransform(transform); // snap into position precisely
     transform.position = ClampPosition(transform.position);  // clamp the position to be safe (because of possible rounding errors above)
     lastSnap           = transform.position;                 //this is out last save position
     SlidingPuzzleExample.RegisterObstacle(transform, false); // mark the space as occupied again
 }
示例#2
0
 void OnMouseDown()
 {
     beingDragged = true;                                                                                  // Start dragging.
     touchOffset  = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;              //offset between the cursor and the block centre
     lastSnap     = transform.position;                                                                    // this is obviously where we snapped the last time
     bounds       = SlidingPuzzleExample.CalculateSlidingBounds(transform.position, transform.lossyScale); // create default bounds
     SlidingPuzzleExample.RegisterObstacle(transform, true);                                               // marks this space as free in the matrix (or else we won't be able to return back here)
 }
示例#3
0
 void Start()
 {
     beingDragged = false;                                    // When the game starts no blocks are being dragged.
     SlidingPuzzleExample.RegisterObstacle(transform, false); // Register this block in the matrix as occupied space.
 }
示例#4
0
    private Vector3[] bounds;     // we can only move the block within these bounds (the grid itself is the largest possible bound)

    void Start()
    {
        beingDragged = false;
        SlidingPuzzleExample.RegisterObstacle(transform, false);         //register this block in the matrix as occupied space
    }