Exemplo n.º 1
0
    public BulletManager CreateManager(Transform bulletParent, Transform barrelEnd)     //these are called to create a new manager
    {
        BulletManager manager = bulletManager.Create(bulletParent, barrelEnd, this);

        managers.Add(manager);
        return(manager);
    }
Exemplo n.º 2
0
    private void Shoot()
    {
        if (Time.time - _lastShot < Stats.FireRate)
        {
            return;
        }

        _lastShot = Time.time;

        _bulletManager.Create(BulletOwner.Player, transform.position, LookDirection.normalized * _settings.BulletSpeed);
        _shootAudioSource.Play();
    }
Exemplo n.º 3
0
    private IEnumerator ShootSequence()
    {
        var bulletOrigin = _bulletOrigin.position;

        if (EnemyBody.SpriteRenderer.flipX) // take in account the sprite flip
        {
            bulletOrigin.x -= _bulletOrigin.localPosition.x;
        }

        var vectorToPlayer = _player.transform.position - bulletOrigin;

        for (var i = 0; i < Random.Range(2, 4); i++)
        {
            _bulletManager.Create(BulletOwner.Enemy,
                                  bulletOrigin, vectorToPlayer.normalized * _bulletSpeed);
            _audioSource.Play();

            yield return(new WaitForSeconds(0.1f));
        }
    }