예제 #1
0
    //-----------------------------------------------------------------------------------
    // Method:      TriggerReload
    // Description: Triggers a reload for weaponToReload. Decided to encapsulate reload
    //              code here because sometimes is useful to call from pickup.cs script
    //              For example the player has 0 bullets in the handgun and picks up a handgun
    //              a reload animation will automatically play
    //-----------------------------------------------------------------------------------
    public void TriggerReload(WeaponSet weaponToReload)
    {
        if (!CanFire)
        {
            return;
        }
        switch (weaponToReload)
        {
        case WeaponSet.None:
            break;

        case WeaponSet.Handgun:
            _handgun.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _handgun.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _handgun.ReloadAudio.Play();
            break;

        case WeaponSet.Shotgun:
            _shotgun.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _shotgun.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _shotgun.ReloadAudio.Play();
            break;

        case WeaponSet.PlasmaRifle:
            _plasmaRifle.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _plasmaRifle.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _plasmaRifle.ReloadAudio.Play();
            break;

        case WeaponSet.RailGun:
            break;

        default:
            break;
        }
    }