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);
        }
            public void CreateBullet(IPlayerWeaponState playerWeapon,
                                     Vector3 direction,
                                     IBulletFireInfoProviderDispatcher bulletFireInfoProviderDispatcher,
                                     int cmdSeq,
                                     int renderTime)
            {
                PlayerEntity playerEntity = (PlayerEntity)playerWeapon.Owner;
                var          bulletEntity = _bulletEntityFactory.CreateBulletEntity(
                    cmdSeq,
                    playerEntity.weaponLogicInfo.WeaponId,
                    playerEntity.entityKey.Value,
                    renderTime,
                    direction,
                    bulletFireInfoProviderDispatcher,
                    _config,
                    playerWeapon.Caliber) as BulletEntity;

                if (null != bulletEntity)
                {
                    _logger.DebugFormat("Fire from {0} with velocity {1}, entity key {2}, cmd {3}",
                                        bulletEntity.position.Value,
                                        bulletEntity.bulletData.Velocity,
                                        bulletEntity.entityKey,
                                        cmdSeq);
                }
            }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public WeaponFactory(IPlayerWeaponState playerWeaponState,
                      CharacterStateManager characterState,
                      IWeaponLogicFactory weaponLogicFactory,
                      IFreeArgs freeArgs)
 {
     _playerWeaponState            = playerWeaponState;
     _weaponLogicFactory           = weaponLogicFactory;
     _bulletInfoProviderDispatcher = new BulletFireInfoProviderDispatcher(playerWeaponState);
     _freeArgs = freeArgs;
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
        public Entity CreateBulletEntity(
            int cmdSeq,
            int weaponId,
            EntityKey entityKey,
            int serverTime, Vector3 dir,
            IBulletFireInfoProviderDispatcher bulletFireInfoProviderDispatcher,
            BulletConfig bulletConfig,
            EBulletCaliber caliber)
        {
            int bulletEntityId = _entityIdGenerator.GetNextEntityId();

            //var emitPost = PlayerEntityUtility.GetCameraBulletEmitPosition(playerEntity);
            Vector3 velocity     = dir * bulletConfig.EmitVelocity;
            var     bulletEntity = _bulletContext.CreateEntity();
            float   maxDistance  = bulletConfig.MaxDistance;

            bulletEntity.AddEntityKey(new EntityKey(bulletEntityId, (int)EEntityType.Bullet));

            bulletEntity.AddBulletData(
                velocity,
                0,
                bulletConfig.Gravity,
                0,
                serverTime,
                maxDistance,
                bulletConfig.PenetrableLayerCount,
                bulletConfig.BaseDamage,
                bulletConfig.PenetrableThickness,
                bulletConfig,
                bulletConfig.VelocityDecay,
                caliber,
                weaponId);
            var viewPosition = bulletFireInfoProviderDispatcher.GetFireViewPosition();
            var emitPosition = bulletFireInfoProviderDispatcher.GetFireEmitPosition();

            bulletEntity.AddPosition(viewPosition);
            bulletEntity.AddOwnerId(entityKey);
            bulletEntity.bulletData.CmdSeq     = cmdSeq;
            bulletEntity.bulletData.StartPoint = viewPosition;
            bulletEntity.bulletData.EmitPoint  = emitPosition;
            bulletEntity.bulletData.StartDir   = dir;
            bulletEntity.isNew = true;
            bulletEntity.AddEmitPosition(emitPosition);
            bulletEntity.isFlagSyncNonSelf = true;
            bulletEntity.AddLifeTime(DateTime.Now, SharedConfig.BulletLifeTime); // in case user logout
            return(bulletEntity);
        }
        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);
        }
        public IWeaponLogic CreateWeaponLogic(int weaponId, IWeaponSoundLogic soundLogic, IWeaponEffectLogic effectLogic, IBulletFireInfoProviderDispatcher bulletFireInfoProvider)
        {
            foreach (var row in Configs.Weapons)
            {
                if (row.Id == weaponId)
                {
                    var weaponCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponId);
                    var rc        = _componentsFactory.CreateWeaponLogic(
                        weaponCfg,
                        row.WeaponLogic,
                        soundLogic,
                        effectLogic,
                        bulletFireInfoProvider);
                    if (rc == null)
                    {
                        throw new Exception("unconfiged weapon " + weaponId);
                    }
                    rc.Reset();
                    return(rc);
                }
            }

            return(null);
        }