コード例 #1
0
    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);
    }
コード例 #2
0
    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);
    }