Пример #1
0
    private void Start()
    {
        m_BulletObjectPool = m_BulletObjectPoolProvider.BulletObjectPool;

        // 1秒毎に弾を発射
        Observable
        .Interval(TimeSpan.FromSeconds(1))
        .Subscribe(_ => ShootBullets())
        .AddTo(this)
        ;
    }
Пример #2
0
 public void Shooting()
 {
     if ((_playerShipTransform.position - _enemyShipTransform.position).sqrMagnitude >= _rangeAttack)
     {
         if (_lastFireTime + _dataBullet.FireCooldown < Time.time)
         {
             _lastFireTime = Time.time;
             var bullet = BulletObjectPool.GetBullet(_dataBullet.BulletPrefab, _enemyShipBarrel.position, _dataBullet.Damage);
             bullet.AddForce(_enemyShipBarrel.up * _dataBullet.Force, ForceMode2D.Impulse);
         }
     }
 }
Пример #3
0
 private void Awake()
 {
     bulletQueue = new Queue <GameObject>();
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Debug.Log("instance already exists, destroying object!");
         Destroy(this);
     }
 }
Пример #4
0
        /// <summary>
        /// Allow Shooting in every state.
        /// </summary>
        /// <param name="bulletPool"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        public virtual ICharacterState Shoot(BulletObjectPool bulletPool, Vector3 position)
        {
            var newBullet = bulletPool.CreateBullet();

            newBullet.transform.position = position;

            //TODO: Rotate the bullet depending on which direction you are walking in here, instead of in Bullet.cs
            if (Input.GetAxisRaw("Horizontal") < 0)
            {
                //Code
            }
            return(this);
        }
Пример #5
0
 public void Shooting()
 {
     if (_isWeaponLocked)
     {
         Debug.Log("Weapon locked!");
     }
     else
     {
         if (_lastFireTime + _fireCooldown < Time.time)
         {
             _audioSource.volume = _shotVolume;
             _audioSource.PlayOneShot(_audioSource.clip);
             _lastFireTime = Time.time;
             var bullet = BulletObjectPool.GetBullet(_dataWeapon.BulletPrefab, _barrelPlayer.position, _damage);
             bullet.AddForce(_barrelPlayer.up * _dataWeapon.Force, ForceMode2D.Impulse);
         }
     }
 }
Пример #6
0
 private void Start()
 {
     bulletObejctPool  = BulletObjectPool.Instance;
     rb.freezeRotation = true;
 }
Пример #7
0
 private void Destroy()
 {
     BulletObjectPool.ReturnToPool(this);
 }
Пример #8
0
 private void Awake()
 {
     SharedInstance = this;
 }
Пример #9
0
    private void Awake()
    {
        Instance = this;

        Initialize(30);
    }
Пример #10
0
 private void Start()
 {
     bulletPool = FindObjectOfType <BulletObjectPool>();
 }