public void OnHitPlayer(PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var baseDamage = GetPlayerFactor(hit, config) * GetBaseDamage(attackInfo, config); Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); //有效命中 if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) { src.statisticsData.Statistics.ShootingPlayerCount++; } NewWeaponConfigItem newConfig = SingletonManager.Get <WeaponConfigManager>().GetConfigById(src.weaponLogicInfo.WeaponId); if (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) { BulletPlayerUtility.ProcessPlayerHealthDamage(_damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Unarmed, (int)part, 0), _damageInfoCollector); } else { BulletPlayerUtility.ProcessPlayerHealthDamage(_damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Weapon, (int)part, src.weaponLogicInfo.WeaponId), _damageInfoCollector); } if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) { target.stateInterface.State.BeenHit(); } ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, hit.point - target.position.Value); }
public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq) { var baseDamage = GetPlayerFactor(hit, config) * GetBaseDamage(attackInfo, config); Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); //有效命中 /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) * { * src.statisticsData.Statistics.ShootingPlayerCount++; * }*/ WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(src.WeaponController().HeldWeaponAgent.ConfigId); if (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) { BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Unarmed, (int)part, 0), _damageInfoCollector); } else { BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Weapon, (int)part, src.WeaponController().HeldWeaponAgent.ConfigId), _damageInfoCollector); } //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) // { // target.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(src, target.entityKey.Value, BulletHitHandler.GeneraterUniqueHitId(src, seq), contexts.session.currentTimeObject.CurrentTime); ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, hit.point - target.position.Value); }
private float GetPlayerFactor(RaycastHit hit, MeleeFireLogicConfig config) { Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); var factor = 1f; for (int i = 0; i < config.DamageFactor.Length; i++) { if (config.DamageFactor[i].BodyPart == part) { factor = config.DamageFactor[i].Factor; break; } } return(factor); }