void Update() { if (transform.position.y >= 4.60f) { transform.position = new Vector3(transform.position.x, 4.50f, 0); spawn_manager.OnPlayerDeath(); UI_Manager.Ongameover(); isgameover = true; wave.GameOver(); UI_Manager.CheckForBestScore(); } if (Input.GetKeyDown(KeyCode.Space) || Input.touchCount > 0) { if (isgameover == false) { GetComponent <Rigidbody2D>().velocity = Vector2.up * force; } } }
public void DamagePlayerOne() { if (_IsShieldIsActive == true) { _IsShieldIsActive = false; _shieldVisualiser.SetActive(false); return; } _livesPlayerOne--; _sr.material = _matWhite; AudioSource.PlayClipAtPoint(_lossClip, transform.position, 1.0f); if (_livesPlayerOne == 2) { Invoke("ResetMaterial", 0.1f); _leftEngineDamage.SetActive(true); } else if (_livesPlayerOne == 1) { Invoke("ResetMaterial", 0.1f); _rightEngineDamage.SetActive(true); } else if (_livesPlayerOne < 1) { _livesPlayerOne = 0; _gameManager._isPlayerOneAlive = false; Instantiate(_explosionPrefab, transform.position, Quaternion.identity); _uiManager.CheckForBestScore(); Destroy(this.gameObject); } _uiManager.UpdateLivesPlayerOne(_livesPlayerOne); }