public GunComponentValues ReturnRangedValue()
    {
        GunComponentValues values = new GunComponentValues();

        values.MIN = MinimumPartValue;
        values.MAX = MaxmimumPartValue;
        return(values);
    }
    public GunComponentValues ReturnBaseAccuracy()
    {
        GunComponentValues AccuracyValues = new GunComponentValues();

        AccuracyValues.MIN = MinAccuracy;
        AccuracyValues.MAX = MaxAccuracy;
        return(AccuracyValues);
    }
    public GunComponentValues ReturnBaseFireRate()
    {
        GunComponentValues FireRateValues = new GunComponentValues();

        FireRateValues.MIN = MinFireRate;
        FireRateValues.MAX = MaxFireRate;
        return(FireRateValues);
    }
    public GunComponentValues ReturnBaseDPS()
    {
        GunComponentValues DPSValues = new GunComponentValues();

        DPSValues.MIN = MinDPS;
        DPSValues.MAX = MaxDPS;
        return(DPSValues);
    }
    public GunComponentValues ReturnBaseClip()
    {
        GunComponentValues ClipValues = new GunComponentValues();

        ClipValues.MIN = MinClipSize;
        ClipValues.MAX = MaxClipSize;
        return(ClipValues);
    }
Beispiel #6
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);
    }