Beispiel #1
0
        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);
        }
Beispiel #2
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);
        }
        public static void DoDamageToAllPassgers(Contexts contexts, VehicleEntity vehicle, float damage, EUIDeadType deadType, PlayerEntity sourcePlayer = null, bool isDamagePercent = false, bool sendToServer = false)
        {
            var seats        = vehicle.vehicleSeat;
            var orignalDamge = damage;

            for (int seatId = 0; seatId < VehicleSeatComponent.MaxSeatCount; ++seatId)
            {
                EntityKey entityKey;
                if (seats.GetEntityKey(seatId, out entityKey))
                {
                    var player = contexts.player.GetEntityWithEntityKey(entityKey);
                    if (player != null)
                    {
                        if (sourcePlayer == null && deadType == EUIDeadType.VehicleHit)
                        {
                            var lastDriveEntityKey = seats.LastDriverEntityKey;
                            sourcePlayer = contexts.player.GetEntityWithEntityKey(lastDriveEntityKey);
                        }

                        //the case in which the damage is from self
                        if (sourcePlayer == player)
                        {
                            sourcePlayer = null;
                        }

                        if (isDamagePercent)
                        {
                            var gamePlay = player.gamePlay;
                            damage = orignalDamge * gamePlay.MaxHp;
                        }

                        BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, sourcePlayer, player, new PlayerDamageInfo(damage, (int)deadType, (int)EBodyPart.Chest, vehicle.vehicleAssetInfo.Id));
                        if (sendToServer)
                        {
                            SendDamageToServer(vehicle, player.entityKey.Value, damage);
                        }
                    }
                }
            }
        }
 public void OnPlayerDamage(PlayerEntity sourcePlayer, PlayerEntity targetPlayer, PlayerDamageInfo damage)
 {
     BulletPlayerUtility.ProcessPlayerHealthDamage(_contexts, _damager, sourcePlayer, targetPlayer, damage);
 }
 public static void DoPlayerDamage(Contexts contexts, PlayerEntity sourcePlayer, PlayerEntity targetPlayer, float damage, EUIDeadType hitType = EUIDeadType.VehicleHit, EBodyPart hitPart = EBodyPart.Chest, int weaponId = 0)
 {
     BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, sourcePlayer, targetPlayer, new PlayerDamageInfo(damage, (int)hitType, (int)hitPart, weaponId));
 }