Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }