Exemplo n.º 1
0
    //[Berdy] Agrego el shooter para identificar el PlayerName que dispara y evitar un autodisparo (bug de disparo sobre planeta con Pusher Gun)
    //[Berdy] Tener en cuenta que solo sirve para comparar, si la comparacion no se hace se puede permitir el autodisparo (ej. Bala orbital)
    public void Shoot(int shooter)
    {
        if (!CanShoot)
        {
            Debug.Log("Weapon in cooldown state.", gameObject);
            return;
        }

        if (_ammo == 0)
        {
            Debug.LogError("Trying to fire a weapon with no ammo. Should have switched to the default weapon!", gameObject);
            return;
        }

        _particles.Play();
        BaseBullet newBullet = Instantiate(_bullet, _bulletSpawnPoint.position, Quaternion.identity, null);

        newBullet.transform.right = _bulletSpawnPoint.transform.right;

        //[Berdy] Nuevo llamado a OnShoot pasandole el shooter
        newBullet.OnShot(shooter);
        //

        if (_ammo != -1)
        {
            _ammo--;
        }

        _lastTimeShot = Time.time;
    }