Exemplo n.º 1
0
        protected override void Update()
        {
            base.Update();
            if (IsActive)
            {
                transform.Rotate(0, 0, -_input.GetRotation() * _rotationSpeed * Time.deltaTime);
                Rigidbody.AddForce(transform.up * _movingForce * _input.GetMovement());

                if (_input.ActionButtonPressed())
                {
                    if (_timeFromLastShot > _shotDelay)
                    {
                        var laser = _laserSpawner.Spawn() as Laser;
                        if (laser != null)
                        {
                            laser.Setup(_weapon.transform.position, transform.rotation);
                            SignalsManager.Broadcast("PlayAudio", "laser");
                        }

                        _timeFromLastShot = 0f;
                    }
                    else
                    {
                        _timeFromLastShot += Time.deltaTime;
                    }
                }
                else
                {
                    _timeFromLastShot = float.MaxValue;
                }
            }
        }