Exemplo n.º 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
 }
Exemplo n.º 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)
 }
Exemplo n.º 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.
 }
Exemplo n.º 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
    }