private void StartMeleeAttack(PlayerWeaponController controller, int attackTime, MeleeAttackInfo attackInfo,
                                      MeleeFireLogicConfig config)
        {
            controller.CreateSetMeleeAttackInfo(attackInfo, config);
            controller.CreateSetMeleeAttackInfoSync(attackTime);

            controller.AudioController.PlayMeleeAttackAudio(controller.HeldConfigId, (int)attackInfo.AttackType);
        }
예제 #2
0
 public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     if (entity.hasMeleeAttackInfo)
     {
         RelatedMeleeAttackInfo    = attackInfo;
         RelatedMeleeAttackInfoCfg = config;
     }
     else
     {
         entity.AddMeleeAttackInfo();
         RelatedMeleeAttackInfo    = attackInfo;
         RelatedMeleeAttackInfoCfg = config;
     }
 }
예제 #3
0
 public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     if (entity.hasMeleeAttackInfo)
     {
         entity.meleeAttackInfo.AttackInfo   = attackInfo;
         entity.meleeAttackInfo.AttackConfig = config;
     }
     else
     {
         entity.AddMeleeAttackInfo();
         entity.meleeAttackInfo.AttackInfo   = attackInfo;
         entity.meleeAttackInfo.AttackConfig = config;
     }
 }
예제 #4
0
        public static float GetPlayerFactor(RaycastHit hit, MeleeFireLogicConfig config, EBodyPart part)
        {
            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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        public void OnHitVehicle(Contexts contexts, PlayerEntity src, VehicleEntity target, RaycastHit hit,
                                 MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
        {
            VehiclePartIndex partIndex;
            var baseDamage = MeleeHitUtil.GetVehicleFactor(hit, target, out partIndex) *
                             MeleeHitUtil.GetBaseDamage(attackInfo, config);
            var gameData = target.GetGameData();

            gameData.DecreaseHp(partIndex, baseDamage);
            if (!src.WeaponController().IsHeldSlotEmpty)
            {
                RaycastHit effectHit;
                if (MeleeHitUtil.CanMeleeAttackShowHit(src, out effectHit, config.Range))
                {
                    ClientEffectFactory.AddHitVehicleEffectEvent(src, target.entityKey.Value, effectHit.point,
                                                                 effectHit.point - target.position.Value, effectHit.normal);
                }
            }
        }
예제 #8
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);
        }
예제 #9
0
        public static float GetBaseDamage(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
        {
            var damage = 0;

            switch (attackInfo.AttackType)
            {
            case EMeleeAttackType.Soft:
                damage = config.LeftDamage;
                break;

            case EMeleeAttackType.Hard:
                damage = config.RightDamage;
                break;

            default:
                MeleeAttackSystem.Logger.ErrorFormat("[HitErr]Melee AttackType {0} is illegal ", attackInfo.AttackType);
                break;
            }
            return(damage);
        }
예제 #10
0
        private float GetBaseDamage(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
        {
            var damage = 0;

            switch (attackInfo.AttackType)
            {
            case MeleeAttckType.LeftMeleeAttack:
                damage = config.LeftDamage;
                break;

            case MeleeAttckType.RightMeleeAttack:
                damage = config.RightDamage;
                break;

            default:
                damage = 1;
                Logger.ErrorFormat("AttackType {0} is illegal ", attackInfo.AttackType);
                break;
            }
            return(damage);
        }
 public void StartMeleeAttack(int attackTime, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     if (_playerEntity.hasMeleeAttackInfoSync)
     {
         _playerEntity.meleeAttackInfoSync.AttackTime = attackTime;
     }
     else
     {
         _playerEntity.AddMeleeAttackInfoSync(attackTime);
     }
     if (_playerEntity.hasMeleeAttackInfo)
     {
         _playerEntity.meleeAttackInfo.AttackInfo   = attackInfo;
         _playerEntity.meleeAttackInfo.AttackConfig = config;
     }
     else
     {
         _playerEntity.AddMeleeAttackInfo();
         _playerEntity.meleeAttackInfo.AttackInfo   = attackInfo;
         _playerEntity.meleeAttackInfo.AttackConfig = config;
     }
 }
예제 #12
0
 public void OnHitVehicle(PlayerEntity src, VehicleEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     DebugDraw.DebugPoint(hit.point, color: Color.yellow, duration: 10);
 }
예제 #13
0
 public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     RelatedMeleeAttackInfo    = attackInfo;
     RelatedMeleeAttackInfoCfg = config;
 }
예제 #14
0
 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);
         }
     }
 }
예제 #15
0
 public void OnHitEnvrionment(PlayerEntity src, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     DebugDraw.DebugPoint(hit.point, color: Color.blue, duration: 10);
 }
예제 #16
0
        public void OnHitVehicle(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.weaponLogic.Weapon.EmptyHand)
            {
                RaycastHit effectHit;
                if (TryGetEffectShowHit(src, out effectHit, config.Range))
                {
                    ClientEffectFactory.AddHitVehicleEffectEvent(
                        src,
                        target.entityKey.Value,
                        effectHit.point,
                        effectHit.point - target.position.Value,
                        effectHit.normal);
                }
            }
        }
예제 #17
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);
        }
예제 #18
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);
        }
예제 #19
0
 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);
         }
     }
 }
예제 #20
0
 public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq)
 {
     DebugDraw.DebugPoint(hit.point, color: Color.red, duration: 10);
 }
예제 #21
0
 public MeleeWeaponFireController(MeleeFireLogicConfig config)
 {
     _config = config;
 }
예제 #22
0
 public MeleeFireLogic(MeleeFireLogicConfig config)
 {
     _config = config;
 }
예제 #23
0
 private void StartMeleeAttack(PlayerWeaponController controller, int attackTime, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     controller.CreateSetMeleeAttackInfo(attackInfo, config);
     controller.CreateSetMeleeAttackInfoSync(attackTime);
 }
예제 #24
0
 public void CreateSetMeleeAttackInfo(MeleeAttackInfo attackInfo, MeleeFireLogicConfig config)
 {
     weaponInteract.CreateSetMeleeAttackInfo(attackInfo, config);
 }