private void ShootLaser() { _canFire = Time.time + _fireRate; if (_tripleFireActive) { Instantiate(_tripleLaserPrefab, transform.position, Quaternion.identity); _ammoCount--; _ammoFillBar.SetFillBar(_ammoCount); } else { Instantiate(_laserPrefab, transform.position + _laserFireOffset, Quaternion.identity); _ammoCount--; _ammoFillBar.SetFillBar(_ammoCount); } _audioSource.PlayOneShot(_laserShot); }
void CalculateMovement() { float horizontalInput = Input.GetAxis("Horizontal"); float verticalInput = Input.GetAxis("Vertical"); Vector3 direction = new Vector3(horizontalInput, verticalInput, 0); if (Input.GetKey(KeyCode.LeftShift) && _currentBoostTime > 0) { _boostAmount = 2; _currentBoostTime -= Time.deltaTime; _boostFillBar.SetFillBar(_currentBoostTime); } else { _boostAmount = 1; _currentBoostTime += (Time.deltaTime * .5f); _boostFillBar.SetFillBar(_currentBoostTime); } if (!_isSpeedBoostActive) { transform.Translate(direction * speed * _boostAmount * _slowDownPowerUp * Time.deltaTime); } else { transform.Translate(direction * (speed * _speedMuliplier) * _slowDownPowerUp * Time.deltaTime); } if (Input.GetKeyDown(KeyCode.LeftShift)) { } //clamps the player to prevent them from going below 3.8 and above 0 transform.position = new Vector3(transform.position.x, Mathf.Clamp(transform.position.y, -3.8f, 0)); if (transform.position.x >= 11f || transform.position.x <= -11f) { transform.position = new Vector3(transform.position.x * -1, transform.position.y, 0); } }