public void UpdateStats(SpellEffectInfo effectInfo, bool isFinal) { DivineDebug.Log("Update Stats for: "); DivineDebug.Log("CurrentHP: " + _currentStats.hp + " FinalHP: " + effectInfo.finalCharacterStats.hp + " IsFinal: " + isFinal); if ((effectInfo.isMultiPart && isFinal) || !effectInfo.isMultiPart) { _currentStats = effectInfo.finalCharacterStats; DivineDebug.Log("moniker " + moniker + " hp: " + _currentStats.hp + " shield: " + _currentStats.shield + " damage: " + _currentStats.damage); charInfo.SetBaseStats(_currentStats.hp, _currentStats.maxHp, _currentStats.damage, _currentStats.shield, _currentStats.maxShield); } else { for (int i = 0; i < effectInfo.singleStatChanges.Count; i++) { switch (effectInfo.singleStatChanges[i].charStatChangeType) { case SpellSingleStatChangeType.None: break; case SpellSingleStatChangeType.curHPValChange: _currentStats.SetHP(_currentStats.hp + effectInfo.singleStatChanges[i].intVal); break; case SpellSingleStatChangeType.curShieldValChange: _currentStats.SetShield(_currentStats.shield + effectInfo.singleStatChanges[i].intVal); break; case SpellSingleStatChangeType.curDamageValChange: _currentStats.damage += effectInfo.singleStatChanges[i].intVal; break; case SpellSingleStatChangeType.curFlagValChange: _currentStats.flags = (BattleFlags)effectInfo.singleStatChanges[i].intVal; break; default: break; } } } DivineDebug.Log("After Update CurrentHP: " + _currentStats.hp + " Shield: " + _currentStats.shield + " Flag: " + _currentStats.flags.ToString()); ShowUpdatingStatsVisual(effectInfo); if (_curState == CharacterState.Idle && _currentStats.hp <= 0) { SetState_Dying(false); } _previousFlag = _currentStats.flags; }
public static BattleObjStats operator -(BattleObjStats a, BattleObjStats b) { BattleObjStats c = new BattleObjStats(0, a.maxHp - b.maxHp, a.damage - b.damage, 0, a.maxShield - b.maxShield); c.SetHP(a.hp - b.hp); c.SetShield(a.shield - b.shield); return c; }
public ChangeStatInfo ApplyDamage(int amount) { DivineDebug.Log("Character " + moniker + " Hp-Shield: " + _stats.hp + " " + _stats.shield, DivineLogType.Warn); if (amount > 0) { DivineDebug.Log("Positive amount for damage is wrong", DivineLogType.Error); _lastChangeStatInfo.SetValues(0, 0); return(_lastChangeStatInfo); } int beforeDmgShield = 0; int amountDecreaseFromHP = 0; int amountDecreaseFromShield = 0; if (_stats.shield > 0) { beforeDmgShield = _stats.shield; _stats.SetShield(_stats.shield + amount); // amount is negative here amountDecreaseFromShield = _stats.shield > 0 ? amount : beforeDmgShield; amount += beforeDmgShield; amount = Mathf.Min(amount, 0); } if (amount < 0) //still has damage to apply { int beforeDmghp = _stats.hp; _stats.SetHP(_stats.hp + amount); amountDecreaseFromHP = _stats.hp > 0 ? amount : beforeDmghp; } _lastChangeStatInfo.SetValues(amountDecreaseFromHP, amountDecreaseFromShield); if (_isActive) { relatedParty.ChangeAP(1); } if (isDead && type == Type.Troop && _isActive) { relatedParty.ChangeAP(2); } DivineDebug.Log("Character " + moniker + " Hp-Shield: " + _stats.hp + " " + _stats.shield, DivineLogType.Warn); if (beforeDmgShield > 0 && shield <= 0 && type == Type.Hero) { CastSpell(2, new List <BtlCtrlCharacter> { relatedParty.chakra }, null, false); } return(_lastChangeStatInfo); }
public void CopyStatsTo(BattleObjStats statsObj) { statsObj.maxHp = this.maxHp ; statsObj.SetHP ( this.hp ) ; statsObj.damage = this.damage ; statsObj.SetShield ( this.shield ) ; statsObj.maxShield = this.maxShield ; }