Exemplo n.º 1
0
    /// <summary>
    /// 聚焦到引导目标
    /// TODO 这个地方需要增加对场景3D物体的特定点击回调操作
    /// </summary>
    /// <param name="operateImage">目标点击区域Button Image</param>
    /// <param name="callBack"></param>
    public void ChangeTarget(Image operateImage, Action callBack = null)
    {
        _ev.SetTargetImage(null);

        if (operateImage == null)
        {
            _parentBG.enabled = false;
            _hand.enabled     = false;

            _isFocusing    = false;
            _currentRadius = 0;
            _radius        = 0f;
            ResetGuide();
            return;
        }
        else
        {
            _parentBG.enabled = true;
        }

        _isFocusing = true;
        _target     = operateImage;

        UIMaskManager.Instance.SetMaskEnable(UITransparentEnum.NoPenetratingMiddle);
        InputControlManager.Instance.IsEnable = false;

        //获取高亮区域的四个顶点的世界坐标
        _target.rectTransform.GetWorldCorners(_corners);

        _guideDataModel.GuideDoneEvent = callBack;
        //如果目标位置是一个UI Button
        //任何按钮点击应该都是进行完成并关闭当前引导或加载下一步引导
        _targetBtn = operateImage.GetComponent <Button>();
        if (_targetBtn != null)
        {
            _targetBtn.onClick.AddListener(OnClickTargetButtonGuideDone);
        }

        //计算高亮显示区域的圆心
        float   x           = _corners[0].x + ((_corners[3].x - _corners[0].x) / 2f);
        float   y           = _corners[0].y + ((_corners[1].y - _corners[0].y) / 2f);
        Vector3 centerWorld = new Vector3(x, y, 0);
        Vector2 center      = LitTool.ScreenToCanvasPos(_rootCanv, centerWorld, _uiCam);

        //设置遮罩材料中的变量
        Vector4 centerMat   = new Vector4(center.x, center.y, 0, 0);
        Vector4 widthHeight = new Vector4(_target.rectTransform.rect.width, _target.rectTransform.rect.height, 0, 0);

        _material.SetVector("_Center", centerMat);
        _material.SetVector("_WH", widthHeight);

        //计算当前高亮显示区域的半径
        RectTransform canRectTransform = _rootCanv.transform as RectTransform;

        if (SType == LitShaderType.Circle)
        {
            //计算最终高亮显示区域的半径
            _radius = Vector2.Distance(LitTool.ScreenToCanvasPos(_rootCanv, _corners[0], _uiCam),
                                       LitTool.ScreenToCanvasPos(_rootCanv, _corners[2], _uiCam)) / 2f;
            if (canRectTransform != null)
            {
                //获取画布区域的四个顶点
                canRectTransform.GetWorldCorners(_corners);
                //将画布顶点距离高亮区域中心最远的距离作为当前高亮区域半径的初始值
                foreach (Vector3 corner in _corners)
                {
                    _currentRadius = Mathf.Max(Vector3.Distance(LitTool.ScreenToCanvasPos(_rootCanv, corner, _uiCam), center),
                                               _currentRadius);
                }
            }
        }
        else if (SType == LitShaderType.Rect)
        {
            //计算最终高亮显示区域的半径
            _radius        = 1f;
            _currentRadius = 10f;
        }
        _material.SetFloat("_Slider", _currentRadius);
        if (FrameworkConfig.Instance.UseHotFixMode)
        {
            LitFramework.HotFix.UIManager.Instance.MaskImage.transform.SetAsLastSibling();
        }
        else
        {
            LitFramework.Mono.UIManager.Instance.MaskImage.transform.SetAsLastSibling();
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 指定两张牌移动到两者之间的位置,放大,最后移动到屏幕游戏右下角,缩小
    /// </summary>
    /// <param name="baseCard1">Base card1.</param>
    /// <param name="baseCard2">Base card2.</param>
    private void EffectMoveToMiddlePoint(BaseCard baseCard1, BaseCard baseCard2, Action action = null)
    {
        Debug.Log("移动到两点间的位置");
        float moveTime       = _cardConfig.CardMoveNormalTime;
        float middleMoveTime = _cardConfig.CardMoveToMiddleTime;

        Sequence sq;

        if (action == null)
        {
            sq = _cardMiddleSequence;
            if (sq != null)
            {
                sq.Complete();
                sq.Kill();
                sq = null;
            }
        }

        sq = DOTween.Sequence();
        sq.PrependCallback(() => { _canPlayBack = false; /*InputControlManager.Instance.IsEnable = false;*/ });

        GameObject obj1 = baseCard1.cardObj;
        GameObject obj2 = baseCard2.cardObj;

        Vector3 pos1           = obj1.transform.position;
        Vector3 pos2           = obj2.transform.position;
        Vector3 targetPosLeft  = (pos1 + pos2) * 0.5f + Vector3.left * CARDS_HALFWIDTH;
        Vector3 targetPosRight = (pos1 + pos2) * 0.5f + Vector3.right * CARDS_HALFWIDTH;

        TweenCallback getMiddleFunc = () =>
        {
            _smog.transform.position = (targetPosLeft + targetPosRight) * 0.5f;
            _smog.SetActive(true);
            LitTool.DelayPlayFunction(1f, () =>
            {
                _smog.transform.position = Vector3.one * 999;
                _smog.SetActive(false);
            });
        };

        //移动到中心点
        if (pos1.x <= pos2.x)
        {
            baseCard1.sprite.sortingOrder = 10000 - 1;
            baseCard2.sprite.sortingOrder = 10000 + 1;

            sq.Join(obj1.transform.DOMove(targetPosLeft + Vector3.left * _cardConfig.CardMoveOutRange, _cardConfig.CardMoveOutTime).SetEase(Ease.OutQuint));
            sq.Join(obj2.transform.DOMove(targetPosRight + Vector3.right * _cardConfig.CardMoveOutRange, _cardConfig.CardMoveOutTime).SetEase(Ease.OutQuint));

            sq.AppendInterval(_cardConfig.CardMoveOutTime);

            sq.Join(obj1.transform.DOMove(targetPosLeft, middleMoveTime).SetEase(_cardConfig.EaseType));
            sq.Join(obj2.transform.DOMove(targetPosRight, middleMoveTime).SetEase(_cardConfig.EaseType).OnComplete(getMiddleFunc));          //reache call Back
        }
        else
        {
            baseCard1.sprite.sortingOrder = 10000 + 1;
            baseCard2.sprite.sortingOrder = 10000 - 1;

            sq.Join(obj1.transform.DOMove(targetPosRight + Vector3.right * _cardConfig.CardMoveOutRange, _cardConfig.CardMoveOutTime).SetEase(Ease.OutQuint));
            sq.Join(obj2.transform.DOMove(targetPosLeft + Vector3.left * _cardConfig.CardMoveOutRange, _cardConfig.CardMoveOutTime).SetEase(Ease.OutQuint));

            sq.AppendInterval(_cardConfig.CardMoveOutTime);

            sq.Join(obj1.transform.DOMove(targetPosRight, middleMoveTime).SetEase(_cardConfig.EaseType));
            sq.Join(obj2.transform.DOMove(targetPosLeft, middleMoveTime).SetEase(_cardConfig.EaseType).OnComplete(getMiddleFunc));           //reache call Back
        }
        //_cardMiddleSequence.Join( obj1.transform.DOScale( Vector3.one * 1.1f, middleMoveTime * 0.5f ).SetEase( Ease.Linear ) );
        //_cardMiddleSequence.Join( obj2.transform.DOScale( Vector3.one * 1.1f, middleMoveTime * 0.5f ).SetEase( Ease.Linear ) );

        //中心点等待
        sq.AppendInterval(_cardConfig.MiddleStayTime);

        sq.Join(baseCard2.sprite.material.DOFade(0f, moveTime));
        sq.Join(baseCard1.sprite.material.DOFade(0f, moveTime));

        sq.Join(obj1.transform.DOScale(Vector3.one * 0.5f, moveTime).SetEase(Ease.Linear));
        sq.Join(obj2.transform.DOScale(Vector3.one * 0.5f, moveTime).SetEase(Ease.Linear));

        //结束
        sq.AppendCallback(() => { _canPlayBack = true; CheckCameraPos(); if (action != null)
                                  {
                                      action();
                                  }
                                  sq.Kill(); /*baseCard1.cardObj.SetActive( false ); baseCard2.cardObj.SetActive( false );*/ });
    }