Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
 set => SetProperty(ref _weaponStates, value);