IEnumerator DisplaySpeedEventCoroutine(SpeedEventType _SpeedEventType, int _SpeedEventIndex) { GameObject spawnedSpeedEvent = null; SpeedEventNotification speedNotification = null; if (_SpeedEventType == SpeedEventType.SpeedLimit) { isShowingSpeedLimit = true; spawnedSpeedEvent = Instantiate(speedEventLimitPrefab, speedEventPanel.transform); speedNotification = spawnedSpeedEvent.GetComponent <SpeedEventNotification>(); Debug.LogWarning("Speed Limit Notification Spawned"); } else if (_SpeedEventType == SpeedEventType.SpeedRecommendation) { isShowingSpeedRecommendation = true; spawnedSpeedEvent = Instantiate(speedEventRecommendationPrefab, speedEventPanel.transform); speedNotification = spawnedSpeedEvent.GetComponent <SpeedEventNotification>(); Debug.LogWarning("Speed Recommendation Notification Spawned"); } while (theGameMaster.distanceRemainingToSpeedEvents[_SpeedEventIndex] > 0f) { speedNotification.eventValue.text = (int)theStationManager.currentStation.upcomingSpeedEvents[_SpeedEventIndex].speedEventValue + "km/h"; speedNotification.distanceToEvent.text = (int)theGameMaster.distanceRemainingToSpeedEvents[_SpeedEventIndex] + "m"; yield return(null); } if (_SpeedEventType == SpeedEventType.SpeedLimit) { isShowingSpeedLimit = false; } if (_SpeedEventType == SpeedEventType.SpeedRecommendation) { isShowingSpeedRecommendation = false; } Destroy(spawnedSpeedEvent); }
public void DisplaySpeedEvent(SpeedEventType _SpeedEventType, int _SpeedEventIndex) { StartCoroutine(DisplaySpeedEventCoroutine(_SpeedEventType, _SpeedEventIndex)); }