public static ThrowingEntity CreateThrowingEntity(
            ThrowingContext throwingContext,
            IEntityIdGenerator entityIdGenerator,
            PlayerEntity playerEntity,
            int serverTime, Vector3 dir, float initVel,
            NewWeaponConfigItem newWeaponConfig,
            ThrowingConfig throwingConfig)
        {
            int throwingEntityId = entityIdGenerator.GetNextEntityId();

            var     emitPost       = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity);
            Vector3 velocity       = dir * initVel;
            var     throwingEntity = throwingContext.CreateEntity();

            throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing));

            throwingEntity.AddThrowingData(
                velocity,
                false,
                false,
                0,
                serverTime,
                false,
                initVel,
                throwingConfig,
                newWeaponConfig.SubType
                );

            throwingEntity.AddPosition(emitPost);
            throwingEntity.AddOwnerId(playerEntity.entityKey.Value);
            throwingEntity.isFlagSyncNonSelf = true;
            throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000);
            return(throwingEntity);
        }
示例#2
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);
        }
示例#3
0
 public ThrowingFactory(ThrowingContext throwingContext, IEntityIdGenerator entityIdGenerator, NewWeaponConfigItem newWeaponConfig, ThrowingConfig throwingConfig)
 {
     _throwingContext   = throwingContext;
     _entityIdGenerator = entityIdGenerator;
     _newWeaponConfig   = newWeaponConfig;
     _config            = throwingConfig;
 }
示例#4
0
 public IFireLogic GetFireLogic(NewWeaponConfigItem newWeaponConfig,
                                FireLogicConfig config)
 {
     if (!_cache.ContainsKey(newWeaponConfig.Id))
     {
         var defaultCfg = config as DefaultFireLogicConfig;
         if (null != defaultCfg)
         {
             _cache[newWeaponConfig.Id] = CreateDefaultFireLogic(newWeaponConfig, defaultCfg);
         }
         var meleeCfg = config as MeleeFireLogicConfig;
         if (null != meleeCfg)
         {
             _cache[newWeaponConfig.Id] = new MeleeFireLogic(meleeCfg);
         }
         var throwingCfg = config as ThrowingFireLogicConfig;
         if (null != throwingCfg)
         {
             _cache[newWeaponConfig.Id] = new ThrowingFireLogic(
                 newWeaponConfig,
                 throwingCfg,
                 _componentsFactory);
         }
     }
     if (_cache.ContainsKey(newWeaponConfig.Id))
     {
         return(_cache[newWeaponConfig.Id]);
     }
     if (newWeaponConfig.Type != (int)EWeaponType.TacticWeapon)
     {
         Logger.ErrorFormat("no firelogic for weapon {0}", newWeaponConfig.Id);
     }
     return(null);
 }
示例#5
0
        public DefaultFireLogic(
            NewWeaponConfigItem newWeaponConfig,
            DefaultFireLogicConfig config,
            IWeaponLogicComponentsFactory componentsFactory,
            IAttachmentManager attachmentManager,
            IWeaponSoundLogic soundLogic,
            IWeaponEffectLogic effectLogic,
            IBulletFireInfoProviderDispatcher bulletFireInfoProviderDispatcher) : base(config)
        {
            _attachmentManager      = attachmentManager;
            _accuracyLogic          = componentsFactory.CreateAccuracyLogic(config.AccuracyLogic, config.Basic);
            _spreadLogic            = componentsFactory.CreateSpreadLogic(config.SpreadLogic, config.Basic);
            _autoFireLogic          = componentsFactory.CreateAutoFireLogic(config.FireModeLogic, config.Basic);
            _bulletLogic            = componentsFactory.CreateBulletLogic(config.Basic);
            _soundLogic             = soundLogic;
            _weaponEffectLogic      = effectLogic;
            _bulletFireInfoProvider = bulletFireInfoProviderDispatcher;

            _bulletFactory       = componentsFactory.CreateBulletFactory(config.Bullet, config.Basic);
            _kickbackLogic       = componentsFactory.CreateKickbackLogic(config.KickbackLogic, config.Basic);
            _fireBulletModeLogic = componentsFactory.CreateFireReadyLogic(config.FireModeLogic, config.Basic);
            _fireBulletCounter   = componentsFactory.CreateContinuesShootLogic(config.FireCounter, config.Basic);
            _fireActionLogic     = componentsFactory.CreateFireActionLogic(newWeaponConfig, config.Basic, _soundLogic);

            AddLogic(_accuracyLogic);
            AddLogic(_spreadLogic);
            AddLogic(_kickbackLogic);
            AddLogic(_autoFireLogic);
            AddLogic(_fireBulletModeLogic);
            AddLogic(_fireActionLogic);
            AddLogic(_fireBulletCounter);
        }
        public IWeaponLogic CreateWeaponLogic(NewWeaponConfigItem newCfg,
                                              WeaponLogicConfig config,
                                              IWeaponSoundLogic soundLogic,
                                              IWeaponEffectLogic effectLogic,
                                              IBulletFireInfoProviderDispatcher bulletFireInfoProvider)
        {
            IWeaponLogic rc = null;

            if (config is DefaultWeaponLogicConfig)
            {
                rc = new DefaultWeaponLogic(newCfg,
                                            config as DefaultWeaponLogicConfig,
                                            this,
                                            soundLogic,
                                            effectLogic,
                                            _attachmentManager,
                                            bulletFireInfoProvider);
            }
            else if (config is DoubleWeaponLogicConfig)
            {
                rc = new DoubleWeaponLogic(newCfg,
                                           config as DoubleWeaponLogicConfig,
                                           this, soundLogic,
                                           effectLogic,
                                           _attachmentManager,
                                           bulletFireInfoProvider);
            }

            return(rc);
        }
 private bool NoReloadAction(NewWeaponConfigItem config)
 {
     if (null == config)
     {
         return(true);
     }
     return(config.Type == (int)EWeaponType.ThrowWeapon || config.Type == (int)EWeaponType.MeleeWeapon);
 }
