public List <TimeEvent> UpdateTimeEventList(List <TimeEvent> timeEvents) { //NEED TO ITERATE ON LIST.TOARRAY IN ORDER TO EDIT VALUES INSIDE LIST foreach (TimeEvent timeEvent in timeEvents.ToArray()) { timeEvent.progressBar.GetComponentInChildren <Slider>().value = timeEvent.currentPercentage += timeEvent.percentagePerMin; if (!(timeEvent.currentPercentage >= 100)) { continue; } if (timeEvent.threat != StaticDb.timeEventThreat) { //ClassDb.worldManager.DeployThreat(timeEvent.threat); deployRoutine = manager.DeployThreat(timeEvent.threat); StartCoroutine(deployRoutine); } timeEvents.Remove(timeEvent); timeEvent.progressBar.GetComponentInChildren <Slider>().value = 0f; ClassDb.prefabManager.ReturnPrefab(timeEvent.progressBar.gameObject, PrefabManager.pbIndex); } return(timeEvents); }