private IEnumerator WaitBeforeDestroy(Collider c) { OnCameraShake?.Invoke(); explosionFX.SetActive(true); c.gameObject.SetActive(false); yield return(new WaitForSeconds(0.6f)); if (saveManager == null) { saveManager = SaveManager.instance; } saveManager.SaveData(); if (SoundManager.instance == null) { _sound = FindObjectOfType <SoundManager>(); _sound.PlayImpactSound(); } else { SoundManager.instance.PlayImpactSound(); } restartEvent?.Invoke(); gameObject.SetActive(false); // GameManager.instance.ReloadGame(); }
public void ChangeLives(int amount) { if (_isShieldActive == true && amount < 0) { _currentShieldStrength--; if (_currentShieldStrength > 0) { ChangeShield(_currentShieldStrength); return; } _isShieldActive = false; _shieldVisual.SetActive(false); return; } if (amount < 0) { OnCameraShake?.Invoke(); } _lives += amount; if (_lives > _maxLives) { _lives = _maxLives; } else if (_lives < 0) { _lives = 0; } OnUpdateLives?.Invoke(_lives); if (_lives == 3) { if (_engineFires[0].activeInHierarchy == true) { _engineFires[0].SetActive(false); } if (_engineFires[1].activeInHierarchy == true) { _engineFires[1].SetActive(false); } } else if (_lives == 2) { _engineFires[0].SetActive(true); if (_engineFires[1].activeInHierarchy == true) { _engineFires[1].SetActive(false); } } else if (_lives == 1) { _engineFires[1].SetActive(true); if (_engineFires[0].activeInHierarchy == false) { _engineFires[0].SetActive(true); } } else if (_lives < 1) { int explosionID = _explosionPrefab.GetExplosionID(); GameObject explosion = OnGetExplosion?.Invoke(explosionID); explosion.transform.position = transform.position; explosion.SetActive(true); OnRemoveTarget?.Invoke(gameObject); OnDeath?.Invoke(); gameObject.SetActive(false); } }