private void Update()
    {
        if (!_ply || !_lphm)
        {
            return;
        }

        _curFireCooldown -= Time.deltaTime;

        if (_curFireCooldown <= 0 && _curMagazine > 0 && !_lphm.IsDead() && !_isReloading)
        {
            if (_isAutomatic && _weaponState == _weaponStates.automatic && InputManager.instance.GetLeftMouse())
            {
                Shoot();
                PlayAudioClip();
            }
            else if (_weaponState == _weaponStates.single && InputManager.instance.GetLeftMouseDown())
            {
                Shoot();
                PlayAudioClip();
            }
        }

        if (InputManager.instance.GetKeyDown(KeyCode.R) && !_lphm.IsDead() && _curAmmo > 0 && !_isReloading)
        {
            Reload();
            PlayAudioClip(_soundClipTypes.reload);
        }

        if (InputManager.instance.GetKeyDown(KeyCode.B) && !_lphm.IsDead())
        {
            if (_isAutomatic)
            {
                var numberOfWeaponStates = Enum.GetValues(typeof(_weaponStates)).Length;

                _weaponState += 1;
                if ((int)_weaponState == numberOfWeaponStates)
                {
                    _weaponState = 0;
                }
                Debug.Log("Switched to " + Enum.GetName(typeof(_weaponStates), _weaponState));
            }
            else
            {
                _weaponState = _weaponStates.single;
            }

            PlayAudioClip(_soundClipTypes.switchstate);
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (!player.IsCovering() && !player.IsAiming() && !healthManager.IsDead())
        {
            score += currentMultiplier;
        }

        if (player.IsCovering() && !healthManager.IsDead())
        {
            score--;
        }

        scoreText.text      = score.ToString();
        multiplierText.text = currentMultiplier.ToString() + "x";
    }