/// <summary> /// 造成伤害 /// </summary> /// <param name="attackHurtStruct"></param> public override CalculateHurt.Result GiveAttackHurtStruct(AttackHurtStruct attackHurtStruct) { MonsterControl monsterControl = GetComponent <MonsterControl>(); if (monsterControl != null && monsterControl.monsterDataInfo != null && monsterControl.monsterDataInfo.MonsterBaseAttribute != null) { PhysicDefenseFactor physicDefenseFactor = monsterControl.monsterDataInfo.PhysicDefenseFactor; //物理防御系数 MagicDefenseFactor magicDefenseFactor = monsterControl.monsterDataInfo.MagicDefenseFactor; //魔法防御系数 CalculateHurt.Result result = CalculateHurt.Calculate(attackHurtStruct, monsterControl.thisAttribute, physicDefenseFactor, magicDefenseFactor); monsterControl.GiveHit(); //显示伤害 base.ShowHurt(result, gameObject); //显示怪物的血条 iGameState.ShowMonsterHP = new MonsterHPUIStruct() { monsterName = monsterControl.monsterDataInfo.monsterPrefabName, maxHP = monsterControl.thisAttribute.MaxHP, nowHP = monsterControl.thisAttribute.HP, monsterObj = gameObject }; return(result); } return(default(CalculateHurt.Result)); }
/// <summary> /// 造成伤害 /// </summary> /// <param name="attackHurtStruct"></param> public override CalculateHurt.Result GiveAttackHurtStruct(AttackHurtStruct attackHurtStruct) { IPlayerState iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); IAttributeState playerAttribute = iPlayerState.GetResultAttribute(); PhysicDefenseFactor physicDefenseFactor = new PhysicDefenseFactor()//物理防御系数 { CoefficientRatioReducingDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicDefenseToHurtRateRatio, ImmunityInjury = iPlayerState.SelfRoleOfRaceInfoStruct.physicQuickToHurtExemptRatio }; MagicDefenseFactor magicDefenseFactor = new MagicDefenseFactor() //魔法防御系数 { CoefficientRatioReducingDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.magicDefenseToHurtRateRatio }; CalculateHurt.Result calculateHurtResult = CalculateHurt.Calculate(attackHurtStruct, playerAttribute, physicDefenseFactor, magicDefenseFactor); if (calculateHurtResult.hurt >= 0) { if (calculateHurtResult.hurt != 0) { //减血(因为这里是整合的属性,必须在外部将自身血量减去) iPlayerState.HP -= calculateHurtResult.hurt; //终端咏唱 ISkillState iSkillState = GameState.Instance.GetEntity <ISkillState>(); iSkillState.GetHitToSkillState(); //手柄震动 iPlayerState.SetVibration(0.1f, 0.7f, 0.7f); } //显示伤害 base.ShowHurt(calculateHurtResult, iPlayerState.PlayerObj); } return(calculateHurtResult); }