예제 #1
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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public static void OnEnvironmentHit(PlayerContext playerContext, IPlayerDamager damager, IDamageInfoCollector damageInfoCollector)
        {
            if (!_active)
            {
                return;
            }

            var player = playerContext.flagSelfEntity;

            BulletPlayerUtility.ProcessPlayerHealthDamage(
                damager,
                player,
                player,
                new PlayerDamageInfo(10, (int)EUIDeadType.Weapon, (int)EBodyPart.Chest, player.weaponLogicInfo.WeaponId),
                damageInfoCollector);
        }