Ejemplo n.º 1
0
    public void CloseDialog(GameObject dialog, float speed = 0.4f, System.Action onComplete = null, DialogController.CloseDialogType closeDialogType = DialogController.CloseDialogType.ToTop, bool isBlockTouch = true, bool isTouchAnywhereToCloseDialog = false, bool isHightlight = true)
    {
        Vector3 position = pos[1].position;

        switch (closeDialogType)
        {
        case DialogController.CloseDialogType.ToLeft:
            position = pos[0].position;
            break;

        case DialogController.CloseDialogType.ToTop:
            position = pos[1].position;
            break;

        case DialogController.CloseDialogType.ToRight:
            position = pos[2].position;
            break;

        case DialogController.CloseDialogType.ToBottom:
            position = pos[3].position;
            break;
        }

        dialog.GetComponent <UIPanel>().alpha = 1;
        TweenAlpha.Begin(dialog, speed, 0);

        dialog.transform.DOMove(position, speed).SetUpdate(true).OnComplete(() =>
        {
            if (Dialog.listDialogShowing.Count <= 1)
            {
                Dialog.root.SetActive(false);
                Dialog.blockTouch.SetActive(false);
                Dialog.blackPanel.SetActive(false);
            }
            else
            {
                Dialog.listDialogShowing[Dialog.listDialogShowing.Count - 2].GetComponent <UIPanel>().depth = 100;
            }


            if (onComplete != null)
            {
                onComplete();
            }
            Dialog.listDialogShowing.Remove(dialog);
            Destroy(dialog);

            AdController.HideBanner();
        });
    }