Example #1
0
    public void ClickToSwap(int x, int y)
    {
        int dx = GetDx(x, y);
        int dy = GetDy(x, y);

        NumberBox currentBox = grid[x, y];
        NumberBox nextBox    = grid[x + dx, y + dy];

        grid[x, y]           = nextBox;
        grid[x + dx, y + dy] = currentBox;

        currentBox.UpdatePos(x + dx, y + dy);
        currentBox.StartMovingAnimation(GetIconCenterByCell(new CCell(x, y)), GetIconCenterByCell(new CCell(x + dx, y + dy)));

        nextBox.UpdatePos(x, y);
        nextBox.transform.position = GetIconCenterByCell(new CCell(x, y));
    }