コード例 #1
0
    public void PickupWeapon(WeaponFactionSelector _weaponSelector)
    {
        if (!CanPickupWeapon)
        {
            return;
        }
        FactionWeapon weaponToInstantiate = null;

        for (int i = 0; i < _weaponSelector.weapons.Count; i++)
        {
            if (_weaponSelector.weapons[i].faction == CharacterFaction)
            {
                weaponToInstantiate = _weaponSelector.weapons[i];
                break;
            }
        }

        if (weaponToInstantiate != null)
        {
            // drop current selector and pick new
            if (CurrentWeaponSelector != null)
            {
                //force destroy
                CurrentWeaponSelector.currentInstantiatedWeapon.Ammo = 0;
                CurrentWeaponSelector.CharacterDropSelector(transform.position);
            }
            CurrentWeaponSelector = _weaponSelector;
            CurrentWeaponSelector.CharacterPickSelector(this, weaponToInstantiate);
        }
    }
コード例 #2
0
    public void DropWeapon()

    {
        if (CurrentWeaponSelector != null)
        {
            CurrentWeaponSelector.CharacterDropSelector(transform.position);
            CurrentWeaponSelector = null;
        }
    }