示例#8
0
        public ThrowingFireLogic(

            NewWeaponConfigItem newWeaponConfig,
            ThrowingFireLogicConfig config,
            IWeaponLogicComponentsFactory componentsFactory)
        {
            _config          = config;
            _throwingFactory = componentsFactory.CreateThrowingFactory(newWeaponConfig, config.Throwing);
        }
示例#9
0
        public static void PerformOnGunSwitch(int weaponId)
        {
            if (AudioInfluence.IsForbidden || AKAudioEntry.Dispatcher == null)
            {
                return;
            }
            NewWeaponConfigItem weaponCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponId);

            PerformOnGunSwitch(weaponCfg);
        }
示例#10
0
 public IFireActionLogic CreateFireActionLogic(NewWeaponConfigItem config)
 {
     if (SingletonManager.Get <WeaponConfigManager>().IsSpecialType(config.Id, ESpecialWeaponType.SniperFrie))
     {
         return(new SpecialFireActionLogic());
     }
     else
     {
         return(new DefaultFireActionLogic());
     }
 }
示例#11
0
        /// <summary>
        /// 枪械开火
        /// </summary>
        /// <param name="weaponState"></param>
        public static void PerformOnGunFire(WeaponLogic.IPlayerWeaponState weaponState)
        {
            if (AudioInfluence.IsForbidden || AKAudioEntry.Dispatcher == null)
            {
                return;
            }
            NewWeaponConfigItem weaponCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponState.CurrentWeapon);

            AKAudioEntry.AudioAssert(weaponCfg != null, string.Format("weapon config id [{0}] not find", weaponState.CurrentWeapon));
            //假装有event
            AKAudioEntry.Dispatcher.PostEvent(testWeaponEvent, weaponState.CurrentWeaponGo);
        }
示例#12
0
 public DoubleWeaponLogic(NewWeaponConfigItem newCfg,
                          DoubleWeaponLogicConfig config,
                          IWeaponLogicComponentsFactory componentsFactory,
                          IWeaponSoundLogic soundLogic,
                          IWeaponEffectLogic effectLogic,
                          IAttachmentManager attachmentManager,
                          IBulletFireInfoProviderDispatcher bulletFireInfoProviderDispatcher) : base(config, componentsFactory)
 {
     _leftFireLogic     = componentsFactory.CreateFireLogic(newCfg, config.LeftFireLogic, soundLogic, effectLogic, bulletFireInfoProviderDispatcher);
     _rightFireLogic    = componentsFactory.CreateFireLogic(newCfg, config.RightFireLogic, soundLogic, effectLogic, bulletFireInfoProviderDispatcher);
     _attachmentManager = attachmentManager;
 }
示例#13
0
        public static void PerformOnGunSwitch(NewWeaponConfigItem weaponCfg)
        {
            if (AudioInfluence.IsForbidden || AKAudioEntry.Dispatcher == null)
            {
                return;
            }
            AKAudioEntry.AudioAssert(weaponCfg != null, string.Format("weapon config id [{0}] not find", weaponCfg.Id));
            //假装有event
            int eventId = 2;

            testWeaponEvent = testWeaponEvent == 1 ? 2 : 1;
            AKAudioEntry.Dispatcher.PrepareEvent(testWeaponEvent);
        }
