Hello everyone!
I have read dozens of discussions about compare two array, but now my brain is tilt!!
I am creating a series of basic scripts for my OGM level. In this case there is a enigma based on the game of fifteen. I managed to move and mix gameobject cubes and now I have to create a solved game.
To decide when the game is over or resolved, I thought of taking the initial position of each individual cube with a Vector3 array…
void Start()
{
go = GameObject.FindGameObjectsWithTag("TileCube");
foreach (GameObject obj in go)
{
goPos = obj.transform.position;
}
oldGopos = new Vector3[] { goPos };
}
Also when mixing the cubes, I take their position with a vector3 array. To determine the random of the cubes I use two pseudo IDs; the first public int id;
it’s used for every single cube (from 1 to 15).
The second pseudo id’s private int[] compareNumbID = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
it’s a array int used for base random.
void RamdomPosCube()
{
for (int i = 0; i < compareNumbID.Length; i++)
{
int temp = compareNumbID[i];
int IDIndex = Random.Range(0, compareNumbID.Length);
compareNumbID[i] = compareNumbID[IDIndex];
compareNumbID[IDIndex] = temp;
if (id == temp)
{
xtemp = transform.localPosition.x;
ytemp = transform.localPosition.y;
transform.localPosition = new Vector3(slot.transform.position.x, slot.transform.position.y, 0);
slot.transform.position = new Vector3(xtemp, ytemp, 0);
}
}
newGoPos = new Vector3[] { transform.localPosition };
}
With void OnMouseUp()
I move the cubes to solve the game.
Is’t fair how I am proceeding? Now, what I just can’t come up with is how to compare this two arrays. I have tried almost all possible solutions but without success.
Is another solution possible?
Any ideas?
Thanks for any help