コード例 #1
0
    /// <summary>
    /// 外部调用摄像机震屏的接口
    /// </summary>
    /// <returns>总时长</returns>
    /// <param name="nRockId">N rock identifier.</param>
    public float InitCameraRock(int nRockId, Callback finishCallback = null)
    {
        Tab_CameraRock _cameraRock = TableManager.GetCameraRockByID(nRockId, 0);

        if (_cameraRock == null)
        {
            return(0);
        }
        CameraRockInfo _tmpInfo = new CameraRockInfo();

        _tmpInfo.CleanUp();
        //初始化数据
        _tmpInfo.m_nCameraRockId = nRockId;
        _tmpInfo.m_fNeedRockTime = _cameraRock.NeedRockTime;
        _tmpInfo.m_fDelayTime    = _cameraRock.DelayTime;
        //位置动画曲线
        _tmpInfo.m_PitchRockOff     = InitRockOff(_cameraRock.PitchAnimCurveId);
        _tmpInfo.m_YawRockOff       = InitRockOff(_cameraRock.YawAnimCurveId);
        _tmpInfo.m_DistanceRockOff  = InitRockOff(_cameraRock.DistanceAnimCurveId);
        _tmpInfo.m_OffsetYRockOff   = InitRockOff(_cameraRock.OffsetAnimCurveId);
        _tmpInfo.m_bContinueRockDie = _cameraRock.IsContinueDie;

        _tmpInfo.m_RockFinishCallback = finishCallback;

        m_CameraRockInfoList.Add(_tmpInfo);

        return(_cameraRock.NeedRockTime + _cameraRock.DelayTime);
    }
コード例 #2
0
 /// <summary>
 /// Stops the camera animation.
 /// </summary>
 /// <param name="nAnimId">N animation identifier.</param>
 public void StopCameraAnim(int nAnimId)
 {
     for (int i = 0; i < m_CameraAnimInfoList.Count; i++)
     {
         CameraRockInfo _tmpRockInfo = m_CameraAnimInfoList[i];
         if (_tmpRockInfo.m_nCameraRockId == nAnimId)
         {
             if (null != _tmpRockInfo.m_RockFinishCallback)
             {
                 _tmpRockInfo.m_RockFinishCallback.Invoke();
             }
             _tmpRockInfo.CleanUp();
             m_CameraAnimInfoList[i] = _tmpRockInfo;
         }
     }
 }
コード例 #3
0
    /// <summary>
    /// Applies the animation.
    /// </summary>
    private void ApplyAnim()
    {
        //有震屏需求 摄像机抖动
        if (m_CameraAnimInfoList.Count > 0)
        {
            Obj_MainPlayer mainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

            if (mainPlayer == null)
            {
                return;
            }

            bool IsRocking = false;
            for (int i = m_CameraAnimInfoList.Count - 1; i >= 0; i--)
            {
                if (m_CameraAnimInfoList[i].IsValid() == false)
                {
                    m_CameraAnimInfoList.RemoveAt(i);
                    continue;
                }
                //struct 先拷贝出一份出来 修改完后 记得再赋值更新
                CameraRockInfo _TmpInfo = m_CameraAnimInfoList[i];
                //死了就不震了
                if (_TmpInfo.m_bContinueRockDie == false && mainPlayer.IsDie())
                {
                    if (null != _TmpInfo.m_RockFinishCallback)
                    {
                        _TmpInfo.m_RockFinishCallback.Invoke();
                    }
                    _TmpInfo.CleanUp();
                }
                else
                {
                    if (_TmpInfo.m_fDelayTime > 0)
                    {
                        _TmpInfo.m_fDelayTime -= Time.deltaTime;
                    }
                    else
                    {
                        if (_TmpInfo.m_fDelayTime <= 0)
                        {
                            if (_TmpInfo.m_fRockTime - _TmpInfo.m_fNeedRockTime >= 0)
                            {
                                if (null != _TmpInfo.m_RockFinishCallback)
                                {
                                    _TmpInfo.m_RockFinishCallback.Invoke();
                                }
                                //震完了 清理数据
                                _TmpInfo.CleanUp();
                            }
                            else
                            {
                                _TmpInfo.m_fRockTime += Time.deltaTime;
                                m_fPitchAnim          = m_CameraAnimInfoList[i].m_PitchRockOff.Evaluate(m_CameraAnimInfoList[i].m_fRockTime);
                                m_fYawAnim            = m_CameraAnimInfoList[i].m_YawRockOff.Evaluate(m_CameraAnimInfoList[i].m_fRockTime);
                                m_fDistanceAnim       = m_CameraAnimInfoList[i].m_DistanceRockOff.Evaluate(m_CameraAnimInfoList[i].m_fRockTime);
                                m_fOffsetAnim         = m_CameraAnimInfoList[i].m_OffsetYRockOff.Evaluate(m_CameraAnimInfoList[i].m_fRockTime);
                                IsRocking             = true;
                            }
                        }
                    }
                }
                //重新赋值更新
                m_CameraAnimInfoList[i] = _TmpInfo;
                if (IsRocking)
                {
                    break;
                }
            }
            if (IsRocking == false)
            {
                m_fPitchAnim    = 0;
                m_fYawAnim      = 0;
                m_fDistanceAnim = 0;
                m_fOffsetAnim   = 0;
            }
        }
        else
        {
            m_fPitchAnim    = 0;
            m_fYawAnim      = 0;
            m_fDistanceAnim = 0;
            m_fOffsetAnim   = 0;
        }
    }