void Update() { if (pc.health < 40f) { healthDisplay.color = Color.red; } else { healthDisplay.color = Color.grey; } healthDisplay.text = "Health: " + Mathf.CeilToInt(pc.health); timeDisplay.text = "Time to Survive: " + gm.timeLeft.ToString("F2"); if (gm.timeLeft < 30f) { timeDisplay.color = Color.green; } else { timeDisplay.color = Color.grey; } int i = 0; foreach (GameObject obj in restorationStations) { if (obj != null) { RestorationStationController rsc = obj.GetComponent <RestorationStationController>(); if (rsc.name == RestorationStations.OXYGEN_STATION) { uiDisplays[i].color = Color.grey; uiDisplays[i].text = "Humans: " + gm.oxygenStationTotal.ToString(); } else if (rsc.name != RestorationStations.HEALTH_STATION) { uiDisplays[i].text = rsc.GenerateText(); if (rsc.resourceTotal < 5) { uiDisplays[i].color = Color.red; } else { uiDisplays[i].color = Color.grey; } i++; } } } }
void InteractWithStation() { if (canInteract && Input.GetKey(KeyCode.E)) { RestorationStationController rsc = collidingStation.GetComponent <RestorationStationController>(); if (rsc.name == RestorationStations.HEALTH_STATION) { RestoreHealth(healthRestorationRate * Time.deltaTime); } else { rsc.RestoreResource(); } } }