void Update()
        {
            if (!Loader.HasLoaded)
            {
                return;
            }


            //this.UpdateWeaponTransform ();

            if (CurrentWeapon != null)
            {
                CurrentWeapon.EnableOrDisableGunFlash();
                CurrentWeapon.UpdateGunFlashRotation();
            }

            // reload weapon ammo clip
            if (CurrentWeapon != null)
            {
                if (CurrentWeapon.AmmoClipSize > 0 && CurrentWeapon.AmmoInClip <= 0)
                {
                    int amountToRefill = Mathf.Min(CurrentWeapon.AmmoClipSize, CurrentWeapon.AmmoOutsideOfClip);
                    CurrentWeapon.AmmoInClip         = amountToRefill;
                    CurrentWeapon.AmmoOutsideOfClip -= amountToRefill;
                }
            }
        }
Beispiel #2
0
        void Update()
        {
            if (!Loader.HasLoaded)
            {
                return;
            }


            // switch weapons
            if (GameManager.CanPlayerReadInput())
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    this.SwitchWeapon(false);
                }
                else if (Input.GetKeyDown(KeyCode.E))
                {
                    this.SwitchWeapon(true);
                }
            }

            this.UpdateWeaponTransform();

            if (CurrentWeapon != null)
            {
                CurrentWeapon.EnableOrDisableGunFlash(m_player);
                CurrentWeapon.UpdateGunFlashRotation(m_player);
            }

            // update aiming state

            if (this.IsAiming)
            {
                // check if we should exit aiming state
                if (!this.IsHoldingWeapon || m_player.IsInVehicle || !this.IsAimOn)
                {
                    if (!this.IsFiring)
                    {
                        this.IsAiming = false;
                    }
                }
            }
            else
            {
                // check if we should enter aiming state
                if (this.IsHoldingWeapon && this.IsAimOn && !m_player.IsInVehicle)
                {
                    this.IsAiming = true;
                }
            }

            // update firing state

            if (!this.IsAiming)
            {
                this.IsFiring = false;
            }
        }
Beispiel #3
0
        void Update()
        {
            if (!Loader.HasLoaded)
            {
                return;
            }


            // switch weapons
            if (GameManager.CanPlayerReadInput())
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    this.SwitchWeapon(false);
                }
                else if (Input.GetKeyDown(KeyCode.E))
                {
                    this.SwitchWeapon(true);
                }
            }

            //this.UpdateWeaponTransform ();

            if (CurrentWeapon != null)
            {
                CurrentWeapon.EnableOrDisableGunFlash();
                CurrentWeapon.UpdateGunFlashRotation();
            }

            // update aiming state

            if (this.IsAiming)
            {
                // check if we should exit aiming state
                if (!this.IsHoldingWeapon || m_ped.IsInVehicle || !this.IsAimOn)
                {
                    if (!this.IsFiring)
                    {
                        this.IsAiming = false;
                    }
                }
            }
            else
            {
                // check if we should enter aiming state
                if (this.IsHoldingWeapon && this.IsAimOn && !m_ped.IsInVehicle)
                {
                    this.IsAiming = true;
                }
            }

            // update firing state

            if (!this.IsAiming)
            {
                this.IsFiring = false;
            }

            // reload weapon ammo clip
            if (CurrentWeapon != null)
            {
                if (CurrentWeapon.AmmoClipSize > 0 && CurrentWeapon.AmmoInClip <= 0)
                {
                    int amountToRefill = Mathf.Min(CurrentWeapon.AmmoClipSize, CurrentWeapon.AmmoOutsideOfClip);
                    CurrentWeapon.AmmoInClip         = amountToRefill;
                    CurrentWeapon.AmmoOutsideOfClip -= amountToRefill;
                }
            }
        }