Example #1
0
 public void execute()
 {
     // 计算伤害
     // todo :以后改为工厂模式通用接口
     HurtVO vo = new HurtVO();
     vo.attacker = this.attacker;
     vo.victim = this.victim;
     vo.damageReason = this.damageReason;
     // 物理伤害
     PhysicsDamageVO phyVO = new PhysicsDamageVO();
     phyVO.damage = this.physicalDamage;
     phyVO.damageBaseOutgoing = attacker.physicalDamageBaseOutgoing + victim.physicalDamageBaseOutgoing;
     phyVO.damagePercentage = attacker.physicalDamagePercentage + victim.physicalDamagePercentage;
     phyVO.damageExtraOutgoing = attacker.physicalDamageExtraOutgoing + victim.physicalDamageExtraOutgoing;
     vo.phycicsDamage = BattleFieldsUtils.getFinalPhysicsDamage(phyVO);
     // 魔法伤害
     SpellDamageVO spellVO = new SpellDamageVO();
     spellVO.damage = this.spellDamage;
     spellVO.damageBaseOutgoing = attacker.spellDamageBaseOutgoing + victim.spellDamageBaseOutgoing;
     spellVO.damagePercentage = attacker.spellDamagePercentage + victim.spellDamagePercentage;
     spellVO.damageExtraOutgoing = attacker.spellDamageExtraOutgoing + victim.spellDamageExtraOutgoing;
     vo.spellDamage = BattleFieldsUtils.getFinalSpellDamage(spellVO);
     // 生命流失
     HpRemovalVO hpRemovalVO = new HpRemovalVO();
     hpRemovalVO.damage = this.hpRemoval;
     vo.hpRemoval = BattleFieldsUtils.getFinalHpRemoval(hpRemovalVO);
     // hurt
     this.victim.hurt(vo);
 }
Example #2
0
 public IBattleVO clone()
 {
     HurtVO vo = new HurtVO();
     vo.attacker = this.attacker;
     vo.victim = this.victim;
     vo.phycicsDamage = this.phycicsDamage;
     vo.spellDamage = this.spellDamage;
     vo.hpRemoval = this.hpRemoval;
     vo.damageReason = this.damageReason;
     return vo;
 }
 public void execute()
 {
     // 攻击方的buff加成属性
     CalcDamageAttackerProperties attackerProps = new CalcDamageAttackerProperties();
     attackerProps.attacker = this.attacker;
     attackerProps.victim = this.victim;
     attackerProps.damageReason = this.damageReason;
     attackerProps.physicalDamage = this.physicalDamage;
     attackerProps.spellDamage = this.spellDamage;
     attackerProps.hpRemoval = this.hpRemoval;
     this.attacker.applyEffects(attackerProps);
     // 受伤害方的buff加成属性
     CalcDamageVictimProperties victimProps = new CalcDamageVictimProperties();
     victimProps.attacker = this.attacker;
     victimProps.victim = this.victim;
     victimProps.damageReason = this.damageReason;
     victimProps.physicalDamage = this.physicalDamage;
     victimProps.spellDamage = this.spellDamage;
     victimProps.hpRemoval = this.hpRemoval;
     this.victim.applyEffects(attackerProps);
     // 计算伤害
     // todo :以后改为工厂模式通用接口
     HurtVO vo = new HurtVO();
     vo.attacker = this.attacker;
     vo.victim = this.victim;
     vo.damageReason = this.damageReason;
     // 物理伤害
     PhysicsDamageVO phyVO = new PhysicsDamageVO();
     phyVO.damage = this.physicalDamage;
     phyVO.damageBaseOutgoing = attackerProps.physicalDamageBaseOutgoing + victimProps.physicalDamageBaseOutgoing;
     phyVO.damagePercentage = attackerProps.physicalDamagePercentage + victimProps.physicalDamagePercentage;
     phyVO.damageExtraOutgoing = attackerProps.physicalDamageExtraOutgoing + victimProps.physicalDamageExtraOutgoing;
     vo.phycicsDamage = BattleFieldsUtils.getFinalPhysicsDamage(phyVO);
     // 魔法伤害
     SpellDamageVO spellVO = new SpellDamageVO();
     spellVO.damage = this.spellDamage;
     spellVO.damageBaseOutgoing = attackerProps.spellDamageBaseOutgoing + victimProps.spellDamageBaseOutgoing;
     spellVO.damagePercentage = attackerProps.spellDamagePercentage + victimProps.spellDamagePercentage;
     spellVO.damageExtraOutgoing = attackerProps.spellDamageExtraOutgoing + victimProps.spellDamageExtraOutgoing;
     vo.spellDamage = BattleFieldsUtils.getFinalSpellDamage(spellVO);
     // 生命流失
     HpRemovalVO hpRemovalVO = new HpRemovalVO();
     hpRemovalVO.damage = this.hpRemoval;
     vo.hpRemoval = BattleFieldsUtils.getFinalHpRemoval(hpRemovalVO);
     // hurt
     this.victim.hurt(vo);
 }