示例#14
0
        public ThrowingFireAction(
            NewWeaponConfigItem newWeaponConfig,
            ThrowingFireLogicConfig config,
            IWeaponLogicComponentsFactory componentsFactory,
            IAttachmentManager attachmentManager,
            IWeaponSoundLogic soundLogic,
            IWeaponEffectLogic effectLogic) : base(config)
        {
            _attachmentManager = attachmentManager;
            _soundLogic        = soundLogic;
            _weaponEffectLogic = effectLogic;

            _throwingLogic   = componentsFactory.CreateThrowingLogic(config.Basic);
            _throwingFactory = componentsFactory.CreateThrowingFactory(newWeaponConfig, config.Throwing);
        }
示例#15
0
        public void HandleWeaponFire(Contexts contexts, PlayerEntity player, NewWeaponConfigItem weapon)
        {
            if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.WEAPON_FIRE))
            {
                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(weapon));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("weapon", sp);
                args.TempUse("current", (FreeData)player.freeData.FreeData);

                this.args.Triggers.Trigger(FreeTriggerConstant.WEAPON_FIRE, args);

                args.Resume("weapon");
                args.Resume("current");
            }
        }
示例#16
0
        public IWeaponLogic CreateWeaponLogic(NewWeaponConfigItem newCfg,
                                              WeaponConfig config,
                                              IWeaponSoundLogic soundLogic,
                                              IWeaponEffectLogic effectLogic)
        {
            IWeaponLogic rc = null;
            var          weaponLogicConfig = config.WeaponLogic;

            if (weaponLogicConfig is DefaultWeaponLogicConfig)
            {
                rc = new DefaultWeaponLogic();
            }
            else if (weaponLogicConfig is DoubleWeaponLogicConfig)
            {
                rc = new DoubleWeaponLogic(null, null);
            }
            return(rc);
        }
示例#17
0
        private IFireLogic CreateDefaultFireLogic(NewWeaponConfigItem newWeaponConfig,
                                                  DefaultFireLogicConfig config)
        {
            var fireLogic = new DefaultFireLogic();

            fireLogic.RegisterLogic(_componentsFactory.CreateAccuracyLogic(config.AccuracyLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateSpreadLogic(config.SpreadLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateKickbackLogic(config.KickbackLogic));

            fireLogic.RegisterLogic(_componentsFactory.CreateFireCheckLogic(config.FireModeLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireActionLogic(newWeaponConfig));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireBulletCounterLogic(config.FireCounter));
            fireLogic.RegisterLogic(_componentsFactory.CreateAutoFireLogic(config.FireModeLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateBulletFireLogic(config.Bullet));
            fireLogic.RegisterLogic(_componentsFactory.CreateSpecialReloadCheckLogic(config.Basic));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireCommandLogic(config));
            fireLogic.RegisterLogic(_componentsFactory.CreateShowFireInMap(config));
            return(fireLogic);
        }
示例#18
0
        public PlayerDamageInfo(float damage, int type, int part, int weaponId, bool isOverWall = false, bool isKnife = false)
        {
            this.damage      = damage;
            this.type        = type;
            this.part        = part;
            this.weaponId    = weaponId;
            IsOverWall       = isOverWall;
            KillType         = 0;
            KillFeedbackType = 0;

            NewWeaponConfigItem weapon = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponId);

            if (weapon != null)
            {
                IsKnife = weapon.Type == (int)EWeaponType.MeleeWeapon;
            }
            else
            {
                IsKnife = false;
            }
        }
        public IFireLogic CreateFireLogic(NewWeaponConfigItem newWeaponConfig,
                                          FireLogicConfig config,
                                          IWeaponSoundLogic soundLogic,
                                          IWeaponEffectLogic effectLogic,
                                          IBulletFireInfoProviderDispatcher bulletFireInfoProviderDispatcher)
        {
            var defaultCfg = config as DefaultFireLogicConfig;

            if (null != defaultCfg)
            {
                return(new DefaultFireLogic(
                           newWeaponConfig,
                           defaultCfg,
                           this,
                           _attachmentManager,
                           soundLogic,
                           effectLogic,
                           bulletFireInfoProviderDispatcher));
            }
            var meleeCfg = config as MeleeFireLogicConfig;

            if (null != meleeCfg)
            {
                return(new MeleeFireLogic(meleeCfg, soundLogic, effectLogic));
            }
            var throwingCfg = config as ThrowingFireLogicConfig;

            if (null != throwingCfg)
            {
                return(new ThrowingFireAction(
                           newWeaponConfig,
                           throwingCfg,
                           this,
                           _attachmentManager,
                           soundLogic,
                           effectLogic));
            }
            return(null);
        }
示例#20
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetSlotWeaponPart(EWeaponSlotType slot, int id)
        {
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return(false);
            }
            NewWeaponConfigItem wpConfig  = SingletonManager.Get <WeaponConfigManager>().GetConfigById(entity.weaponBasicData.ConfigId);
            WeaponPartsStruct   lastParts = entity.weaponBasicData.GetParts();
            int  realAttachId             = BagUtility.GetRealAttachmentId(id, wpConfig.Id);
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, wpConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(),
                SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                realAttachId);

            entity.weaponBasicData.ApplyParts(attachments);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = entity.weaponBasicData.GetParts();
            RefreshModelWeaponParts(refreshData);
            return(true);
        }
 public override IThrowingFactory CreateThrowingFactory(NewWeaponConfigItem newWeaponConfig, ThrowingConfig config)
 {
     return(new ThrowingFactory(_throwingContext, _entityIdGenerator, newWeaponConfig, config));
 }
