예제 #1
0
    void tweenShowHide(bool isShow, float t)
    {
        if (m_wndObj == null)
        {
            return;
        }

        if (m_wInfo.fade == WndFadeMode.Alpha || m_wInfo.fade == WndFadeMode.ScaleAlpha)//补间alpha
        {
            if (isShow)
            {
                m_wndObj.GetComponent <UIWidget>().alpha = DP_TweenFuncs.Tween_Linear_Float(0, 1, t);
            }
            else
            {
                m_wndObj.GetComponent <UIWidget>().alpha = DP_TweenFuncs.Tween_Linear_Float(m_TweenStartAlpha, 0, t);
            }
        }

        if (m_wInfo.fade == WndFadeMode.Scale || m_wInfo.fade == WndFadeMode.ScaleAlpha)//补间缩放
        {
            if (isShow)
            {
                var s = WndConfig.Single.WndScaleEnterCurve.Evaluate(t);
                m_wndObj.transform.localScale = new Vector3(s, s, s);
            }
            else
            {
                var x = DP_TweenFuncs.Tween_Linear_Float(m_TweenStartScale.x, 0, t);
                var y = DP_TweenFuncs.Tween_Linear_Float(m_TweenStartScale.y, 0, t);
                var z = DP_TweenFuncs.Tween_Linear_Float(m_TweenStartScale.z, 0, t);
                m_wndObj.transform.localScale = new Vector3(x, y, z);
            }
        }

        if (m_wInfo.animaMode != WndAnimationMode.situ)
        {
            Vector3  startPos = Vector3.zero;
            UIWidget widget   = m_wndObj.GetComponent <UIWidget>();
            //处理出场模式
            switch (m_wInfo.animaMode)
            {
            case WndAnimationMode.down:
            {
                startPos.y = widget.height;
            }
            break;

            case WndAnimationMode.up:
            {
                startPos.y = -widget.height;
            }
            break;

            case WndAnimationMode.left:
            {
                startPos.x = -widget.width;
            }
            break;

            case WndAnimationMode.right:
            {
                startPos.x = widget.width;
            }
            break;
            }

            if (isShow)
            {
                m_wndObj.transform.localPosition = new Vector3(
                    DP_TweenFuncs.Tween_Linear_Float(startPos.x, 0, t),
                    DP_TweenFuncs.Tween_Linear_Float(startPos.y, 0, t),
                    DP_TweenFuncs.Tween_Linear_Float(startPos.z, 0, t)
                    );
            }
            else
            {
                m_wndObj.transform.localPosition = new Vector3(
                    DP_TweenFuncs.Tween_Linear_Float(m_TweenStartPos.x, startPos.x, t),
                    DP_TweenFuncs.Tween_Linear_Float(m_TweenStartPos.y, startPos.y, t),
                    DP_TweenFuncs.Tween_Linear_Float(m_TweenStartPos.z, startPos.z, t)
                    );
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 旋转相机携程
    /// 从配置中读取旋转参数
    /// </summary>
    /// <param name="complateRecall"></param>
    /// <returns></returns>
    IEnumerator coLookAround(Action complateRecall)
    {
        //计算演示动画数值区间
        var   yrot_str  = UserDatas.GetUserData("CameraYRot");
        var   scale_str = UserDatas.GetUserData("CameraScale");
        float user_yrot;
        float user_scale;

        if (!float.TryParse(yrot_str, out user_yrot))
        {
            user_yrot = SData_mapdata.Single.GetDataOfID(1).CameraY_Xuanzhuan_End;
        }

        if (!float.TryParse(scale_str, out user_scale))
        {
            user_scale = SData_mapdata.Single.GetDataOfID(1).FreeCamera_Scale_End;
        }

        float scale_start;
        float scale_end = user_scale;

        if (user_scale < SData_mapdata.Single.GetDataOfID(1).FreeCamera_Scale_StopRange_Min)
        {
            scale_start = SData_mapdata.Single.GetDataOfID(1).FreeCamera_Scale_End;
        }
        else if (user_scale > SData_mapdata.Single.GetDataOfID(1).FreeCamera_Scale_StopRange_Max)
        {
            scale_start = SData_mapdata.Single.GetDataOfID(1).FreeCamera_Scale;
        }
        else
        {
            scale_start = user_scale;
        }

        float yrot_start;
        float yrot_end = user_yrot;

        if (user_yrot < SData_mapdata.Single.GetDataOfID(1).CameraY_Xuanzhuan_StopRange_Min)
        {
            yrot_start = SData_mapdata.Single.GetDataOfID(1).CameraY_Xuanzhuan_End;
        }
        else if (user_yrot > SData_mapdata.Single.GetDataOfID(1).CameraY_Xuanzhuan_StopRange_Max)
        {
            yrot_start = SData_mapdata.Single.GetDataOfID(1).CameraY_Xuanzhuan_Start;
        }
        else
        {
            yrot_start = user_yrot;
        }


        YQ2CameraCtrl.Single.EnabledAll = false;//禁用相机控制

        float count = 0;

        do
        {
            if (m_InterruptLookAround)
            {
                break;                       //已经被打断了
            }
            count += Time.deltaTime;

            //计算插值系数
            var t = Mathf.Clamp(count / SData_FightKeyValue.Single.ZhanqianCameraStop, 0, 1);

            //插值
            var currScale = DP_TweenFuncs.Tween_Deceleration_Float(scale_start, scale_end, t);
            var currYRot  = DP_TweenFuncs.Tween_Deceleration_Float(yrot_start, yrot_end, t);

            //应用效果
            YQ2CameraCtrl.Single.SetScale(currScale);
            YQ2CameraCtrl.Single.SetYRot(currYRot);

            yield return(null);
        } while (count < SData_FightKeyValue.Single.ZhanqianCameraStop);


        YQ2CameraCtrl.Single.EnabledAll = true;//启用相机控制
    }