Пример #1
0
    void HandleFire(Vector2 dir, Vector2 pos)
    {
        while (ready && currentClip > 0)
        {
            for (int i = 0; i < projectileCount; i++)
            {
                float xSpread = UnityEngine.Random.Range(-spread, spread);
                float ySpread = UnityEngine.Random.Range(-spread, spread);

                Vector2 adjustedDir = new Vector2(dir.x + xSpread, dir.y + ySpread);
                Bullet  bullet      = Instantiate(projectile, pos, Quaternion.identity).GetComponent <Bullet>();
                bullet.direction = adjustedDir;

                _audio.PlayRandomClip(fireAudioClips);
            }

            Equippable.BeUsed();
            UIManager.AddScreenshake(shakeDuration, shakeMagnitude);
            // currentClip -= 1;
            ready = false;
        }
    }
Пример #2
0
    void TryFire()
    {
        Vector2 pos = PlayerInput.GetPlayerPos();
        Vector2 dir = PlayerInput.GetMouseDirection();

        if (ready && currentClip > 0)
        {
            for (int i = 0; i < projectileCount; i++)
            {
                // currentClip -= 1;
                float xSpread = UnityEngine.Random.Range(-spread, spread);
                float ySpread = UnityEngine.Random.Range(-spread, spread);

                Vector2 adjustedDir = new Vector2(dir.x + xSpread, dir.y + ySpread);
                Bullet  bullet      = Instantiate(projectile, pos, Quaternion.identity).GetComponent <Bullet>();
                bullet.direction = adjustedDir;
            }
            UIManager.AddScreenshake(shakeDuration, shakeMagnitude);
            _audio.PlayRandomClip(fireAudioClips);
            ready = false;
            Equippable.BeUsed();
        }
    }