public void Damage() { if (_isShield == false) { _lives--; _uiManager = GameObject.Find("Canvas").GetComponent <UI_Manager>(); _uiManager.UpdateLives(_lives); if (_lives == 2) { _rightEngine.SetActive(true); } if (_lives == 1) { _leftEngine.SetActive(true); } } else { _shield.SetActive(false); _isShield = false; } if (_lives <= 0) { _spawnManager.OnPlayerDeath(); Destroy(this.gameObject); _uiManager.GameOver(); //communicate with spawn manager } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { uiScript.GameOver(); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Player") { UIManager.GameOver(); UIManager.Die(); } }
void Update() { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal * speed * Time.timeScale, 0.0f, moveVertical * speed * Time.timeScale); transform.Translate(movement); //Game Over if fall if (this.transform.position.y < -6f) { uiScript.GameOver(); } }
public void DealDamage(int dmg = 1) { if (_shieldActive) { _shieldActive = false; _shieldTransform.gameObject.SetActive(false); return; } _hp -= dmg; _ui_manager.UpdateHP(_hp); if (_hp <= 0) { _spawnManager.PlayerDied(); _ui_manager.GameOver(); Destroy(gameObject); } }
public virtual void TakeDamage(int damage) { //_audio_Source.PlayOneShot(_audio_Damage); if (damage > _lives) { _lives = 0; } else { _lives -= damage; switch (_lives) { case 3: _damage1.transform.rotation = transform.rotation; _damage1.gameObject.SetActive(true); break; case 2: _damage2.transform.rotation = transform.rotation; _damage2.gameObject.SetActive(true); break; case 1: _damage3.transform.rotation = transform.rotation; _damage3.gameObject.SetActive(true); break; } } if (_lives <= 0) { _UI_Manager.GameOver(); transform.gameObject.SetActive(false); return; } else { StartCoroutine(FireCooldown()); } }
public void GameOver(bool playerHasWon) { Time.timeScale = 0; uiManager.GameOver(playerHasWon); }