// Update is called once per frame private void Update() { if (!_alive) { return; } _rigidbody.rotation -= _settings.rotationSpeed * Time.smoothDeltaTime * _input.Horizontal; _speed = Mathf.MoveTowards(_speed, _settings.speed * _input.Vertical, _settings.acceleration * Time.smoothDeltaTime); if (_input.SwapWeapon) { _weaponIdx += 1; _weaponIdx %= _settings.weapons.Count; _signalBus.Fire(new WeaponChangedSignal() { NewWeapon = _settings.weapons[_weaponIdx].name }); } if (_input.Fire) { var activeWeapon = _settings.weapons[_weaponIdx]; if (Time.time > activeWeapon.fireTimeout + _lastFire) { _lastFire = Time.time; var angle = -Mathf.Atan2(firePoint.up.x, firePoint.up.y) * Mathf.Rad2Deg; _bulletPool.Spawn(firePoint.position, angle, activeWeapon.bulletSettings); } } _rigidbody.velocity = _transform.up * _speed; }
public Bullet Create(BulletOwner owner, Vector2 position, Vector2 velocity, int damage = 1) { var bullet = _bulletPool.Spawn(owner, position, velocity, damage); _bullets.Add(bullet); return(bullet); }