Beispiel #1
0
        public IEnumerator StartStage()
        {
            if (_shooter != null)
            {
                UBulletPoolManager poolManager = _shooter.GetBulletPoolManager();
                // Check if the bulletIndex is in valid range (bullet exists)
                if (_bulletIndex >= 0 && _bulletIndex < poolManager.GetPrototypesCount())
                {
                    for (int i = 0; i < _count; i++)
                    {
                        UBulletObject fetchedBullet = poolManager.FetchBulletByID(_bulletIndex, true, _shouldBulletAddToMonitor, _shouldBulletActivateCollider);
                        // rotate fetched bullet to have the same rotation as the shooter.
                        // This is meaningful as we want bullets to shoot at the same UP direction of the shooter
                        Transform fetchedBulletTrans = fetchedBullet.GetTransform();
                        Transform shooterTrans       = _shooter.GetTransform();
                        fetchedBulletTrans.position = shooterTrans.position;
                        fetchedBulletTrans.rotation = shooterTrans.rotation;
                        // More motion settings on the bullet itself
                        _bulletInitEvent.Invoke(fetchedBullet);

                        // Invoke shootEvent here
                        _shooter.GetActor().InvokeShootEvents(fetchedBullet);

                        // all non-last shots should wait for the specified interval
                        if (i < _count - 1)
                        {
                            yield return(new WaitForSeconds(_intervalFunc()));
                        }
                    }
                }
            }
            _isComplete = true;
            yield break;
        }
Beispiel #2
0
        public IEnumerator StartStage()
        {
            if (_shooter != null)
            {
                UBulletPoolManager poolManager = _shooter.GetBulletPoolManager();
                // Check if the bulletIndex is in valid range (bullet exists)
                if (_bulletIndex >= 0 && _bulletIndex < poolManager.GetPrototypesCount())
                {
                    // Forever and infinite
                    while (true)
                    {
                        // when this is true, the infinite call is forcefully stopped
                        if (_isForceStopped)
                        {
                            break;
                        }

                        UBulletObject fetchedBullet = poolManager.FetchBulletByID(_bulletIndex, true, _shouldBulletAddToMonitor, _shouldBulletActivateCollider);
                        // rotate fetched bullet to have the same rotation as the shooter.
                        // This is meaningful as we want bullets to shoot at the same UP direction of the shooter
                        Transform fetchedBulletTrans = fetchedBullet.GetTransform();
                        Transform shooterTrans       = _shooter.GetTransform();
                        fetchedBulletTrans.position = shooterTrans.position;
                        fetchedBulletTrans.rotation = shooterTrans.rotation;
                        // More motion settings on the bullet itself
                        _bulletInitEvent.Invoke(fetchedBullet);

                        // Invoke shootEvent here
                        _shooter.GetActor().InvokeShootEvents(fetchedBullet);

                        yield return(new WaitForSeconds(_intervalFunc()));
                    }
                }
            }
            yield break;
        }
Beispiel #3
0
 public UShooter SetBulletPoolManager(UBulletPoolManager newPoolManager)
 {
     this.bulletPoolManager = newPoolManager;
     return(this);
 }
Beispiel #4
0
        public UBulletObject SetPoolManager(UBulletPoolManager manager)
        {
            this.poolManager = manager;

            return(this);
        }