예제 #1
0
 public void SetGunValues(SCR_GunClass mWeaponValues, GameObject mplayerObj, SCR_Ability mWeaponAbility)
 {
     _weaponStructure = mWeaponValues;
     _gunValues       = _weaponStructure.ReturnGunValues();
     _playerParent    = mplayerObj;
     gunAbility       = mWeaponAbility;
 }
예제 #2
0
    public void AddWeapon(SCR_GunClass newWeapon, GameObject gunBody)
    {
        bPlayerHasGun = true;
        if (_gunInventory[_currentlySelectedWeapon].gunObject)
        {
            _gunInventory[_currentlySelectedWeapon].gunObject.SetActive(false);
        }
        GunValues currentWeapon = newWeapon.ReturnGunValues();
        int       weaponSlot    = 0;

        switch (currentWeapon.SLOTTYPE)
        {
        case GunTypes.Primary: weaponSlot = 0; break;

        case GunTypes.Secondary: weaponSlot = 1; break;

        case GunTypes.Infinite: weaponSlot = 2; break;

        case GunTypes.Throwable: weaponSlot = 3; break;
        }
        _currentWeaponInterface = (IWeapon)gunBody.GetComponent(typeof(IWeapon));
        Destroy(_gunInventory[weaponSlot].gunObject);
        _gunInventory[weaponSlot].gunObject = gunBody;
        _currentlySelectedWeapon            = weaponSlot;
        int _clipSize = _currentWeaponInterface.ReturnClipSize();

        _currentWeaponInterface.setCurrentClip(_clipSize);
        _attackScript.UpdateWeaponInterface(_currentWeaponInterface);
        float percentage = _currentWeaponInterface.ReturnClipSize() * playerStats.GetUpgradeLevelMultiplier(PlayerUpgradeType.reload);

        uiManagerScript.SetGauge(gameObject.tag, (int)percentage);
        uiManagerScript.SetCurrentAmmoText(gameObject.tag, _currentWeaponInterface.ReturnClipSize(), _gunInventory[weaponSlot].currentAmmo, _currentWeaponInterface.ReturnClipSize());
        PlaySwitchingSound();
        if (weaponSlot != 3)
        {
            uiManagerScript.SwitchGunImages(gameObject.tag, false, ThrowableType.FireGrenade, false, _currentWeaponInterface.RetrieveGunValues().ReturnGunValues().GUNTYPE, _currentWeaponInterface.RetrieveGunValues().ReturnGunValues().RARITY, _currentWeaponInterface.RetrieveGunValues().ReturnGunValues().EFFECT);
        }

        if (weaponSlot == 0 || weaponSlot == 1)
        {
            uiManagerScript.EnableWeaponSlot(gameObject.tag, _currentlySelectedWeapon);
        }

        uiManagerScript.SwitchSelectedWeaponUI(gameObject.tag, _currentlySelectedWeapon);
    }
예제 #3
0
    void Awake()
    {
        if (!IsInfinitePistol)
        {
            _weaponStructure = new SCR_GunClass();
            _gunValues       = new GunValues();
        }
        _playerParent = null;
        if (IsInfinitePistol)
        {
            _gunValues   = _weaponStructure.ReturnGunValues();
            _currentClip = _gunValues.CLIPSIZE;
        }

        currentGunShotSource                  = GetComponent <AudioSource>();
        currentMuzzle                         = Instantiate(muzzle, _gunPosition.position, Quaternion.identity);
        currentMuzzle.transform.parent        = _gunPosition.transform;
        currentMuzzle.transform.localRotation = new Quaternion(0, 0, 0, 0);
        currentMuzzle.transform.localScale    = new Vector3(muzzleFlashScale, muzzleFlashScale, muzzleFlashScale);
        currentMuzzle.SetActive(false);
    }
