I have a script wich shuffels tiles on the field. That means It rotates tiles by an array of angles, rotate enums to that corresponding angles. The next step is reposition. After that i want to call another function.
Currently i have this and basicly it works, but the last called function is called to early. How can i put this all together to work properly?
void Update ()
{
if (shuffeling)
{
chooseRandomRotation ();
chooseRandomLocation ();
GMS.InitColorCheck ();
}
}
void chooseRandomRotation()
{
int num = Random.Range(0,degreesToRotate.Length);
float rot = degreesToRotate[num];
for (int i = 0; i < allCards.Length;i++)
{
allCards*.transform.rotation = Quaternion.Euler(0,rot,0);*
-
//now rotate all enums according to the direction*
_ CC = allCards*.GetComponent();_
_ //RotateEnums for num amount*_
* for (int j = 0; j < num; j++) {*
* //Update the colors*
* CC.temp = CC.Top;//save top in temp*
* CC.Top = CC.Left;// set top to left*
* CC.Left = CC.Bottom;//set left to bottom*
* CC.Bottom = CC.Right;*
* CC.Right = CC.temp;//set top to the saved topleft(temp)*
* //Update Forms*
* CC.formTemp = CC.formTop;//save top in temp*
* CC.formTop = CC.formLeft;// set top to left*
* CC.formLeft = CC.formBottom;//set left to bottom*
* CC.formBottom = CC.formRight;*
* CC.formRight = CC.formTemp;//set top to the saved topleft(temp)*
* }*
* }*
* shuffeling = false;*
* }*
* void chooseRandomLocation()*
* {*
* while(Fields.Count > 0)*
* {*
* for(int k = 0; k < allCards.Length;k++)*
* {*
* int l = Random.Range(0,Fields.Count);*
* Transform newloc = Fields[l];*
* allCards[k].transform.position = new Vector3(newloc.transform.position.x,newloc.transform.position.y,newloc.transform.position.z);*
* allCards[k].GetComponent().oldPosition = newloc.transform.position;// set the shuffeled position as the old position*
* Fields.RemoveAt(l);*
* }*
* }*
* }*
}
I hope you understand my problem and have an idea how i could fix it. Thanks in advance.