public void MakeAndAddSpellEffect(BtlCtrlCharacter target, SpellEffectOnChar effectOnChar, BtlCtrlCharacter.ChangeStatInfo changeStatInfo) { var statChanges = new List <SpellSingleStatChangeInfo>(); if (Mathf.Abs(changeStatInfo.shieldChangeAmount) > 0) { statChanges.Add(new SpellSingleStatChangeInfo( SpellSingleStatChangeType.curShieldValChange, changeStatInfo.shieldChangeAmount)); } if (Mathf.Abs(changeStatInfo.hpChangeAmount) > 0) { statChanges.Add(new SpellSingleStatChangeInfo( SpellSingleStatChangeType.curHPValChange, changeStatInfo.hpChangeAmount)); } var stat = new BattleObjStats(target.hp, target.maxHp, damage, target.shield, target.maxShield); var effectInfo = new SpellEffectInfo( statChanges, target.id, effectOnChar, stat); _spellEffectInfoes.Add(effectInfo); }
public override void StartIt(BtlCtrlSpell main, List <BtlCtrlCharacter> targets) { for (int i = 0; i < targets.Count; i++) { changeStatInfo = targets[i].ApplyDamage(main.damage); main.MakeAndAddSpellEffect(targets[i], SpellEffectOnChar.NormalDamage, changeStatInfo); } }
//Private Methods private BtlCtrlCharacter.ChangeStatInfo[] CalculateChangeStateByPercent() { BtlCtrlCharacter.ChangeStatInfo[] changeStatArray = new BtlCtrlCharacter.ChangeStatInfo[_percents.Length]; int dmg, currentDmg; dmg = currentDmg = _damage; for (int i = 0; i < changeStatArray.Length; i++) { if (i != changeStatArray.Length - 1) //last one { currentDmg = (int)(_damage * _percents[i]); dmg -= currentDmg; } else { currentDmg = dmg; } int shieldChange = 0, hpChange = 0; if (_changeStatInfo.shieldChangeAmount != 0) { if (Mathf.Abs(currentDmg) <= Mathf.Abs(_changeStatInfo.shieldChangeAmount)) { shieldChange = currentDmg; _changeStatInfo.ChangeShield(Mathf.Abs(currentDmg)); currentDmg = 0; } else { shieldChange = _changeStatInfo.shieldChangeAmount; currentDmg -= _changeStatInfo.shieldChangeAmount; _changeStatInfo.ChangeShield(Mathf.Abs(_changeStatInfo.shieldChangeAmount));//make it 0 } } if (currentDmg != 0) { hpChange = currentDmg; _changeStatInfo.ChangeHP(Mathf.Abs(currentDmg)); currentDmg = 0; } changeStatArray[i].SetValues(hpChange, shieldChange); } return(changeStatArray); }
public override void StartIt(BtlCtrlSpell main, List <BtlCtrlCharacter> targets) { for (int i = 0; i < targets.Count; i++) { _damage = main.damage; _changeStatInfo = targets[i].ApplyDamage(_damage); BtlCtrlCharacter.ChangeStatInfo[] changeStatArray = CalculateChangeStateByPercent(); for (int j = 0; j < changeStatArray.Length; j++) { main.MakeAndAddSpellEffect(targets[i], SpellEffectOnChar.NormalDamage, changeStatArray[j]); } } }