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 }
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) }
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. }
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 }