示例#22
0
        private static List <PlayerEntity> OnePlayerHealthDamage(IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector, bool isTeam)
        {
            if (playerEntity.gamePlay.IsDead())
            {
                return(null);
            }

            float curHp = playerEntity.gamePlay.CurHp;

            float realDamage = damage.damage;

            if (gameRule != null)
            {
                realDamage = gameRule.HandleDamage(srcPlayer, playerEntity, damage);
            }

            if (null != damageInfoCollector)
            {
                damageInfoCollector.SetPlayerDamageInfo(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
            }

            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            float ret = playerEntity.gamePlay.DecreaseHp(realDamage);

            damage.damage = ret;

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, !isTeam && gameRule != null ? gameRule.Contexts : null);

            //保存最后伤害来源
            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;

            if (playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
            {
                statisticsData.IsHited = true;
                if (null != srcPlayer)
                {
                    statisticsData.LastHurtKey = srcPlayer.entityKey.Value;
                }
                else
                {
                    statisticsData.LastHurtKey = EntityKey.Default;
                }
                statisticsData.LastHurtType     = damage.type;
                statisticsData.LastHurtPart     = damage.part;
                statisticsData.LastHurtWeaponId = damage.weaponId;
            }

            //谁击倒算谁的人头
            if (statisticsData.IsHited)
            {
                if (gameRule != null)
                {
                    PlayerEntity lastEntity = gameRule.Contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                    if (null != lastEntity)
                    {
                        srcPlayer = lastEntity;
                    }
                }
                damage.type     = statisticsData.LastHurtType;
                damage.part     = statisticsData.LastHurtPart;
                damage.weaponId = statisticsData.LastHurtWeaponId;
            }


            if (playerEntity.gamePlay.IsDead())
            {
                //UI击杀信息
                int killType = 0;
                if (damage.part == (int)EBodyPart.Head)
                {
                    killType |= (int)EUIKillType.Crit;
                }
                if (playerEntity.gamePlay.IsHitDown())
                {
                    killType |= (int)EUIKillType.Hit;
                }
                damage.KillType = killType;
                //UI击杀反馈
                if (null != srcPlayer)
                {
                    int feedbackType = 0;
                    if (damage.part == (int)EBodyPart.Head)
                    {
                        //爆头
                        feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                    }
                    if (damage.IsOverWall)
                    {
                        //穿墙击杀
                        feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                    }
                    if (SharedConfig.IsServer && null != gameRule && gameRule.Contexts.session.serverSessionObjects.DeathOrder == 0)
                    {
                        //一血
                        feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                    }
                    if (srcPlayer.statisticsData.BeKilledOrHitDown(playerEntity.entityKey.Value))
                    {
                        //复仇
                        feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                    }
                    if (false)
                    {
                        //合作击杀(助攻)
                        feedbackType |= 1 << (int)EUIKillFeedbackType.Cooperate;
                    }
                    //武器
                    NewWeaponConfigItem newConfig = SingletonManager.Get <WeaponConfigManager>().GetConfigById(damage.weaponId);
                    if (null != newConfig)
                    {
                        if (newConfig.SubType == (int)EWeaponSubType.Melee)
                        {
                            feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                        }
                        else if (newConfig.SubType == (int)EWeaponSubType.BurnBomb)
                        {
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                        }
                        else if (newConfig.SubType == (int)EWeaponSubType.Grenade)
                        {
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                        }
                    }
                    if (feedbackType == 0)
                    {
                        //普通击杀
                        feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                    }
                    damage.KillFeedbackType = feedbackType;
                }
            }


            //数据统计
            ProcessDamageStatistics(gameRule, srcPlayer, playerEntity, damage);

            //击杀|击倒
            if (null != gameRule && (playerEntity.gamePlay.IsDead()))
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
            }

            _logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}", playerEntity.entityKey.Value.EntityId, curHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);

            return(teamList);
        }
 public abstract IThrowingFactory CreateThrowingFactory(NewWeaponConfigItem newWeaponConfig, ThrowingConfig config);