예제 #1
0
 public Shooter(Transform sourceTransform, MonoBehaviour coroutineKeeper, Animator animator, ShooterType type)
 {
     _sourceTransform = sourceTransform;
     _coroutineKeeper = coroutineKeeper;
     _animator        = animator;
     _type            = type;
 }
    /// <summary>
    /// From version 1.3 onward, you can setup weapon "configurations" which are stored in the weaponConfigs List property. You should use this
    /// EquipWeaponConfiguration method to change weapons, passing in the index of the list for the weapon you want to select. Use the in-editor inspector on the WeaponSystem component to setup new configurations and
    /// add them to the inventory/configurations list.
    /// </summary>
    /// <param name="slot">The weapon configuration 'slot' index to equip.</param>
    public void EquipWeaponConfiguration(int slot)
    {
        if (_weaponConfigs.Count <= 0)
        {
            return;
        }
        var weaponConfig = _weaponConfigs[slot];

        if (weaponConfig == null)
        {
            return;                       // Return if an invalid weaponConfig is requested
        }
        var config = _weaponConfigs[slot];

        weaponName                = config.weaponName;
        ammoUsed                  = config.ammoUsed;
        bulletColour              = config.bulletColour;
        bulletCount               = config.bulletCount;
        bulletRandomness          = config.bulletRandomness;
        bulletSpacing             = config.bulletSpacing;
        bulletSpeed               = config.bulletSpeed;
        bulletSpread              = config.bulletSpread;
        bulletSpreadPingPongMax   = config.bulletSpreadPingPongMax;
        bulletSpreadPingPongMin   = config.bulletSpreadPingPongMin;
        spreadPingPongSpeed       = config.spreadPingPongSpeed;
        weaponFireRate            = config.weaponFireRate;
        weaponXOffset             = config.weaponXOffset;
        weaponYOffset             = config.weaponYOffset;
        ricochetChancePercent     = config.ricochetChancePercent;
        startingAmmo              = config.ammoAvailable;
        autoFire                  = config.autoFire;
        pingPongSpread            = config.pingPongSpread;
        richochetsEnabled         = config.richochetsEnabled;
        hitEffectEnabled          = config.hitEffectEnabled;
        limitedAmmo               = config.limitedAmmo;
        weaponIcon                = config.weaponIcon;
        gunPoint                  = config.gunPoint;
        weaponRelativeToComponent = config.weaponRelativeToComponent;
        bulletCountsAsAmmo        = config.bulletCountsAsAmmo;
        usesMagazines             = config.usesMagazines;
        magazineChangeDelay       = config.magazineChangeDelay;
        magazineRemainingBullets  = config.magazineRemainingBullets;
        magazineSize              = config.magazineSize;
        isFirstEquip              = config.isFirstEquip;
        playEmptySfx              = config.playEmptySfx;
        emptySfxClip              = config.emptySfxClip;
        reloadSfxClip             = config.reloadSfxClip;
        playReloadingSfx          = config.playReloadingSfx;
        shotFiredClip             = config.shotFiredClip;
        targetToTrack             = config.targetToTrack;
        trackingTurnRate          = config.trackingTurnRate;
        lerpTurnRate              = config.lerpTurnRate;
        mirrorX = config.mirrorX;

        bulletOptionType     = config.BulletOptionType;
        shooterDirectionType = config.ShooterType;

        // If the weapon uses magazines we want to setup initial magazine clip with bullets etc the first time the weapon is equipped...
        if (usesMagazines && isFirstEquip && !isReloading && ammoUsed < startingAmmo)
        {
            StartCoroutine(LoadMagazine(true, false));
            isFirstEquip = false;
        }

        if (WeaponConfigurationChanged != null)
        {
            WeaponConfigurationChanged(gunPoint, slot);
        }
    }