Ejemplo n.º 1
0
    public void AnimateTileSlide(Tile slidingTile, Tile destinationTile, bool isMerge)
    {
        LeanTween.cancel(slidingTile.tileObject, true);

        Vector3 originalPosition = slidingTile.tileObject.transform.position;

        LeanTween.move(slidingTile.tileObject, destinationTile.transform.position, Time).setOnComplete(ApplyTileStylesAndResetPosition);

        void ApplyTileStylesAndResetPosition()
        {
            slidingTile.ApplyTileStyle();
            destinationTile.ApplyTileStyle();
            slidingTile.tileObject.transform.position = originalPosition;

            tilesManager.CheckIfTileSpawnedThisTurn();

            if (isMerge)
            {
                destinationTile.Merged();
            }
        }
    }