Example #1
0
    void Init()
    {
        if (isInit == false)
        {
            ItemMoveScript moveScrpit = m_drag.GetComponent <ItemMoveScript>();
            if (moveScrpit == null)
            {
                moveScrpit = m_drag.gameObject.AddComponent <ItemMoveScript>();
            }

            deckImageHight = (int)(m_deckItem.GetComponent <RectTransform>().sizeDelta.y);
            cutImageHight  = (int)(m_drag.GetComponent <RectTransform>().sizeDelta.y);
            Debug.LogFormat("deckImageHight:{0} cutImageHight:{1}", deckImageHight, cutImageHight);
            m_dragRect = m_drag.GetComponent <RectTransform>();
            //m_drag.upLimit = (deckImageHight - cutImageHight) / 2 * -1;
            //m_drag.downLimit = m_drag.upLimit + (DeckNum - 2) * deckHight * -1;
            m_drag.upLimit   = Spacing * -1;
            m_drag.downLimit = Spacing * (DeckNum - 1) * -1;
            if (m_content.GetComponent <ScaleChangeScript>() == null)
            {
                m_content.gameObject.AddComponent <ScaleChangeScript>();
            }
            if (m_content.GetComponent <ItemMoveScript>() == null)
            {
                m_content.gameObject.AddComponent <ItemMoveScript>();
            }
            if (m_content.GetComponent <RotationChangeScript>() == null)
            {
                m_content.gameObject.AddComponent <RotationChangeScript>();
            }
            isInit = true;
        }
    }
Example #2
0
    /// <summary>
    /// 进入飞入桌面环节
    /// </summary>
    void MoveToDesk1()
    {
        //print("666666666666666666666");
        // 进入飞入桌面环节
        ScaleChangeScript scaleScript = m_content.GetComponent <ScaleChangeScript>();

        if (scaleScript == null)
        {
            scaleScript = m_content.gameObject.AddComponent <ScaleChangeScript>();
        }
        float scaleEnd = 0.12f;
        float time     = ReturnDeskTime;

        scaleScript.StartScale(scaleEnd, time, null);
        ItemMoveScript moveScript = m_content.GetComponent <ItemMoveScript>();

        if (moveScript == null)
        {
            moveScript = m_content.gameObject.AddComponent <ItemMoveScript>();
        }
        RectTransform rectContent = m_content.GetComponent <RectTransform>();
        float         speed       = (deskPoint - rectContent.anchoredPosition).magnitude / ReturnDeskTime;
        Vector2       endPoint    = deskPoint;

        // 所有牌块向指定坐标点移动,移动的过程中逐渐缩小,当到达坐标点的时候,事件通知
        moveScript.StartMove(endPoint, speed, OnMoveToDeskEnd1);

        RotationChangeScript rotationScript = m_content.GetComponent <RotationChangeScript>();

        rotationScript.StartRotation(new Vector3(-50, 80, -40), time, null);
    }
Example #3
0
    /// <summary>
    /// 向下移动
    /// </summary>
    void StartDownMove1()
    {
        // 向下方移动,距离为未移动牌的厚度,移动完成事件通知
        float          distance   = DeckNum * deckHight;
        float          speed      = distance / (SwitchTime / 3);
        Vector2        endPoint   = new Vector2(m_dragRect.anchoredPosition.x, m_dragRect.anchoredPosition.y - distance);
        ItemMoveScript moveScript = m_drag.GetComponent <ItemMoveScript>();

        if (moveScript == null)
        {
            Debug.LogError("m_drag未挂ItemMoveScript脚本");
            return;
        }
        moveScript.StartMove(endPoint, speed, OnMoveToDownEnd1);
    }
Example #4
0
    /// <summary>
    /// 向左移动
    /// </summary>
    void StartLeftMove1()
    {
        // 调整m_drag的层级
        m_drag.transform.SetAsFirstSibling();
        // 向左方水平移动,让牌块恢复为一整块状态,移动完成事件通知
        float speed = (SwitchPointX - DeckPointX) / (SwitchTime / 3);
        //print("speed = " + speed);
        Vector2        endPoint   = new Vector2(DeckPointX, m_dragRect.anchoredPosition.y);
        ItemMoveScript moveScript = m_drag.GetComponent <ItemMoveScript>();

        if (moveScript == null)
        {
            Debug.LogError("m_drag未挂ItemMoveScript脚本");
            return;
        }
        moveScript.StartMove(endPoint, speed, OnMoveToLeftEnd1);
    }
Example #5
0
    /// <summary>
    /// 交换环节处理
    /// </summary>
    void SwitchPosition1()
    {
        // 包括牌靴在内,上部的牌,向右方移动,移动完成事件通知
        for (int i = m_index; i >= 0; i--)
        {
            m_Decks[i].SetParent(m_drag.transform, true);
        }
        float speed = (SwitchPointX - DeckPointX) / (SwitchTime / 3);
        //print("speed = " + speed);
        Vector2        endPoint   = new Vector2(SwitchPointX, m_dragRect.anchoredPosition.y);
        ItemMoveScript moveScript = m_drag.GetComponent <ItemMoveScript>();

        if (moveScript == null)
        {
            Debug.LogError("m_drag未挂ItemMoveScript脚本");
            return;
        }
        moveScript.StartMove(endPoint, speed, OnMoveToRightEnd1);
    }
Example #6
0
    /// <summary>
    /// 自动切牌
    /// </summary>
    /// <param name="index"></param>
    public void AutoCutIn(int index)
    {
        m_drag.CloseDrag();
        // 调整cut到合适的起始点y方向
        m_index = index;
        //m_dragRect.anchoredPosition = new Vector2(m_dragRect.anchoredPosition.x, m_drag.upLimit + deckHight * m_index * -1);
        m_dragRect.anchoredPosition = new Vector2(m_dragRect.anchoredPosition.x, m_drag.upLimit + Spacing * m_index * -1);
        // 调整cut的层级到合适的位置
        m_drag.transform.SetSiblingIndex(DeckNum - 1 - m_index);
        // 计算出移动的速度
        float   speed    = (CutPointX - DeckPointX) / CutInTime;
        Vector2 endPoint = new Vector2(DeckPointX, m_dragRect.anchoredPosition.y);
        // 执行移动动画,动画完成会事件通知
        ItemMoveScript moveScript = m_drag.GetComponent <ItemMoveScript>();

        if (moveScript == null)
        {
            moveScript = m_drag.gameObject.AddComponent <ItemMoveScript>();
        }
        moveScript.StartMove(endPoint, speed, OnCutIn1);
    }