Ejemplo n.º 1
0
 private void LateUpdate()
 {
     if (MyInfoManager.Instance.IsSpectator)
     {
         _LateUpdate4SpectatorMode();
     }
     else if (!alive)
     {
         _LateUpdate4Respawn();
     }
     else if (null != cannon)
     {
         _LateUpdate4Cannon();
     }
     else
     {
         if (Screen.lockCursor)
         {
             float num = 0f;
             if (sumOfRecoilPitch > 0f)
             {
                 num = y - Mathf.Lerp(y, y - sumOfRecoilPitch, 2f * Time.deltaTime);
                 sumOfRecoilPitch -= num;
                 if (sumOfRecoilPitch < 0f)
                 {
                     sumOfRecoilPitch = 0f;
                 }
             }
             float num2 = 0f;
             if (sumOfRecoilYaw < 0f)
             {
                 num2            = x - Mathf.Lerp(x, x - sumOfRecoilYaw, 2f * Time.deltaTime);
                 sumOfRecoilYaw -= num2;
                 if (sumOfRecoilYaw > 0f)
                 {
                     sumOfRecoilYaw = 0f;
                 }
             }
             else if (sumOfRecoilYaw > 0f)
             {
                 num2            = x - Mathf.Lerp(x, x - sumOfRecoilYaw, 2f * Time.deltaTime);
                 sumOfRecoilYaw -= num2;
                 if (sumOfRecoilYaw < 0f)
                 {
                     sumOfRecoilYaw = 0f;
                 }
             }
             sumOfRecoilYaw   += recoilYaw;
             sumOfRecoilPitch += recoilPitch;
             x += Input.GetAxis("Mouse X") * xSpeed * cameraSpeedFactor * scopeCameraFactor * 0.02f + recoilYaw - num2;
             if (GlobalVars.Instance.reverseMouse)
             {
                 y += Input.GetAxis("Mouse Y") * ySpeed * cameraSpeedFactor * scopeCameraFactor * 0.02f - recoilPitch + num;
             }
             else
             {
                 y -= Input.GetAxis("Mouse Y") * ySpeed * cameraSpeedFactor * scopeCameraFactor * 0.02f + recoilPitch - num;
             }
             recoilPitch = 0f;
             recoilYaw   = 0f;
             y           = Angles.ClampAngle(y, yMinLimit, yMaxLimit);
         }
         base.transform.rotation = Quaternion.Euler(y, x, 0f);
     }
 }