public override void OnAttack(CharacterData target, CharacterData user, ref Weapon.AttackData attackData) { if (Random.value < (PercentageChance / 100.0f)) { ElementalEffect effect = new ElementalEffect(Time, StatSystem.DamageType.Fire, Damage, 1.0f); target.Stats.AddElementalEffect(effect); } }
public void SetGunModel(int bodyType, int scopeType, int clipType, int underBarrelType, int stockType, GunTypes type, WeaponType weaponType, ElementalEffect typeOfEffect, int mtypeOfAbility, bool mHasAbility) { body = bodyType; scope = scopeType; clip = clipType; underBarrel = underBarrelType; barrel = stockType; WeaponSlot = type; typeOfWeapon = weaponType; effect = typeOfEffect; Ability = mHasAbility; typeOfAbility = mtypeOfAbility; }
ElementalEffect SelectEffect() { int rng = Random.Range(0, 4); ElementalEffect effect = ElementalEffect.Normal; switch (rng) { case 0: effect = ElementalEffect.Normal; break; case 1: effect = ElementalEffect.Fire; break; case 2: effect = ElementalEffect.Oil; break; case 3: effect = ElementalEffect.Destructor; break; } return(effect); }
public void AddElementalEffect(ElementalEffect effect) { bool hasBeenAdded = false; foreach (ElementalEffect focus in effects) { if (focus.getName().Equals(effect.getName())) { focus.addToStack(); hasBeenAdded = true; Destroy(effect); break; } } if (!hasBeenAdded) //Add if not found { effects.Add(effect); } }
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); }