/// <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); }
/// <summary> /// 显示伤害 /// </summary> /// <param name="hurtResult"></param> /// <param name="targetObj"></param> public void ShowHurt(CalculateHurt.Result hurtResult, GameObject targetObj) { iGameState.ShowHurtFont = new HurtFontStruct() { Hurt = hurtResult.hurt, IsCrit = hurtResult.IsCrit, Offset = HurtFontOffset, TargetObj = targetObj }; }
/// <summary> /// 计算物理技能伤害 /// </summary> /// <param name="skillType">技能类型</param> /// <param name="weaponTypeByPlayerState">武器类型</param> /// <param name="physicsSkillStateStruct">物理技能数据</param> /// <param name="innerOrder">当前攻击的阶段</param> /// <param name="target">攻击的目标</param> private bool CalculatePhysicSkillHurt(EnumSkillType skillType, EnumWeaponTypeByPlayerState weaponTypeByPlayerState, PhysicsSkillStateStruct physicsSkillStateStruct, int innerOrder, GameObject target) { if (target == null) { return(true); } InteractiveAsMonster interactiveAsMonster = target.GetComponent <InteractiveAsMonster>(); if (interactiveAsMonster == null) { return(true); } IPlayerState iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); AttackHurtStruct attackHurtStruct = new AttackHurtStruct() { hurtTransferNum = 0, hurtType = EnumHurtType.PhysicSkill, attributeState = physicsSkillStateStruct.AttributeState, hurtFromObj = iPlayerState.PlayerObj, PhysicAttackFactor = new PhysicAttackFactor() { IncreaseRatioInjuryFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicAttackToDamageRateRatio, MinimumDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicQuickToMinDamageRatio } }; CalculateHurt.Result hurtResult = interactiveAsMonster.GiveAttackHurtStruct(attackHurtStruct); if (hurtResult.IsCrit || hurtResult.hurtRate > 0.2f) { iPlayerState.SetVibration(0.1f, 0.7f, 0.7f);//设置手柄震动 } //如果命中了则自身的动画造成0.1秒的延迟 IAnimatorState iAnimatorState = GameState.Instance.GetEntity <IAnimatorState>(); if (weaponTypeByPlayerState != EnumWeaponTypeByPlayerState.Arch) { iAnimatorState.PhysicHitMonsterAnimDelay = true; } //停止持续 iAnimatorState.SkillSustainable = false; //如果是冲锋则停止任务 switch (skillType) { case EnumSkillType.ZS03: runTaskStruct_Charge.StopTask(); break; } //设置命中声音 WeaponPhysicHit = (int)weaponTypeByPlayerState; //判断技能类型,有些紧只需要判断一次 switch (skillType) { case EnumSkillType.GJS03: case EnumSkillType.SSS03: case EnumSkillType.ZS03: return(false); default: return(true); } }
/// <summary> /// 计算物理普通攻击伤害 /// </summary> /// <param name="weaponTypeByPlayerState">武器类型</param> /// <param name="iAttribute">攻击时的状态数据</param> /// <param name="innerOrder">当前攻击的阶段</param> /// <param name="target">攻击的目标</param> private bool CalculateNormalActionHurt(EnumWeaponTypeByPlayerState weaponTypeByPlayerState, IAttributeState _iAttribute, int innerOrder, GameObject target) { if (target == null) { return(true); } InteractiveAsMonster interactiveAsMonster = target.GetComponent <InteractiveAsMonster>(); if (interactiveAsMonster == null) { return(true); } IPlayerState iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); IAttributeState iAttribute = ((AttributeStateAdditional)_iAttribute).Clone(); switch (weaponTypeByPlayerState) { case EnumWeaponTypeByPlayerState.SingleHandedSword: if (innerOrder == 3) { iAttribute.PhysicsAttacking *= 1.2f; } break; case EnumWeaponTypeByPlayerState.TwoHandedSword: if (innerOrder == 3) { iAttribute.PhysicsAttacking *= 0.7f; } break; case EnumWeaponTypeByPlayerState.Arch: if (innerOrder == 3) { iAttribute.PhysicsAttacking *= 2f; } break; } AttackHurtStruct attackHurtStruct = new AttackHurtStruct() { hurtTransferNum = 0, hurtType = EnumHurtType.NormalAction, attributeState = iAttribute, hurtFromObj = iPlayerState.PlayerObj, PhysicAttackFactor = new PhysicAttackFactor() { IncreaseRatioInjuryFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicAttackToDamageRateRatio, MinimumDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicQuickToMinDamageRatio } }; CalculateHurt.Result hurtResult = interactiveAsMonster.GiveAttackHurtStruct(attackHurtStruct); if (hurtResult.IsCrit || hurtResult.hurtRate > 0.2f) { iPlayerState.SetVibration(0.1f, 0.6f, 0.6f);//设置手柄震动 } //如果命中了则自身的动画造成0.1秒的延迟 IAnimatorState iAnimatorState = GameState.Instance.GetEntity <IAnimatorState>(); if (weaponTypeByPlayerState != EnumWeaponTypeByPlayerState.Arch) { iAnimatorState.PhysicHitMonsterAnimDelay = true; } //停止持续 iAnimatorState.SkillSustainable = false; //设置命中声音 WeaponPhysicHit = (int)weaponTypeByPlayerState; //判断武器类型 switch (weaponTypeByPlayerState)//根据武器类型判断是否还需要下次检测 { case EnumWeaponTypeByPlayerState.Arch: return(false); default: return(true); } }
/// <summary> /// 计算魔法组合技能的伤害 /// </summary> /// <param name="_iAttributeState">伤害计算时使用的属性</param> /// <param name="collisionHitCallbackStruct">碰撞到的对象</param> /// <param name="thisUsedMana">本次技能的耗魔值</param> /// <param name="statusLevelDataInfos">本次技能附加的特殊效果数组</param> /// <param name="skills">本次技能组合</param> /// <returns></returns> private bool CalculateCombineMagicHurt(IAttributeState _iAttributeState, CollisionHitCallbackStruct collisionHitCallbackStruct, float thisUsedMana, StatusDataInfo.StatusLevelDataInfo[] statusLevelDataInfos, EnumSkillType[] skills) { if (collisionHitCallbackStruct.targetObj == null) { return(false); } InteractiveAsMonster interactiveAsMonster = collisionHitCallbackStruct.targetObj.GetComponent <InteractiveAsMonster>(); if (interactiveAsMonster == null) { return(false); } IPlayerState iPlayerState = GameState.Instance.GetEntity <IPlayerState>(); IAttributeState iAttributeState = ((AttributeStateAdditional)_iAttributeState).Clone(); //根据技能设置平摊伤害 if (skills.Length >= 2) { switch (skills[1]) { case EnumSkillType.YSX01: //火元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 4; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 2.5f; break; } break; case EnumSkillType.YSX02: //水元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 1.8f; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 0.85f; break; } break; case EnumSkillType.YSX03: //土元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 1.4f; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 2.5f; break; } break; case EnumSkillType.YSX04: //风元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 4; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 4; break; } break; case EnumSkillType.SM06: //冰元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 1.2f; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 1.2f; break; } break; case EnumSkillType.SM07: //雷元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 5.5f; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 6; break; } break; case EnumSkillType.DSM03: //光元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 1; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 1; break; } break; case EnumSkillType.DSM04: //暗元素 switch (skills[0]) { case EnumSkillType.FS02: iAttributeState.BaseMagicDamage /= 1; break; case EnumSkillType.MFS05: iAttributeState.BaseMagicDamage /= 1; break; } break; } } AttackHurtStruct attackHurtStruct = new AttackHurtStruct() { hurtTransferNum = 0, hurtType = EnumHurtType.Magic, attributeState = iAttributeState, thisUsedMana = thisUsedMana, hurtFromObj = iPlayerState.PlayerObj, statusLevelDataInfos = statusLevelDataInfos, MagicAttackFactor = new MagicAttackFactor() { IncreaseRatioInjuryFactor = iPlayerState.SelfRoleOfRaceInfoStruct.magicAttackToDamageRateRatio } }; CalculateHurt.Result hurtResult = interactiveAsMonster.GiveAttackHurtStruct(attackHurtStruct); if (hurtResult.IsCrit || hurtResult.hurtRate > 0.2f) { iPlayerState.SetVibration(0.1f, 0.8f, 0.8f);//设置手柄震动 } //设置声音 if (skills.Length >= 2)//说明有二阶段技能 { MagicTypeHit = (int)skills[1]; } else { MagicTypeHit = (int)EnumSkillType.MagicCombinedLevel2Start; } return(true); }