예제 #4
0
    private void Generate(bool random, Rarity rarity)
    {
        int typeRNG     = Random.Range(0, typesOfGuns.Count);
        int SelectedGun = typeRNG;



        float ROF, DPS, CLIP, ACC;

        GunComponentValues GunFireRateValues = typesOfGuns[SelectedGun].ReturnBaseFireRate();

        ROF = Random.Range(GunFireRateValues.MIN, GunFireRateValues.MAX);

        bool HighFireRate = false;

        float MidwayValues = GunFireRateValues.MIN + ((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2);

        if (ROF >= MidwayValues)
        {
            HighFireRate = true;
        }


        GunComponentValues GunAccuracyValue = typesOfGuns[SelectedGun].ReturnBaseAccuracy();
        GunComponentValues GunClipValue     = typesOfGuns[SelectedGun].ReturnBaseClip();
        GunComponentValues GunDPSValue      = typesOfGuns[SelectedGun].ReturnBaseDPS();

        if (HighFireRate)
        {
            MidwayValues          = ((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2);
            GunAccuracyValue.MAX -= MidwayValues;

            MidwayValues     = ((GunDPSValue.MAX - GunDPSValue.MIN) / 2);
            GunDPSValue.MAX -= MidwayValues;

            MidwayValues      = ((GunClipValue.MAX - GunClipValue.MIN) / 2);
            GunClipValue.MIN += MidwayValues;
        }
        else
        {
            MidwayValues          = ((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2);
            GunAccuracyValue.MIN += MidwayValues;

            MidwayValues     = ((GunDPSValue.MAX - GunDPSValue.MIN) / 2);
            GunDPSValue.MIN += MidwayValues;

            MidwayValues      = ((GunClipValue.MAX - GunClipValue.MIN) / 2);
            GunClipValue.MAX -= MidwayValues;
        }



        List <SCR_WeaponPartsClass> scopes = typesOfGuns[SelectedGun].scopes;
        ///Decide if a scope will be added, if so then affect the guns accuracy rate to suit
        int   ScopeSelected = Random.Range(0, scopes.Count);
        float AccuracyAddOn = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * scopes[ScopeSelected].ReturnPercentageIncrease();

        GunAccuracyValue.MIN += AccuracyAddOn;



        int underBarrelSelected = 0;
        List <SCR_WeaponComponent> underBarrels = typesOfGuns[SelectedGun].underBarrel;

        ///Decide if a scope will be added, if so then affect the guns accuracy rate to suit///
        if (underBarrels.Count > 0)
        {
            underBarrelSelected = Random.Range(0, underBarrels.Count);

            for (int i = 0; i < underBarrels[underBarrelSelected].statsComponentAffects.Count; i++)
            {
                float           statAffectAddOn   = 0;
                STR_statsAffect currentComponent  = underBarrels[underBarrelSelected].statsComponentAffects[i];
                statAffect      currentStatAffect = currentComponent.componentStatType;
                switch (currentStatAffect)
                {
                case statAffect.accuracy:
                    statAffectAddOn       = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunAccuracyValue.MIN += statAffectAddOn;
                    break;


                case statAffect.damage:
                    statAffectAddOn  = (((GunDPSValue.MAX - GunDPSValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunDPSValue.MIN += statAffectAddOn;
                    break;


                case statAffect.clipSize:
                    statAffectAddOn   = (((GunClipValue.MAX - GunClipValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunClipValue.MIN += statAffectAddOn;
                    break;


                case statAffect.rateOfFire:
                    statAffectAddOn        = (((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2) / 100) * currentComponent.percentage;
                    GunFireRateValues.MIN += statAffectAddOn;
                    break;
                }
            }
        }



        int barrelSelected = 0;
        List <SCR_WeaponComponent> barrel = typesOfGuns[SelectedGun].barells;

        ///Decide if a new clip will be added, if so then affect the guns clip size to suit
        if (barrel.Count > 0)
        {
            barrelSelected = Random.Range(0, barrel.Count);
            for (int i = 0; i < underBarrels[underBarrelSelected].statsComponentAffects.Count; i++)
            {
                float           statAffectAddOn   = 0;
                STR_statsAffect currentComponent  = underBarrels[underBarrelSelected].statsComponentAffects[i];
                statAffect      currentStatAffect = currentComponent.componentStatType;
                switch (currentStatAffect)
                {
                case statAffect.accuracy:
                    statAffectAddOn       = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunAccuracyValue.MIN += statAffectAddOn;
                    break;


                case statAffect.damage:
                    statAffectAddOn  = (((GunDPSValue.MAX - GunDPSValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunDPSValue.MIN += statAffectAddOn;
                    break;


                case statAffect.clipSize:
                    statAffectAddOn   = (((GunClipValue.MAX - GunClipValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunClipValue.MIN += statAffectAddOn;
                    break;


                case statAffect.rateOfFire:
                    statAffectAddOn        = (((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2) / 100) * currentComponent.percentage;
                    GunFireRateValues.MIN += statAffectAddOn;
                    break;
                }
            }
        }



        ACC  = Random.Range(GunAccuracyValue.MIN, GunAccuracyValue.MAX);
        DPS  = Random.Range(GunDPSValue.MIN, GunDPSValue.MAX);
        CLIP = Random.Range(GunClipValue.MIN, GunClipValue.MAX);



        List <SCR_WeaponPartsRangedClass> clips = typesOfGuns[SelectedGun].clips;
        ///Decide if a new clip will be added, if so then affect the guns clip size to suit
        int clipSelected             = 0;
        GunComponentValues maxValues = clips[clips.Count - 1].ReturnRangedValue();

        if (CLIP > maxValues.MAX)
        {
            clipSelected = clips.Count - 1;
        }
        else
        {
            if (clips.Count > 0)
            {
                for (int i = 0; i < clips.Count; i++)
                {
                    GunComponentValues ClipValues = clips[i].ReturnRangedValue();

                    if (CLIP >= ClipValues.MIN && CLIP < ClipValues.MAX && (i + 1) == clips.Count)
                    {
                        clipSelected = i;
                    }
                }
            }
        }



        int WeaponsRating = 0;

        if (random)
        {
            int RatingRNG = Random.Range(0, 101);

            for (int i = weaponRates.Count - 1; i >= 0; i--)
            {
                if (RatingRNG > weaponRates[i].Rating && WeaponsRating < i)
                {
                    WeaponsRating = i;
                }
            }
        }
        else
        {
            for (int i = 0; i < weaponRates.Count; i++)
            {
                if (weaponRates[i].rarityType == rarity)
                {
                    WeaponsRating = i;
                    break;
                }
            }
        }



        ACC  *= weaponRates[WeaponsRating].statsAffect;
        DPS  *= weaponRates[WeaponsRating].statsAffect;
        CLIP *= weaponRates[WeaponsRating].statsAffect;
        ROF  *= weaponRates[WeaponsRating].statsAffect;


        GunTypes   currentGunType    = typesOfGuns[SelectedGun].ReturnGunTypes();
        WeaponType currentWeaponType = typesOfGuns[SelectedGun].ReturnWeaponsType();


        ElementalEffect currentWeaponsEffect = SelectEffect();


        int  weaponAbility = LegendaryAbilities.Count;
        bool hasAbility    = false;

        if (weaponRates[WeaponsRating].rarityType == Rarity.Legendary)
        {
            weaponAbility = Random.Range(0, LegendaryAbilities.Count);
            hasAbility    = true;
        }



        Gun = new SCR_GunClass();
        Gun.SetGunModel(SelectedGun, ScopeSelected, clipSelected, underBarrelSelected, barrelSelected, currentGunType, currentWeaponType, currentWeaponsEffect, weaponAbility, hasAbility);
        Gun.SetGunStats((int)CLIP, DPS, ROF, ACC);
        Gun.SetRarity(weaponRates[WeaponsRating].rarityType);
    }