Example #4
0
 public AttackResult(Minion _attackTo, HurtVO _hurtVO)
 {
     success = true;
     attackTo = _attackTo;
     hurtVO = _hurtVO;
 }
Example #5
0
 public static HurtVO operator*(HurtVO _left, int _right)
 {
     HurtVO hurtVO = new HurtVO(_left);
     hurtVO.damageMultiplication *= _right;
     return hurtVO;
 }
Example #6
0
 public HurtVO(HurtVO _hurtVO)
 {
     damage = _hurtVO.damage;
     damageAddition = _hurtVO.damageAddition;
     damageMultiplication = _hurtVO.damageMultiplication;
 }
Example #7
0
 public void hurt(HurtVO vo)
 {
     int totalDamage = vo.phycicsDamage + vo.spellDamage + vo.hpRemoval;
     Debug.Log("unit in position(" + this._row + "," + this._col + ") curHp=" + this._curHp + " hurt,damage is " + totalDamage);
     if ( this._curHp <= totalDamage )
     {
         // 判断是否有死亡前触发的effect
         // 触发单位死亡事件
     }
     else
     {
         this._curHp -= totalDamage;
         // 更新UI
         this._updateViewFlag = true;
     }
     // 触发受伤事件
     EventVOBase evtVO = BattleObjectFactory.createEventVO(BattleConsts.Code.TakeDamage);
     evtVO.setProperty(BattleConsts.Property.DamageAttacker, vo.attacker);
     evtVO.setProperty(BattleConsts.Property.DamageVictim, vo.victim);
     evtVO.setProperty(BattleConsts.Property.CalcPhysicalDamage, vo.phycicsDamage);
     evtVO.setProperty(BattleConsts.Property.CalcSpellDamage, vo.spellDamage);
     evtVO.setProperty(BattleConsts.Property.CalcHpRemoval, vo.hpRemoval);
     evtVO.setProperty(BattleConsts.Property.DamageReason, vo.damageReason);
     BattleEventBase evt = BattleObjectFactory.createBattleEvent(BattleConsts.Code.TakeDamage, evtVO);
     ProcessManager.getInstance().raiseEvent(evt);
 }
Example #8
0
 public void RealHurt(HurtVO _hurtVO)
 {
     HurtVO hurtVO = new HurtVO(_hurtVO);
     int damageGot = Mathf.CeilToInt((hurtVO.damage + hurtVO.damageAddition) * hurtVO.damageMultiplication);
     int tempArmor = data.armor;
     data.armor = data.armor - damageGot;
     damageGot = damageGot - tempArmor;
     if (data.armor < 0) data.armor = 0;
     if (damageGot < 0) damageGot = 0;
     data.health -= damageGot;
     CheckIfDead();
 }
Example #9
0
 public void BeingFightBack(Minion _fightBackMinion, HurtVO _hurtVO)
 {
     Hurt(_hurtVO);
     MinionManager.Instance.CheckResult();
 }
Example #10
0
 public void Hurt(HurtVO _hurtVO)
 {
     BeingHurtResult beingHurtResult = new BeingHurtResult(_hurtVO);
     foreach (Buff buff in buffs)
     {
         beingHurtResult = buff.BeingHurt(this, beingHurtResult);
     }
     if (beingHurtResult.success)
     {
         RealHurt(beingHurtResult.hurtVO);
     }
 }
Example #11
0
 public void BeingFightBack(Minion _fightBackMinion)
 {
     HurtVO hurtVO = new HurtVO(_fightBackMinion);
     BeingFightBack(_fightBackMinion, hurtVO);
 }
Example #12
0
 public void BeingAttacked(Minion _attackingMinion, HurtVO _hurtVO)
 {
     HurtVO hurtVO = new HurtVO(_hurtVO);
     BeingAttackedResult result = new BeingAttackedResult(_attackingMinion, hurtVO);
     for(int i = buffs.Count - 1; i >= 0; --i)
     {
         Buff buff = buffs[i];
         result = buff.BeingAttacked(this, result);
     }
     if (result.success)
     {
         Hurt(result.hurtVO);
         FightBack(result.attackFrom);
     }
     MinionManager.Instance.CheckResult();
 }
Example #13
0
 public void BeingAttacked(Minion _attackingMinion)
 {
     HurtVO hurtVO = new HurtVO(_attackingMinion);
     BeingAttacked(_attackingMinion, hurtVO);
 }
Example #14
0
 public BeingHurtResult(HurtVO _hurtVO)
 {
     success = true;
     hurtVO = _hurtVO;
 }
Example #15
0
 public BeingAttackedResult(Minion _attackFrom, HurtVO _hurtVO)
 {
     success = true;
     attackFrom = _attackFrom;
     hurtVO = _hurtVO;
 }