Help to solve this slider puzzle coding issue ?

Dear friends,
I have been trying since quite some time on this slider puzzle. I have made 4X4 cubes block with the following script .
I have declared variables as TileWinPos, TileCurPos and GetTilePos…
TileWinPos - declares and initializes the winning position
GetTilePos- to find the gameobject by name
TileCurPos - to store the current position of the Tile

Now i am trying to check if TileCurPos matches with the TileWinPos ,if it is true then load a level.
I tried checking each variable values through debug log,everything seems to be correct, but i am not able to load the level.
The Script is as below…
can anyone tell me why i am not able to load the level here ?

To test this you can follow this tutorial ----> - YouTube
and append the following code.

Note: I am checking only for 7 tiles(cubes) which are shuffled…rest eight tiles are not shuffled.

Thanks in advance

var emptyslot : Transform;
var xtemp;
var ytemp;
var slide:AudioClip;

private var GetTile1Pos : GameObject;
private var GetTile2Pos : GameObject;
private var GetTile3Pos : GameObject;
private var GetTile4Pos : GameObject;
private var GetTile5Pos : GameObject;
private var GetTile6Pos : GameObject;
private var GetTile7Pos : GameObject;



var Tile1WinPos =Vector3(0.0,0.3,0.0);
var Tile2WinPos =Vector3(1.0,3.0,0.0);
var Tile3WinPos =Vector3(2.0,3.0,0.0);
var Tile4WinPos =Vector3(0.0,2.0,0.0);
var Tile5WinPos =Vector3(1.0,2.0,0.0);
var Tile6WinPos =Vector3(2.0,2.0,0.0);
var Tile7WinPos =Vector3(3.0,2.0,0.0);

function Start()
{

GetTile1Pos= GameObject.Find("Tile1");
GetTile2Pos = GameObject.Find("Tile2");
GetTile3Pos = GameObject.Find("Tile3");
GetTile4Pos = GameObject.Find("Tile4");
GetTile5Pos = GameObject.Find("Tile5");
GetTile6Pos = GameObject.Find("Tile6");
GetTile7Pos = GameObject.Find("Tile7");

}

function OnMouseUp()
{

if(Vector3.Distance(transform.position,emptyslot.p osition)==1)
{
xtemp = transform.position.x;
ytemp = transform.position.y;
transform.position.x=emptyslot.position.x;
transform.position.y=emptyslot.position.y;
emptyslot.position.x=xtemp;
emptyslot.position.y=ytemp;

}

}

function Update()
{
var Tile1CurPos = GetTile1Pos.GetComponent(Transform).transform.posi tion;
var Tile2CurPos = GetTile2Pos.GetComponent(Transform).transform.posi tion;
var Tile3CurPos = GetTile3Pos.GetComponent(Transform).transform.posi tion;
var Tile4CurPos = GetTile4Pos.GetComponent(Transform).transform.posi tion;
var Tile5CurPos = GetTile5Pos.GetComponent(Transform).transform.posi tion;
var Tile6CurPos = GetTile6Pos.GetComponent(Transform).transform.posi tion;
var Tile7CurPos = GetTile7Pos.GetComponent(Transform).transform.posi tion;

///////Debug Log//////////////////////
//Debug.Log(Tile1CurPos);
//Debug.Log(Tile2CurPos);
//Debug.Log(Tile3CurPos);
//Debug.Log(Tile4CurPos);
//Debug.Log(Tile5CurPos);
//Debug.Log(Tile6CurPos);
//Debug.Log(Tile7CurPos);

if(Tile1CurPos==Tile1WinPos && Tile2CurPos==Tile2WinPos)
{
if(Tile3CurPos==Tile3WinPos && Tile4CurPos==Tile4WinPos)
{
if(Tile5CurPos==Tile5WinPos && Tile6CurPos==Tile6WinPos )
{
if( Tile7CurPos==Tile7WinPos)
{

Application.LoadLevel(12);
}
}
}

}
}

I’ve not run your code, so this is a guess. It’s normally very bad form to try and compare floating point numbers using equals. The == operator for vectors does check to see whether vectors are almost the same, but it could easily be the case that some of the vectors that you think are equal are not. You can check this by testing each vector pair and use Debug.Log to say whether they are equal or not.

A more reliable way to solve your problem is using arrays. Have an array called puzzlePieces which stores 16 ints. This array will store the index for each tile. So, for example, for your tiles were arranged like this (with 99 meaning the empty square)

  0   1   2   3
  4   5   6   7
  8   9  10  11
 12  13  14  99

then your array would have the numbers 0 through 14 and then 99 in it. You can multiply the row by 4 and add the column to get to a particular element.

Then, to check that the puzzle is solved, you can simply loop through checking that the entry at location q is equal to q and where you don’t bother to check the last location, since it’ll have to be 99 if the others are all correct. You can write a simple function to test that the puzzle is solved.

Next, when you move a puzzle piece, you’re actually updating your puzzlePieces array. You can simply swap the values stored in the array (assuming that the piece is adjacent to the empty slot). You’ll need a way to get from the GameObject you clicked on to the array - I assume you can do that with the name of the game object.

Finally, displaying the puzzle means looping through the array by row and column, and computing the location for the game object.

Read up on model-view-controllers.