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); }
public void PlayBulletDropEffect(IPlayerWeaponState playerState) { var player = playerState.Owner as PlayerEntity; if (null == player) { Logger.Error("player state owner is not player or null !"); return; } var appearance = player.appearanceInterface.Appearance; var characterBone = player.characterBoneInterface.CharacterBone; var owner = player.entityKey.Value; var ejectTrans = characterBone.GetLocation(SpecialLocation.EjectionLocation, appearance.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != ejectTrans) { ClientEffectFactory.CreateBulletDrop(_context, _idGenerator, owner, ejectTrans.position, playerState.ViewYaw, playerState.ViewPitch, _config.BulletDrop); } else { Logger.Error("Get ejectionLocation location failed"); } }
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); }
private void CreateBulletEffect(WeaponAttackProxy attackProxy, ICharacterBone bones) { if (DefaultCfg.BulletFly < 1 || attackProxy.IsAiming) { return; } var muzzleTrans = bones.GetLocation(SpecialLocation.MuzzleEffectPosition, attackProxy.Appearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (!muzzleTrans) { return; } var efcCommonCfg = SingletonManager.Get <ClientEffectCommonConfigManager>() .GetConfigByType(EEffectObjectClassify.BulletFly); foreach (var bulletData in attackProxy.Owner.BulletList) { var origin = bulletData.ViewPosition; var velocity = efcCommonCfg.Velocity * bulletData.Dir; Vector3 target = origin + velocity * 1.0f; Vector3 bulletEffectVelocity = (target - bulletData.EmitPosition) / 1.0f; ClientEffectFactory.CreateBulletFlyEffect(attackProxy.Owner.Owner, muzzleTrans.position, muzzleTrans.rotation, bulletEffectVelocity, DefaultCfg.BulletFly, efcCommonCfg.Delay); } }
protected virtual void CreateFireRelatedEffect(WeaponAttackProxy attackProxy, ICharacterBone bones) { if (DefaultCfg.Spark < 1) { return; } var muzzleTrans = bones.GetLocation(SpecialLocation.MuzzleEffectPosition, attackProxy.Appearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); var ejectTrans = bones.GetLocation(SpecialLocation.EjectionLocation, attackProxy.Appearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); bool hasMuzzleEfc = muzzleTrans && DefaultCfg.Spark > 0 && attackProxy.Owner.HeldWeaponAgent.HasSpark; bool hasBulletDrop = ejectTrans && DefaultCfg.BulletDrop > 0; if (hasMuzzleEfc) { ClientEffectFactory.CreateMuzzleSparkEffct(muzzleTrans.position, attackProxy.Orientation.Yaw, attackProxy.Orientation.Pitch, DefaultCfg.Spark, muzzleTrans); } if (hasBulletDrop) { ClientEffectFactory.CreateBulletDrop(ejectTrans.position, attackProxy.Orientation.Yaw, attackProxy.Orientation.Pitch, DefaultCfg.BulletDrop, attackProxy.WeaponConfigAssy.S_Id, attackProxy.AudioController.GetFootMatType()); } }
public void OnHitVehicle(PlayerEntity srcPlayer, VehicleEntity targetVehicle, IBulletEntity bulletEntity, RaycastHit hit) { if (srcPlayer.gamePlay.IsDead()) { return; } Collider collider = hit.collider; VehiclePartIndex partIndex; var hitBoxFactor = VehicleEntityUtility.GetHitFactor(targetVehicle, collider, out partIndex); var totalDamage = GetBulletDamage(bulletEntity, hitBoxFactor, Vector3.Distance(hit.point, bulletEntity.GunEmitPosition)); var gameData = targetVehicle.GetGameData(); gameData.DecreaseHp(partIndex, totalDamage, srcPlayer.entityKey.Value); srcPlayer.statisticsData.Statistics.TotalDamage += totalDamage; bulletEntity.IsValid = false; srcPlayer.statisticsData.Statistics.ShootingSuccCount++; _logger.DebugFormat("bullet from {0} hit vehicle {1}, part {2}", bulletEntity.OwnerEntityKey, targetVehicle.entityKey.Value, collider.name); ClientEffectFactory.AddHitVehicleEffectEvent(srcPlayer, targetVehicle.entityKey.Value, hit.point, hit.point - targetVehicle.position.Value, hit.normal); }
public void OnHitPlayer(Contexts contexts, PlayerEntity srcPlayer, PlayerEntity targetPlayer, IBulletEntity bulletEntity, RaycastHit hit, Vector3 targetPlayerPostion, int cmdSeq) { if (srcPlayer.gamePlay.IsDead()) { return; } Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); _logger.DebugFormat("OnHitPlayer in {0}", part); float hitboxFactor = bulletEntity.GetDamageFactor(part); float totalDamage = GetBulletDamage(bulletEntity, hitboxFactor, Vector3.Distance(hit.point, bulletEntity.GunEmitPosition)); bulletEntity.IsValid = false; //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (targetPlayer.hasStateInterface && targetPlayer.stateInterface.State.CanBeenHit()) // { // targetPlayer.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(srcPlayer, targetPlayer.entityKey.Value, GeneraterUniqueHitId(srcPlayer, cmdSeq), contexts.session.currentTimeObject.CurrentTime); ClientEffectFactory.AddHitPlayerEffectEvent(srcPlayer, targetPlayer.entityKey.Value, hit.point, hit.point - targetPlayer.position.Value); _logger.InfoFormat( "bullet from {0} hit player {1}, part {2}, hitbox factor {3}, result damage {4}", bulletEntity.OwnerEntityKey, targetPlayer.entityKey.Value, collider, hitboxFactor, totalDamage); if (!targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Dead)) { //有效命中 if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) { srcPlayer.statisticsData.Statistics.ShootingPlayerCount++; } srcPlayer.statisticsData.Statistics.ShootingSuccCount++; } BulletPlayerUtility.ProcessPlayerHealthDamage( contexts, _damager, srcPlayer, targetPlayer, new PlayerDamageInfo(totalDamage, (int)EUIDeadType.Weapon, (int)part, bulletEntity.WeaponId, bulletEntity.IsOverWall), _damageInfoCollector); }
public override void DoEventClient(Entitas.IContexts contexts, IEntity entity, IEvent e) { var playerEntity = entity as PlayerEntity; Contexts c = contexts as Contexts; HitPlayerEvent ev = e as HitPlayerEvent; if (playerEntity != null) { ClientEffectFactory.CreateHitPlayerEffect(c, playerEntity.entityKey.Value, ev); } }
public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (!src.WeaponController().IsHeldSlotEmpty) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood); } } }
private void DoHitPlayer(PlayerEntity srcPlayer, IBulletEntityAgent bulletEntityAgent, RaycastHit hit) { Collider collider = hit.collider; bulletEntityAgent.SetAnimationAndColliderText(hitTargetPlayer.networkAnimator.ToStringExt(), GetCollidersDebugDatas(hitTargetPlayer)); EBodyPart part = BulletPlayerUtil.GetBodyPartByHitBoxName(collider); BulletHitHandler._logger.InfoFormat("[Hit{0}]HitPlayer in {1}", cmdSeq, part); float hitboxFactor = bulletEntityAgent.GetDamageFactor(part); float totalDamage = GetBulletDamage(bulletEntityAgent, hitboxFactor, Vector3.Distance(hit.point, bulletEntityAgent.GunEmitPosition)); bulletEntityAgent.IsValid = false; //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (hitTargetPlayer.hasStateInterface && hitTargetPlayer.stateInterface.State.CanBeenHit()) // { // hitTargetPlayer.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(srcPlayer, hitTargetPlayer, AttackUtil.GeneraterUniqueHitId(srcPlayer, cmdSeq), contexts.session.currentTimeObject.CurrentTime); //添加假红统计 if (hitTargetPlayer.gamePlay.IsAlive()) { srcPlayer.StatisticsController().AddShootPlayer(cmdSeq, bulletEntityAgent, hit.point, hitTargetPlayer.entityKey.Value, hitTargetPlayer.position.Value, part, totalDamage); } ClientEffectFactory.AddHitPlayerEffectEvent(srcPlayer, hitTargetPlayer.entityKey.Value, hit.point, (int)EAudioUniqueId.BulletHit, part); BulletHitHandler._logger.InfoFormat("[Hit{5}]bullet from {0} hit player {1}, part {2}, hitbox factor {3}, result damage {4}", bulletEntityAgent.OwnerEntityKey, hitTargetPlayer.entityKey.Value, collider, hitboxFactor, totalDamage, cmdSeq); if (!hitTargetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Dead)) { //有效命中 if (hitTargetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) { srcPlayer.statisticsData.Statistics.ShootingPlayerCount++; } srcPlayer.statisticsData.Statistics.ShootingSuccCount++; } BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, damager, srcPlayer, hitTargetPlayer, new PlayerDamageInfo(totalDamage, (int)EUIDeadType.Weapon, (int)part, bulletEntityAgent.WeaponId, bulletEntityAgent.IsOverWall, false, false, bulletEntityAgent.HitPoint, bulletEntityAgent.Velocity)); DebugUtil.AppendShootText(cmdSeq, "[HitPlayer]hitPoint:{0},collider:{1},totalDamage:{2},part:{3}", hit.point, hit.collider, totalDamage, part); }
public void OnHitEnvrionment(PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { if (!src.weaponLogic.Weapon.EmptyHand) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood); } } }
/// <summary> /// </summary> /// <param name="contexts"></param> /// <param name="entity"></param> /// <param name="e"></param> public override void DoEventClient(IContexts contexts, IEntity entity, IEvent e) { FireEvent evt = e as FireEvent; if (evt != null) { var effectCfg = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(evt.weaponId) .S_EffectConfig as DefaultWeaponEffectConfig; if (effectCfg == null) { return; } Contexts ctx = contexts as Contexts; PlayerEntity player = ctx.player.GetEntityWithEntityKey(evt.owner); if (evt.fireEffectType != FireEvent.FireEffectType.EnjectOnly) { var muzzleTrans = player.characterBoneInterface.CharacterBone.GetLocation(SpecialLocation.MuzzleEffectPosition, CharacterView.ThirdPerson); if (muzzleTrans) { ClientEffectFactory.CreateMuzzleSparkEffct(muzzleTrans.position, evt.pitch, evt.yaw, effectCfg.Spark, muzzleTrans); } } if (evt.fireEffectType != FireEvent.FireEffectType.MuzzleOnly) { var ejectTrans = player.characterBoneInterface.CharacterBone.GetLocation(SpecialLocation.EjectionLocation, CharacterView.ThirdPerson); if (ejectTrans) { ClientEffectFactory.CreateBulletDrop(ejectTrans.position, evt.yaw, evt.pitch, effectCfg.BulletDrop, evt.weaponId, AudioGrp_FootMatType.Concrete); } } // var weaponGo = (entity as PlayerEntity).appearanceInterface.Appearance.GetWeaponP1InHand(); // GameAudioMedia.PlayWeaponFireAudio(evt.fireWeaponId, evt.audioFirePos, (AudioGrp_ShotMode)evt.audioFireMode); } // GameAudioMedium.ProcessWeaponAudio(playerEntity,allContexts,(item)=>item.Fire); // if (playerEntity.appearanceInterface.Appearance.IsFirstPerson) // { // } // else // { //// GameAudioMedium.PerformOnGunFire(); // } }
private void PlayOneEffect(ThrowingEntity throwing, int effectId, Vector3 effectPos, bool isBomb) { var entityIdGenerator = _contexts.session.commonSession.EntityIdGenerator; EClientEffectType effectType = EClientEffectType.GrenadeExplosion; int effectTime = _bombEffectTime; var bombAudioId = Core.EAudioUniqueId.GrenadeExplosion; if (isBomb) { //爆炸特效类型 switch ((EWeaponSubType)throwing.throwingData.WeaponSubType) { case EWeaponSubType.Grenade: effectType = EClientEffectType.GrenadeExplosion; break; case EWeaponSubType.FlashBomb: effectType = EClientEffectType.FlashBomb; bombAudioId = Core.EAudioUniqueId.FlashBombExplosion; break; case EWeaponSubType.FogBomb: effectType = EClientEffectType.FogBomb; bombAudioId = Core.EAudioUniqueId.FoggyBombExplosion; effectTime = _fogBombEffectTime; break; case EWeaponSubType.BurnBomb: effectType = EClientEffectType.BurnBomb; break; } } else { bombAudioId = EAudioUniqueId.None; } if (effectId > 0) { float effectYaw = throwing.throwingData.IsFly ? 0 : 1; var effectEntity = ClientEffectFactory.CreateGrenadeExplosionEffect(_contexts.clientEffect, entityIdGenerator, throwing.ownerId.Value, effectPos, effectYaw, 0, effectId, effectTime, effectType); if (effectEntity.hasAudio) { effectEntity.RemoveAudio(); } effectEntity.AddAudio((int)AudioClientEffectType.ThrowExplosion); effectEntity.audio.AudioClientEffectArg1 = (int)bombAudioId; } }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { int serverTime = room.RoomContexts.session.currentTimeObject.CurrentTime; ClientEffectFactory.CreateSprayPaint(room.RoomContexts.clientEffect, room.RoomContexts.session.commonSession.EntityIdGenerator, new Vector3(message.Fs[0], message.Fs[1], message.Fs[2]), new Vector3(message.Fs[3], message.Fs[4], message.Fs[5]), 1, new Vector3(message.Fs[6], message.Fs[7], message.Fs[8]), XmlConfig.ESprayPrintType.TypeBounds_1, message.Ins[0], message.Ins[1]); player.playerSpray.mLastCreateTime = (float)serverTime; }
public override void DoEventClient(Entitas.IContexts contexts, IEntity entity, IEvent e) { var playerEntity = entity as PlayerEntity; Contexts c = contexts as Contexts; HitEnvironmentEvent ev = e as HitEnvironmentEvent; if (playerEntity != null) { ClientEffectFactory.CreateHitEnvironmentEffect(c.clientEffect, c.session.commonSession.EntityIdGenerator, ev.HitPoint, ev.Offset, playerEntity.entityKey.Value, ev.EnvironmentType); } }
public void OnHitPlayer(PlayerEntity srcPlayer, PlayerEntity targetPlayer, IBulletEntity bulletEntity, RaycastHit hit, UnityEngine.Vector3 targetPlayerPostion) { Collider collider = hit.collider; EBodyPart part = BulletPlayerUtility.GetBodyPartByHitBoxName(collider); _logger.DebugFormat("OnHitPlayer in {0}", part); float hitboxFactor = bulletEntity.GetDamageFactor(part); float totalDamage = GetBulletDamage(bulletEntity, hitboxFactor); bulletEntity.IsValid = false; ClientEffectFactory.AddHitPlayerEffectEvent(srcPlayer, targetPlayer.entityKey.Value, hit.point, hit.point - targetPlayer.position.Value); if (targetPlayer.hasStateInterface && targetPlayer.stateInterface.State.CanBeenHit()) { targetPlayer.stateInterface.State.BeenHit(); } _logger.DebugFormat( "bullet from {0} hit player {1}, part {2}, hitbox factor {3}, result damage {4}", bulletEntity.OwnerEntityKey, targetPlayer.entityKey.Value, collider, hitboxFactor, totalDamage); if (!targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Dead)) { //有效命中 if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) { srcPlayer.statisticsData.Statistics.ShootingPlayerCount++; } srcPlayer.statisticsData.Statistics.ShootingSuccCount++; } BulletPlayerUtility.ProcessPlayerHealthDamage( _damager, srcPlayer, targetPlayer, new PlayerDamageInfo(totalDamage, (int)EUIDeadType.Weapon, (int)part, bulletEntity.WeaponId, bulletEntity.IsOverWall), _damageInfoCollector); }
public void OnHitVehicle(Contexts contexts, PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { VehiclePartIndex partIndex; var baseDamage = GetVehicleFactor(hit, target, out partIndex) * GetBaseDamage(attackInfo, config); var gameData = target.GetGameData(); gameData.DecreaseHp(partIndex, baseDamage); if (!src.WeaponController().IsHeldSlotEmpty) { RaycastHit effectHit; if (TryGetEffectShowHit(src, out effectHit, config.Range)) { ClientEffectFactory.AddHitVehicleEffectEvent(src, target.entityKey.Value, effectHit.point, effectHit.point - target.position.Value, effectHit.normal); } } }
public void PlayPullBoltEffect(PlayerWeaponController controller) { if (null == controller) { Logger.Error("player state owner is not player or null !"); return; } var effectPos = PlayerEntityUtility.GetThrowingEmitPosition(controller); float effectYaw = (controller.RelatedOrient.Yaw + 90) % 360; float effectPitch = controller.RelatedOrient.Pitch; int effectId = 32; int effectTime = 3000; ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator, controller.Owner, effectPos, effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt); }
private void CreatePullBoltEffect(PlayerWeaponController controller) { if (null == controller) { Logger.Error("player state owner is not player or null !"); return; } var effectPos = SingletonManager.Get <ThrowAmmunitionCalculator>().GetFireViewPosition(controller); float effectYaw = (controller.RelatedOrientation.Yaw + 90) % 360; float effectPitch = controller.RelatedOrientation.Pitch; int effectId = 32; int effectTime = 3000; ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator, controller.Owner, effectPos, effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt); }
public void PlayMuzzleSparkEffect(PlayerWeaponController controller) { if (null == controller) { Logger.Error("player state owner is not player or null !"); return; } var muzzleTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != muzzleTrans) { ClientEffectFactory.CreateMuzzleSparkEffct(_context, _idGenerator, controller.Owner, muzzleTrans, controller.RelatedOrient.Pitch, controller.RelatedOrient.Yaw, _config.Spark); } else { Logger.Error("Get muzzleLocation location failed"); } }
public void PlayBulletDropEffect(PlayerWeaponController controller) { if (null == controller) { Logger.Error("player state owner is not player or null !"); return; } var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.EjectionLocation, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != ejectTrans) { ClientEffectFactory.CreateBulletDrop(_context, _idGenerator, controller.Owner, ejectTrans.position, controller.RelatedOrient.Yaw, controller.RelatedOrient.Pitch, _config.BulletDrop); } else { Logger.Error("Get ejectionLocation location failed"); } }
public void OnHitEnvrionment(Contexts contexts, PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config) { var heldConfigId = src.WeaponController().HeldConfigId; RaycastHit effectHit; bool showAttackEffect = (MeleeHitUtil.CanMeleeAttackShowHit(src, out effectHit, config.Range)); var collider = effectHit.collider != null ? effectHit.collider : hit.collider; FracturedHittable fracturedHittable = collider.GetComponent <FracturedHittable>(); FracturedAbstractChunk fracturedChunk = HitFracturedHandler.HitFracturedObj(src, effectHit, fracturedHittable); var hasHole = fracturedChunk == null || (fracturedChunk.HasBulletHole && !fracturedChunk.IsBroken()); if (showAttackEffect && hasHole) { int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(heldConfigId).HitList.Body; ClientEffectFactory.AdHitEnvironmentEffectEvent(src, effectHit.point, effectHit.normal, EEnvironmentType.Wood, audioId, 0, heldConfigId != WeaponUtil.EmptyHandId); } }
private void CreateMuzzleSparkEffect(PlayerWeaponController controller) { if (null == controller || DefaultCfg.Spark < 1) { return; } var muzzleTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != muzzleTrans) { // Logger.Info("CreateMuzzleSparkEffct Once"); ClientEffectFactory.CreateMuzzleSparkEffct(_context, _idGenerator, controller.Owner, muzzleTrans, controller.RelatedOrientation.Pitch, controller.RelatedOrientation.Yaw, DefaultCfg.Spark); } else { Logger.Error("Get muzzleLocation location failed"); } }
public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq) { EBodyPart part = BulletPlayerUtil.GetBodyPartByHitBoxName(hit.collider); var baseDamage = MeleeHitUtil.GetPlayerFactor(hit, config, part) * MeleeHitUtil.GetBaseDamage(attackInfo, config); if (src.hasStatisticsData) { src.statisticsData.Statistics.AttackType = (int)attackInfo.AttackType; } //有效命中 /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive)) * { * src.statisticsData.Statistics.ShootingPlayerCount++; * }*/ var playerWeaponId = src.WeaponController().HeldConfigId; WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(playerWeaponId); EUIDeadType euiDeadType = (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand) ? EUIDeadType.Unarmed : EUIDeadType.Weapon; BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)euiDeadType, (int)part, src.WeaponController().HeldWeaponAgent.ConfigId, false, false, false, hit.point, target.position.Value - src.position.Value)); // Logger.InfoFormat("[Hit] process damage sucess,dvalue:{0}", baseDamage); //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端 // if (target.hasStateInterface && target.stateInterface.State.CanBeenHit()) // { // target.stateInterface.State.BeenHit(); // } ClientEffectFactory.AddBeenHitEvent(src, target, AttackUtil.GeneraterUniqueHitId(src, seq), contexts.session.currentTimeObject.CurrentTime); int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(playerWeaponId).HitList.Body; ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, audioId, part); }
public void PlayPullBoltEffect(IPlayerWeaponState playerState) { var player = playerState.Owner as PlayerEntity; if (null == player) { Logger.Error("player state owner is not player or null !"); return; } var owner = player.entityKey.Value; var effectPos = PlayerEntityUtility.GetThrowingEmitPosition(player); float effectYaw = (playerState.ViewYaw + 90) % 360; float effectPitch = playerState.ViewPitch; int effectId = 32; int effectTime = 3000; ClientEffectFactory.CreateGrenadeExplosionEffect(_context, _idGenerator, owner, effectPos, effectYaw, effectPitch, effectId, effectTime, EClientEffectType.PullBolt); }
private void CreateBulletDropEffect(PlayerWeaponController controller) { if (DefaultCfg.BulletDrop < 1) { return; } //For test // var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.MuzzleEffectPosition, // controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); var ejectTrans = controller.RelatedBones.GetLocation(SpecialLocation.EjectionLocation, controller.RelatedAppearence.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != ejectTrans) { ClientEffectFactory.CreateBulletDrop(_context, _idGenerator, controller.Owner, ejectTrans.position, controller.RelatedOrientation.Yaw, controller.RelatedOrientation.Pitch, DefaultCfg.BulletDrop, controller.HeldConfigId, AudioGrp_FootMatType.Concrete); } else { Logger.Error("Get ejectionLocation location failed"); } }
private void PlayOneEffect(ThrowingEntity throwing, int effectId, Vector3 effectPos, bool isBomb) { var entityIdGenerator = _contexts.session.commonSession.EntityIdGenerator; EClientEffectType effectType = EClientEffectType.GrenadeExplosion; int effectTime = _bombEffectTime; if (isBomb) { //爆炸特效类型 switch ((EWeaponSubType)throwing.throwingData.WeaponSubType) { case EWeaponSubType.Grenade: effectType = EClientEffectType.GrenadeExplosion; break; case EWeaponSubType.FlashBomb: effectType = EClientEffectType.FlashBomb; break; case EWeaponSubType.FogBomb: effectType = EClientEffectType.FogBomb; effectTime = _fogBombEffectTime; break; case EWeaponSubType.BurnBomb: effectType = EClientEffectType.BurnBomb; break; } } if (effectId > 0) { float effectYaw = throwing.throwingData.IsFly ? 0 : 1; ClientEffectFactory.CreateGrenadeExplosionEffect(_contexts.clientEffect, entityIdGenerator, throwing.ownerId.Value, effectPos, effectYaw, 0, effectId, effectTime, effectType); } }
public void PlayMuzzleSparkEffect(IPlayerWeaponState playerState) { var player = playerState.Owner as PlayerEntity; if (null == player) { Logger.Error("player state owner is not player or null !"); return; } var appearance = player.appearanceInterface.Appearance; var characterBone = player.characterBoneInterface.CharacterBone; var owner = player.entityKey.Value; var muzzleTrans = characterBone.GetLocation(SpecialLocation.MuzzleEffectPosition, appearance.IsFirstPerson ? CharacterView.FirstPerson : CharacterView.ThirdPerson); if (null != muzzleTrans) { ClientEffectFactory.CreateMuzzleSparkEffct(_context, _idGenerator, owner, muzzleTrans, playerState.ViewPitch, playerState.ViewYaw, _config.Spark); } else { Logger.Error("Get muzzleLocation location failed"); } }
private void OnHitEnvironment(PlayerEntity srcPlayer, IBulletEntity bulletEntity, RaycastHit hit) { if (srcPlayer.gamePlay.IsDead()) { _logger.InfoFormat("[hit] environment dead"); return; } ThicknessInfo thicknessInfo; EnvironmentInfo info = BulletEnvironmentUtility.GetEnvironmentInfoByHitBoxName(hit, bulletEntity.Velocity, out thicknessInfo); float damageDecayFactor = _environmentTypeConfigManager.GetDamageDecayFactorByEnvironmentType(info.Type); float energyDecayFactor = _environmentTypeConfigManager.GetEnergyDecayFactorByEnvironmentType(info.Type); float oldThickNess = bulletEntity.PenetrableThickness; float oldDamage = bulletEntity.BaseDamage; bulletEntity.BaseDamage *= damageDecayFactor; bulletEntity.PenetrableThickness = bulletEntity.PenetrableThickness * energyDecayFactor - info.Thickness; bulletEntity.PenetrableLayerCount -= info.LayerCount; if (bulletEntity.PenetrableLayerCount <= 0 || bulletEntity.PenetrableThickness <= 0) { bulletEntity.IsValid = false; } else { bulletEntity.AddPenetrateInfo(info.Type); } EBulletCaliber caliber = bulletEntity.Caliber; //根据口径 var collider = hit.collider; var fracturedHittable = collider.GetComponent <FracturedHittable>(); if (fracturedHittable != null) { EntityKey?hittedObjectKey = null; var script = fracturedHittable.gameObject.GetComponent <FracturedHittable>(); if (script == null) { return; } var objtype = MapObjectUtility.GetGameObjType(script.Owner); if (objtype < 0) { return; } var rawObjKey = MapObjectUtility.GetGameObjId(script.Owner); if (rawObjKey != Int32.MinValue && !SharedConfig.IsServer && MapObjectUtility.GetMapObjectByGameObject(script.Owner) == null) { MapObjectUtility.SendCreateMapObjMsg(objtype, rawObjKey); _logger.InfoFormat("CreateMapObjEvent: type:{0}, obj:{1}, num:{2}", (ETriggerObjectType)objtype, fracturedHittable.gameObject, srcPlayer.uploadEvents.Events.Events[EEventType.CreateMapObj].Count); } FracturedAbstractChunk fracturedChunk = null; fracturedChunk = fracturedHittable.Hit(hit.point, hit.normal); if (fracturedHittable.HasBulletHole && fracturedChunk != null) { ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator, hit.point, srcPlayer.entityKey.Value, hittedObjectKey.Value, fracturedChunk.ChunkId, hit.point - fracturedChunk.transform.position, hit.normal); } srcPlayer.statisticsData.Statistics.ShootingSuccCount++; if (fracturedHittable.HasBulletHole && fracturedChunk != null && bulletEntity.IsValid && thicknessInfo.Thickness > 0) { ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator, thicknessInfo.OutPoint, srcPlayer.entityKey.Value, hittedObjectKey.Value, fracturedChunk.ChunkId, thicknessInfo.OutPoint - fracturedChunk.transform.position, thicknessInfo.Normal); } } else { ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, hit.point, hit.normal, info.Type); if (bulletEntity.IsValid && thicknessInfo.Thickness > 0) { ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, thicknessInfo.OutPoint, thicknessInfo.Normal, info.Type); } } _logger.InfoFormat("[hit]bullet from {0} hit environment {1}, collier {2}, base damage {3}->{4}, penetrable thick {5}->{6}, env ({7}), remain layer {8}", bulletEntity.OwnerEntityKey, hit.point, hit.collider.name, oldDamage, bulletEntity.BaseDamage, oldThickNess, bulletEntity.PenetrableThickness, info, bulletEntity.PenetrableLayerCount); }
private void DoHitEnvironment(PlayerEntity srcPlayer, IBulletEntityAgent bulletEntityAgent, RaycastHit hit) { if (srcPlayer.gamePlay.IsDead()) { BulletHitHandler._logger.InfoFormat("hit environment dead"); return; } subProfilerInfo.BeginProfileOnlyEnableProfile(); // BulletHitHandler._logger.InfoFormat("[Hit{0}] OwnerEntityKey {1}, point {2},collider:{3}", cmdSeq, // bulletEntityAgent.OwnerEntityKey, hit.point, hit.collider.name); ThicknessInfo thicknessInfo; /*profiler:热点项 考虑材质检测方式调整 * --GetColliderThickness * -- GetMaterialByHit * --GetEnvironmentTypeByMatName */ EnvironmentInfo info = BulletEnvironmentUtil.GetEnvironmentInfoByHitBoxName(hit, bulletEntityAgent.Velocity, out thicknessInfo); float damageDecayFactor = SingletonManager.Get <EnvironmentTypeConfigManager>().GetDamageDecayFactorByEnvironmentType(info.Type); float energyDecayFactor = SingletonManager.Get <EnvironmentTypeConfigManager>().GetEnergyDecayFactorByEnvironmentType(info.Type); // float oldThickNess = bulletEntityAgent.PenetrableThickness; // float oldDamage = bulletEntityAgent.BaseDamage; bulletEntityAgent.BaseDamage *= damageDecayFactor; bulletEntityAgent.PenetrableThickness = bulletEntityAgent.PenetrableThickness * energyDecayFactor - info.Thickness; bulletEntityAgent.PenetrableLayerCount -= info.LayerCount; if (bulletEntityAgent.PenetrableLayerCount <= 0 || bulletEntityAgent.PenetrableThickness <= 0) { //profiler:editor下热点项 -- Entity.AddComponent bulletEntityAgent.IsValid = false; } else { bulletEntityAgent.AddPenetrateInfo(info.Type); } subProfilerInfo.EndProfileOnlyEnableProfile(); var collider = hit.collider; var fracturedHittable = collider.GetComponent <FracturedHittable>(); if (fracturedHittable != null) { var fracturedChunk = HitFracturedHandler.HitFracturedObj(srcPlayer, hit, fracturedHittable); if (fracturedHittable.HasBulletHole && fracturedChunk != null) { // ClientEffectFactory.CreateHitFracturedChunkEffect( hit.point, srcPlayer.entityKey.Value, fracturedHittable.transform, fracturedChunk.ChunkId,hit.point - fracturedChunk.transform.position, hit.normal,info.Type); if (fracturedChunk.IsBroken()) { ChunkEffectBehavior.CleanupChunkEffectBehaviors(fracturedChunk.ChunkId); } else { ClientEffectFactory.CreateHitEnvironmentEffect(hit.point, hit.normal, info.Type, (int)EAudioUniqueId.BulletHit, true, fracturedChunk.ChunkId, fracturedChunk.transform); } } srcPlayer.statisticsData.Statistics.ShootingSuccCount++; if (fracturedHittable.HasBulletHole && fracturedChunk != null && bulletEntityAgent.IsValid && thicknessInfo.Thickness > 0) { ClientEffectFactory.CreateHitEnvironmentEffect(hit.point, hit.normal, info.Type, (int)EAudioUniqueId.BulletHit, true, fracturedChunk.ChunkId, fracturedChunk.transform); // ClientEffectFactory.CreateHitFracturedChunkEffect(_contexts.clientEffect, _entityIdGenerator, // thicknessInfo.OutPoint, srcPlayer.entityKey.Value, hittedObjectKey, fracturedChunk.ChunkId, // thicknessInfo.OutPoint - fracturedChunk.transform.position, thicknessInfo.Normal); } } else { //profiler:热点项 -- EventInfos.Instance.Allocate(EEventType.HitEnvironment, false); ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, hit.point, hit.normal, info.Type, (int)EAudioUniqueId.BulletHit); if (bulletEntityAgent.IsValid && thicknessInfo.Thickness > 0) { ClientEffectFactory.AdHitEnvironmentEffectEvent(srcPlayer, thicknessInfo.OutPoint, thicknessInfo.Normal, info.Type, (int)EAudioUniqueId.BulletHit); } } // BulletHitHandler._logger.InfoFormat( // "bullet from {0} hit environment {1}, collier {2}, base damage {3}->{4}, penetrable thick {5}->{6}, env ({7}), remain layer {8}", // bulletEntityAgent.OwnerEntityKey, hit.point, hit.collider.name, oldDamage, bulletEntityAgent.BaseDamage, // oldThickNess, bulletEntityAgent.PenetrableThickness, info, bulletEntityAgent.PenetrableLayerCount); }