void Init() { transform.position = Vector2.zero; _baseSpeed = _speed; _currentAmmo = _maxAmmo; _lives = _maxLives; _tripleShotDuration = _powerUpDuration; _speedBoostDuration = _powerUpDuration; _omniShotDuration = _powerUpDuration; _negativeEffectDuration = _powerUpDuration; _shieldRenderer = _shieldVisual.GetComponent <SpriteRenderer>(); _fullShieldColor = _shieldRenderer.color; _shieldVisual.SetActive(false); for (int i = 0; i < _engineFires.Length; i++) { _engineFires[i].SetActive(false); } OnUpdateLives?.Invoke(_lives); OnUpdateThuster?.Invoke(_elapsedTime, _thrusterBurnLength); OnUpdateAmmo?.Invoke(_currentAmmo, _maxAmmo); OnUpdateMissiles?.Invoke(_currentMissiles, _numberOfMissiles); }
void FireLaser() { GameObject weapon; if (_isNegativeEffectActive == true || _isOmniShotActive == true) { _canFire = Time.time + _fireRate + _fireDelayIncrease; } else { _canFire = Time.time + _fireRate; } PlayClip(_laserClip); if (_isTripleShotActive == true) { int weaponType = _laserPrefab.GetWeaponType(); for (int i = 0; i < _spawnPoints.Length; i++) { weapon = OnGetLaser?.Invoke(weaponType); if (weapon != null) { weapon.transform.position = _spawnPoints[i].position; weapon.SetActive(true); } } } else if (_isOmniShotActive == true) { int weaponType = _omniShotPrefab.GetWeaponType(); weapon = OnGetWeapon?.Invoke(weaponType); if (weapon != null) { weapon.transform.position = transform.position; weapon.SetActive(true); } } else { int weaponType = _laserPrefab.GetWeaponType(); weapon = OnGetLaser?.Invoke(weaponType); if (weapon != null) { weapon.transform.position = _spawnPoints[0].position; weapon.SetActive(true); _currentAmmo--; OnUpdateAmmo?.Invoke(_currentAmmo, _maxAmmo); } } }
public void ChangeAmmo() { _currentAmmo = _maxAmmo; OnUpdateAmmo?.Invoke(_currentAmmo, _maxAmmo); }
public void CallUpdateAmmo() { OnUpdateAmmo?.Invoke(); }