コード例 #1
0
    GridItems instantiate_items(int x, int y)
    {
        GameObject random_items = itemPrefabs[Random.Range(0, 5)];
        GridItems  newItem      = ((GameObject)Instantiate(random_items,
                                                           new Vector2(x * items_width, y), Quaternion.identity)).GetComponent <GridItems>();

        newItem.OnItemPostionChanged(x, y);
        return(newItem);
    }
コード例 #2
0
    void swapIndices(GridItems gridA, GridItems gridB)
    {
        GridItems tempA = gridItems[gridA.x, gridA.y];

        gridItems[gridA.x, gridA.y] = gridB;
        gridItems[gridB.x, gridB.y] = tempA;
        int boldx = gridB.x;
        int boldy = gridB.y;

        gridB.OnItemPostionChanged(gridA.x, gridA.y);
        gridA.OnItemPostionChanged(boldx, boldy);
    }