Exemplo n.º 1
0
    private void Awake()
    {
        instantiatedWeapon = Instantiate(weaponObj, weaponPos);
        SetLayerRecursively(instantiatedWeapon, weaponPos.gameObject.layer);
        gunTip            = instantiatedWeapon.GetComponentInChildren <GunTip>().gameObject.transform;
        _gunEffectsHolder = instantiatedWeapon.GetComponentInChildren <GunEffectsHolder>().gameObject.transform;
        _gunInterface     = GetComponentInChildren <GunInterface>();
        _gunInterface.SetSubText(_currentAmmo.ToString());
        CurrentAmmo = clipSize;

        if (tracerEffect != null)
        {
            instantiatedTracer = Instantiate(tracerEffect, _gunEffectsHolder);
        }
        if (muzzleFlash != null)
        {
            instantiatedMuzzleFlash = Instantiate(muzzleFlash, _gunEffectsHolder);
        }

        if (altFireController != null)
        {
            instantiatedAltFireController = Instantiate(altFireController, weaponPos);
            altFire = instantiatedAltFireController.GetComponent <altFireController>().altFireScript as altFireBase;
        }
    }
Exemplo n.º 2
0
    public void InitializeNewWeapon(WeaponInstance weapon)
    {
        weaponObj = weapon.weaponObj;

        hitDamage   = weapon.hitDamage;
        fireRate    = weapon.fireRate;
        clipSize    = weapon.clipSize;
        CurrentAmmo = weapon.currentAmmo;
        reloadTime  = weapon.reloadTime;
        isAutomatic = weapon.isAutomatic;

        _isReloading = false;
        IsZoomed     = false;

        spreading           = weapon.spreading;
        normalBurstDuration = weapon.normalBurstDuration;
        burstPenaltySpeed   = weapon.burstPenaltySpeed;
        maxBurstPenalty     = weapon.maxBurstPenalty;
        CurrentBurstPenalty = 0f;

        zoomRotateModifier    = weapon.zoomRotateModifier;
        zoomSpeedModifier     = weapon.zoomSpeedModifier;
        zoomSpreadingModifier = weapon.zoomSpreadingModifier;
        zoomValue             = weapon.zoomValue;
        impactForce           = weapon.impactForce;

        _currentMode      = 1;
        altFireController = weapon.altFireController;

        tracerEffect = weapon.tracerEffect;
        muzzleFlash  = weapon.muzzleFlash;
        impactEffect = weapon.impactEffect;
        hitDecal     = weapon.hitDecal;
        recoilAngle  = weapon.recoilAngle;

        Destroy(instantiatedWeapon);
        Destroy(instantiatedAltFireController);

        instantiatedWeapon = Instantiate(weaponObj, weaponPos);
        gunTip             = instantiatedWeapon.GetComponentInChildren <GunTip>().gameObject.transform;
        _gunEffectsHolder  = GetComponentInChildren <GunEffectsHolder>().gameObject.transform;
        _gunInterface      = instantiatedWeapon.GetComponentInChildren <GunInterface>();
        _gunInterface.SetSubText(CurrentAmmo.ToString());

        instantiatedTracer      = Instantiate(tracerEffect, _gunEffectsHolder);
        instantiatedMuzzleFlash = Instantiate(muzzleFlash, _gunEffectsHolder);

        if (altFireController != null)
        {
            instantiatedAltFireController = Instantiate(altFireController, weaponPos);
            altFire = instantiatedAltFireController.GetComponent <altFireController>().altFireScript as altFireBase;
        }

        GetComponent <ShootingSystem>().gunRecoil = instantiatedWeapon.GetComponentInChildren <RecoilGun>();
    }