Exemplo n.º 1
0
 public void Initialization()
 {
     for (int i = 0; i < _bulletsSettings.MaxBulletsInPool; i++)
     {
         var bullet = _bulletFactory.CreateBullet(_bulletsSettings, _generatedBulletsType, _bulletsPlaceHolder) as BulletProvider;
         bullet.gameObject.SetActive(false);
         _bulletsPool[i] = bullet;
     }
 }
Exemplo n.º 2
0
    public void Fire(Vector3 currentPosition)
    {
        var bullet = _bulletFactory.CreateBullet();

        bullet.Fire(currentPosition + MuzzlePosition, WeaponData.BulletSpeed, _intensity, _intensity >= WeaponData.MaxCharge);
        _intensity = 1f;
        _charging  = false;
        OnChargevalueChanged(_intensity, WeaponData.MaxCharge);
    }
Exemplo n.º 3
0
 private void OnCollisionEnter(Collision collision)
 {
     for (int i = 0; i < bulletsToSpawn; i++)
     {
         Vector3 randomPosition = new Vector3(Random.insideUnitCircle.x * i, 0, Random.insideUnitCircle.y * i);
         var     newBullet      = bulletFactory.CreateBullet();
         newBullet.transform.position = this.transform.position + randomPosition;
     }
     Destroy(gameObject);
 }
Exemplo n.º 4
0
 protected override void Action()
 {
     if (_factory != null)
     {
         var myBullet = _factory.CreateBullet();
         myBullet.transform.position = _shootPoint.position;
         myBullet.transform.forward  = _shootPoint.forward;
         myBullet.rb.AddForce(myBullet.transform.forward * shootForce, ForceMode.Impulse);
     }
 }
Exemplo n.º 5
0
        private void Fire(IPlayerWeaponState playerWeapon, IWeaponCmd cmd)
        {
            _bulletFireInfoProvider.Prepare();
            int cmdSeq     = cmd.CmdSeq;
            int renderTime = cmd.RenderTime;

            playerWeapon.RangeAttacking = true;
            int fireTimes = _fireBulletModeLogic.GetFireTimes(playerWeapon);

            for (int i = 0; i < fireTimes; i++)
            {
                CallBeforeFire(playerWeapon, cmd, i);

                if (Logger.IsDebugEnabled)
                {
                    Logger.DebugFormat("spread {0} {1}, YawPitch {2} {3}, index {4}",
                                       playerWeapon.LastSpreadX, playerWeapon.LastSpreadY, playerWeapon.NegPunchYaw,
                                       playerWeapon.NegPunchPitch, i);
                }

                //播放弹壳掉落特效
                //_weaponEffectLogic.PlayBulletDropEffect(playerWeapon);
                _weaponEffectLogic.CreateFireEvent(playerWeapon);
                //Audio.GameAudioMedium.PerformAudioOnGunFire(playerWeapon);
                //Audio.AKAudioEntry.PostEvent(11,);

                // 射出子弹
                for (int j = 0; j < _bulletFactory.BulletHitCount; j++)
                {
                    var dir = _bulletFireInfoProvider.GetFireDir(cmdSeq + i + j);
                    _bulletFactory.CreateBullet(playerWeapon,
                                                dir,
                                                _bulletFireInfoProvider,
                                                cmdSeq,
                                                renderTime);
                    playerWeapon.LastBulletDir = dir;
                }
                //开枪总数
                playerWeapon.OnFireOnce();
                //    playerWeapon.CurrentWeapon
                CallAfterFires(playerWeapon, cmd, i);
                playerWeapon.OnWeaponCost();
            }

            CallAfterFireCmds(playerWeapon, cmd, fireTimes);
            if (fireTimes > 0)
            {
                Logger.DebugFormat("fire {0}", fireTimes);
            }
        }
        public IPlayer CreatePlayer(IRegistration playerParameters)
        {
            string name, spaceshipModel, engineModel, armourModel, weaponModel;

            name           = playerParameters.ParametersForPlayer["name"];
            spaceshipModel = playerParameters.ParametersForPlayer["ship"];
            engineModel    = playerParameters.ParametersForPlayer["engine"];
            armourModel    = playerParameters.ParametersForPlayer["armour"];
            weaponModel    = playerParameters.ParametersForPlayer["weapon"];

            ISpaceshipEngine engine = engineFactory.CreateEngine(engineModel);
            IArmour          armour = armourFactory.CreateArmour(armourModel);
            IWeapon          weapon = weaponFactory.CreateWeapon(weaponModel.ToLower());

            weapon.Bullet = bulletFactory.CreateBullet();
            ISpaceShip spaceship = spaceshipFactory.CreateSpaceship(spaceshipModel, engine, armour, weapon);
            IPlayer    player    = playerFactory.CreatePlayer(name, spaceship);

            return(player);
        }
Exemplo n.º 7
0
        public void Execute(float deltaTime)
        {
            if (_playerTransform == null)
            {
                CanExecute = false;
                return;
            }

            if (_fire && _currentCooldown == 0)
            {
                _playerBullets.AddBullet(_bulletFactory.CreateBullet(_playerTransform, _player.GetDirection()));
                _currentCooldown = _data._reloadTime;
                _fire            = false;
            }
            else
            {
                _currentCooldown = _currentCooldown > 0 ? _currentCooldown - deltaTime : 0;
            }

            _playerBullets.Move(deltaTime);
        }
Exemplo n.º 8
0
        public Rigidbody2D GetBullet()
        {
            var bullet = _bulletFactory.CreateBullet().GetComponent <Rigidbody2D>();

            return(bullet);
        }
 public void GeneratingBullets(object sender, BulletCoordsEventArgs args)
 {
     bullets.Add(bulletFactory.CreateBullet(args.BulletType, args.Position));
 }