private void Update() { health = 0; bool isBurning = false; int burntCount = 0; foreach (Burnable prop in props) { if (!prop.isInvincible) { health += prop.health; isBurning = isBurning || prop.isBurning; if (prop.health == 0) { burntCount++; } } } for (int i = 0; i < Mathf.Min(burntCount, matches.Length); i++) { matches[matches.Length - 1 - i].sprite = burntMatch; } if (burntCount >= matches.Length) { menu.GameOver(); return; } if (!isBurning) { timerSlider.gameObject.SetActive(true); if (timer < waitingTime) { timer += Time.deltaTime; } else { menu.Win(); return; } } else { timerSlider.gameObject.SetActive(false); timer = 0; } timerSlider.value = (waitingTime - timer) / waitingTime; healthSlider.value = health - baseHealth; if (healthSlider.value <= 0) { menu.GameOver(); return; } }