Exemple #1
0
 private void PlayExitAnimation(BasePanel panel, BasePanel nextPanel)
 {
     lastPanel = panel;
     if (panel.managedAnimation && nextPanel.managedAnimation)
     {
         if (panel.animationType == AnimationType.None)
         {
             InternalLastAnimationFinished();
         }
         else if (panel.animationType == AnimationType.PushFromSide)
         {
             RectTransform lastRectTrans = panel.GetComponent <RectTransform>();
             Vector2       lastEndPos    = Vector2.zero - new Vector2(panelRoot.sizeDelta.x / 2, 0f);
             lastRectTrans.DOAnchorPos(lastEndPos, animationDuration).SetEase(Ease.OutQuad).OnComplete(InternalLastAnimationFinished).Play();
         }
         else if (panel.animationType == AnimationType.PushFromBottom)
         {
             InternalLastAnimationFinished();
         }
     }
     else
     if (panel.managedAnimation && !nextPanel.managedAnimation)
     {
         if (panel.animationType == AnimationType.None)
         {
             InternalLastAnimationFinished();
         }
         else if (panel.animationType == AnimationType.PushFromSide)
         {
             RectTransform lastRectTrans = panel.GetComponent <RectTransform>();
             Vector2       lastEndPos    = Vector2.zero - new Vector2(panelRoot.sizeDelta.x, 0f);
             lastRectTrans.DOAnchorPos(lastEndPos, animationDuration).SetEase(Ease.OutQuad).OnComplete(InternalLastAnimationFinished).Play();
         }
         else if (panel.animationType == AnimationType.PushFromBottom)
         {
             RectTransform lastRectTrans = panel.GetComponent <RectTransform>();
             Vector2       endpos        = new Vector3(0f, 0f - panelRoot.sizeDelta.y);
             lastRectTrans.DOAnchorPos(endpos, animationDuration).OnComplete(InternalLastAnimationFinished).Play();
         }
     }
     else if (!panel.managedAnimation)
     {
         // wait for exit animation played and deactivate it
         try
         {
             panel.StartExitAnimation();
         }
         catch (Exception e)
         {
             Debug.Log(e.Message);
             Debug.Log(e.StackTrace);
         }
     }
 }
Exemple #2
0
    public virtual BasePanel GetPanelById(Panel_ID panelId)
    {
        BasePanel panel = null;

        for (int i = 0; i < panelList.Count; i++)
        {
            panel = panelList[i];
            if (panel != null)
            {
                if (panel.GetComponent <BasePanel>().panelID == panelId)
                {
                    return(panel);
                }
            }
        }
        return(null);
    }
Exemple #3
0
    //managed animations:
    //

    private void PlayOpenAnimation(BasePanel panel, bool first = false)
    {
        currentPanel = panel;
        if (panel.managedAnimation)
        {
            panel.gameObject.SetActive(true);
            RectTransform rectTrans = panel.GetComponent <RectTransform>();

            Vector2 endpos = Vector2.zero;
            if (!first)
            {
                if (panel.animationType == AnimationType.None)
                {
                    rectTrans.DOAnchorPos(endpos, 0f).OnComplete(InternalCurrentAnimationFinished).Play();
                }
                else if (panel.animationType == AnimationType.PushFromSide)
                {
                    Vector3 startpos = endpos + new Vector2(panelRoot.sizeDelta.x, 0f);
                    rectTrans.DOAnchorPos(endpos, animationDuration).ChangeStartValue(startpos).SetEase(Ease.OutQuad).OnComplete(InternalCurrentAnimationFinished).Play();
                }
                else if (panel.animationType == AnimationType.PushFromBottom)
                {
                    Vector3 startpos = new Vector3(0f, endpos.y - panelRoot.sizeDelta.y);
                    rectTrans.DOAnchorPos(endpos, animationDuration).ChangeStartValue(startpos).OnComplete(InternalCurrentAnimationFinished).Play();
                }
            }
            else
            {
                rectTrans.DOAnchorPos(endpos, 0f).OnComplete(InternalCurrentAnimationFinished).Play();
            }
        }
        else
        {
            try
            {
                panel.StartEnterAnimation();
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
                Debug.Log(e.StackTrace);
            }
        }
    }
Exemple #4
0
    private void PlayCloseAnimation(BasePanel panel)
    {
        lastPanel = panel;

        if (panel.managedAnimation)
        {
            panel.gameObject.SetActive(true);

            RectTransform rectTrans = panel.GetComponent <RectTransform>();
            Vector2       oripos    = Vector2.zero;
            if (panel.animationType == AnimationType.None)
            {
                rectTrans.DOAnchorPos(oripos, 0f).OnComplete(InternalLastAnimationFinished).Play();
            }
            else if (panel.animationType == AnimationType.PushFromSide)
            {
                Vector3 endpos = Vector2.zero + new Vector2(panelRoot.sizeDelta.x, 0f);
                rectTrans.DOAnchorPos(endpos, animationDuration).SetEase(Ease.OutQuad).OnComplete(InternalLastAnimationFinished).Play();
            }
            else if (panel.animationType == AnimationType.PushFromBottom)
            {
                Vector3 endpos = new Vector3(0f, oripos.y - panelRoot.sizeDelta.y);
                rectTrans.DOAnchorPos(endpos, animationDuration).OnComplete(InternalLastAnimationFinished).Play();
            }
        }
        else
        {
            try
            {
                panel.StartExitAnimation();
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
                Debug.Log(e.StackTrace);
            }
        }
    }
Exemple #5
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!isDrag || panelDragCell == null)
        {
            return;
        }
        // Ray Cast UI Panels
        PointerEventData pointerData = new PointerEventData(EventSystem.current);

        pointerData.position = Input.mousePosition;
        List <RaycastResult> results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(pointerData, results);
        // Get Drop Body
        foreach (RaycastResult result in results)
        {
            if (result.gameObject.tag == "DropBody")
            {
                // Set Drag And Drop Params
                dragAndDropParam.dragToPanel   = result.gameObject.transform.parent.GetComponent <BasePanel>();
                dragAndDropParam.dragFromPanel = rootPanel.GetComponent <BasePanel>();
                dragAndDropParam.dragCell      = baseCell;
                break;
            }
        }
        foreach (RaycastResult rayResult in results)
        {
            if (rayResult.gameObject.GetComponent <BaseCellPanel>() != null)
            {
                dragAndDropParam.dropCell = rayResult.gameObject.GetComponent <BaseCellPanel>().baseCell;
                break;
            }
        }
        DragAndDrop?.Invoke(dragAndDropParam);
        dragAndDropParam.Clear();
        Destroy(panelDragCell);
    }