private void OnAttackHit(object obj) { //结算对自身的伤害 AttackStruct attackStruct = obj as AttackStruct; attackStruct.boutAction.iValue = BattleTool.AdjustAttackVal(attackStruct.casterInst, _battleModel.selfData, attackStruct.boutAction.iValue); int orignArmor = _battleModel.selfData.armor; int leftArmor = orignArmor - attackStruct.boutAction.iValue; int reduceArmor = 0; int reeduceHp = 0; if (leftArmor < 0) { _battleModel.UpdateArmor(_battleModel.selfData, 0); _battleModel.ReduceSelfHp(-leftArmor); reduceArmor = orignArmor; reeduceHp = -leftArmor; } else //如果护甲有剩余 { _battleModel.UpdateArmor(_battleModel.selfData, leftArmor); reduceArmor = attackStruct.boutAction.iValue; } SoundTool.inst.PlaySoundEffect(ResPath.SFX_SPEAR); //todo 根据模板表和是否格挡来播放音效 Message.Send(MsgType.SHOW_HIT_EFFECT, attackStruct); OnObjectHitted(attackStruct.casterInst, _battleModel.selfData, reeduceHp, reduceArmor); }
IEnumerator Combo_Coroutine() { //foreach attack in the list for (int i = 0; i < attacks.Length; i++) { //reset attack currentAttack = attacks[i]; goToNextAttack = false; //stop coroutines if (slideForward_Coroutine != null) { player.StopCoroutine(slideForward_Coroutine); } //effective attack SlideForward(); Attack(); //then wait end of attack yield return(new WaitForSeconds(currentAttack.timeBeforeNextAttack)); //check if ended combo or go to next attack bool lastAttack = i >= attacks.Length - 1; if (CheckEndCombo(lastAttack)) { break; } } //come back to fight state EndAttack(); }
/// <summary> /// Find the attack in the list of attacks and calculate the damage /// then call the attack function of the area manager. /// </summary> public override void OnAction() { if (areaManager != null) { string attackName = option.optionText; AttackStruct attack = attacks.GetAttack(attackName); int damage = CalculateDamage(attack.damage, attack.physicalOrMagic); areaManager.Attack(damage, attack.manacost); } }
private void OnShowHitEffect(object obj) { AttackStruct attackStruct = obj as AttackStruct; //todo 判断攻击者是否是敌人 ftSelf.ShowHitEffect(); if (attackStruct.isBlock) { ShowBlockText(ftSelf.xy); } }
private void OnDoAttack(object obj) { AttackStruct attackStruct = obj as AttackStruct; Fighter fighter = GetFighter(attackStruct.casterInst.instId); if (fighter == null) { return; } fighter.DoAttack(() => { Message.Send(MsgType.ATTACK_HIT, attackStruct); }); }