public void Damage() { // if sheilds is active if (_powerUpShields == true) // do nothing { _powerUpShields = false; this.gameObject.transform.GetChild(0).gameObject.SetActive(false); Debug.Log("<color=red>SHEILDS ARE DOWN..!!!</color>"); return; // kill shields } else { _healthPointsPlayer -= _enemyImpactDamage; } if (_healthPointsPlayer == 2) { this.gameObject.transform.GetChild(2).gameObject.SetActive(true); //if lives is 2 enable right engine } if (_healthPointsPlayer == 1) { this.gameObject.transform.GetChild(3).gameObject.SetActive(true); // else if lives is 1, enable left engine. } _uiManager.UpdateLives(_healthPointsPlayer); if (_healthPointsPlayer <= 0) { //communicate with Spawn Manager _spawnManager.OnPlayerDeath(); //this.gameObject.transform.GetChild(2).gameObject.SetActive(false); Debug.Log("<color=red>Player has been destroyed..!!!</color>"); _singleShotAudioSource.PlayOneShot(_explosionAudio, 0.7F); //_uiManager.ActivateGameOverScreen(true); //_gameOverScreen.SetActive(true); //.transform.GetChild(0).gameObject.SetActive(true); GameObject newExplosion = Instantiate(_explosionPrefab, this.gameObject.transform.position, Quaternion.identity); Destroy(this.gameObject); } Debug.Log("Player Hitpoints: " + _healthPointsPlayer); }
public void Damage() { if (_isShieldActive == true) { _isShieldActive = false; _shieldVisualizer.SetActive(false); return; } _lives--; _uiManager.UpdateLives(_lives); if (_lives < 1) { _spawnManager.OnPlayerDeath(); Destroy(this.gameObject); } }