Esempio n. 1
0
        protected virtual void PullTheTrigger()
        {
            if (CurrentRounds > 0 && Magazines >= 0)
            {
                if (FireMode == GunData.FireMode.FullAuto || FireMode == GunData.FireMode.Single)
                {
                    m_NextFireTime = Time.time + m_FireInterval;
                    CurrentRounds--;

                    m_NextShootDirection = GetBulletSpread();
                    Shot();

                    m_IsShooting = 0.1f;

                    m_GunAnimator.Shot(CurrentRounds == 0);
                    m_GunEffects.Play();

                    StartCoroutine(m_MotionAnimation.RecoilAnimation(false));

                    if (m_CameraAnimationsController)
                    {
                        m_CameraAnimationsController.ApplyRecoil(m_MotionAnimation.CameraRecoil, m_MotionAnimation.MinCameraRecoilRotation, m_MotionAnimation.MaxCameraRecoilRotation,
                                                                 m_MotionAnimation.CameraRecoilDuration, m_MotionAnimation.CameraReturnDuration);
                    }
                }
                else if (FireMode == GunData.FireMode.ShotgunAuto || FireMode == GunData.FireMode.ShotgunSingle)
                {
                    m_NextFireTime = Time.time + m_FireInterval;
                    CurrentRounds--;

                    for (int i = 0; i < m_GunData.BulletsPerShoot; i++)
                    {
                        m_NextShootDirection = GetBulletSpread();
                        Shot();
                    }

                    m_IsShooting = 0.1f;

                    m_GunAnimator.Shot(CurrentRounds == 0);
                    m_GunEffects.Play();

                    StartCoroutine(m_MotionAnimation.RecoilAnimation(false));

                    if (m_CameraAnimationsController != null)
                    {
                        m_CameraAnimationsController.ApplyRecoil(m_MotionAnimation.CameraRecoil, m_MotionAnimation.MinCameraRecoilRotation, m_MotionAnimation.MaxCameraRecoilRotation,
                                                                 m_MotionAnimation.CameraRecoilDuration, m_MotionAnimation.CameraReturnDuration);
                    }
                }
                else if (FireMode == GunData.FireMode.Burst)
                {
                    m_NextFireTime = Time.time + m_FireInterval * (m_GunData.BulletsPerBurst + 1);
                    StartCoroutine(Burst());
                }
            }
            else
            {
                m_NextFireTime = Time.time + 0.25f;
                m_GunAnimator.OutOfAmmo();
            }
        }