GridItems InstantiateCandy(int x, int y) { GameObject randomCandy = Candies[Random.Range(0, Candies.Length)]; GridItems newCandy = ((GameObject)Instantiate(randomCandy, new Vector2(x * CandiesWidth, y), Quaternion.identity)).GetComponent <GridItems>(); newCandy.OnItemPositionChanged(x, y); return(newCandy); }
void SwapIndeces(GridItems a, GridItems b) { GridItems tempA = items[a.x, a.y]; items[a.x, a.y] = items[b.x, b.y]; items[b.x, b.y] = tempA; int bOldX = b.x; int bOldY = b.y; b.OnItemPositionChanged(a.x, a.y); a.OnItemPositionChanged(bOldX, bOldY); }