Puzzle Box Level Complete - Help Needed!

I am developing a small puzzle game where the user needs to create the image on a 4x4 puzzle box within a time limit. I have so far coded it so once the timer hits 0 the game over screen will appear but I need a way to ccomplete the level once the image is created.

I will use screenshots to show you what I have.

Current Game Screen when run: Screenshot - e9f86b98c523f449238660255b4c7eb2 - Gyazo

I have 16 tiles to hold all 15 images, 1 is left blank to allow for movement. Screenshot - e5db02d98da940cd7d1b0a5a23b97552 - Gyazo

Can anyone help me code a win sequence once the tiles reach the correct layout as shown in the 2nd print screen. I will be very gratefull as this is due in in a few weeks.

I suggest having a “correct” tile position for each of the 15 images. Simply check if they are all in the right place. Check every time a block moves instead of every frame to be more efficient.

Given how you are handling your movement, I’d create a script that is attached to each tile object. In that script I’d store the winning position for that tile. If you know the positions where you are going to place the tiles, you can just specify the position in the inspector. Or you can specify a Transform variable and drag and drop the tile objects onto the variables (you’ll need an empty game object in the open slot). So if a tile is current at (2,1) and its winning position is (0,2), then you drag the game object at (0,2) onto the transform variable. Then you can have a method to check if the Tile is at is home position. Something like (untested):

public var transHome : Transform;
private var v3HomePos : Vector3;

function Start () {
	v3HomePos = transHome.position;
}

function IsHome() {
	return (transform.position - v3HomePos).magnitude < 0.01; 
}

Say this was the “Tile” component. If you had a script at the root object of all the tiles you could do something like:

private var tiles : Component[];

function Start () {
	tiles = GetComponentsInChildren (Tile);
}

function HasWon() :  boolean {
	for (var tile : Tile in tiles) {
      if (!tile.IsHome())
      	return false;
     }
     return true;
}