void Start() { healthScript = GameObject.FindWithTag("HealthUI").GetComponent <DisplayHealth>(); livesScript = GameObject.FindWithTag("LivesUI").GetComponentInChildren <DisplayLives> (); if (PlayerPrefs.HasKey("247127CurrentPlayerHealth")) { health = PlayerPrefs.GetInt("247127CurrentPlayerHealth"); //TakeDamage (health - PlayerPrefs.GetInt ("247127CurrentPlayerHealth"), false); } else { health = 3; PlayerPrefs.SetInt("247127CurrentPlayerHealth", health); } if (PlayerPrefs.HasKey("247127CurrentPlayerLives")) { lives = PlayerPrefs.GetInt("247127CurrentPlayerLives"); //if (lives <= 0) //SceneManager.LoadScene (2); } else { lives = 2; PlayerPrefs.SetInt("247127CurrentPlayerLives", lives); } if (lives <= 0) { SceneManager.LoadScene(2); } }
private void OnEnable() { GameCanvas gameCanvas = FindObjectOfType <GameCanvas>(); if (gameCanvas != null) { _health.OnDead += gameCanvas.ShowGameOverPanel; DisplayHealth displayHealth = gameCanvas.GetComponentInChildren <DisplayHealth>(); _health.OnHealthChanged += displayHealth.WriteHealth; } _health.OnDead += () => OnPlayerDead.Invoke(deadClip); _health.OnHealthChanged += PlayOnHit; }
private void Start() { GameCanvas gameCanvas = FindObjectOfType <GameCanvas>(); if (gameCanvas != null) { DisplayHealth displayHealth = FindObjectOfType <DisplayHealth>(); _health.OnHealthChanged += displayHealth.WriteHealth; _health.OnDead += gameCanvas.ShowGameOverPanel; displayHealth.WriteHealth(_health.MaxHealth, 0); } _health.OnDead += () => OnPlayDeadSound?.Invoke(deadClip); _health.OnHealthChanged += PlayDamageSound; }