private void Update() { if (timeIsUp) { return; } timer -= Time.deltaTime; timerText.text = timer.ToString("0:00"); altitudeText.text = rocket.position.y.ToString("0"); altitudeSlider.value = rocket.position.y / levelAltitude; if (timer <= 0 && !timeIsUp) { timer = 0; timeIsUp = true; OnTimeIsUp?.Invoke(); } if (rocket.position.y >= levelAltitude && !altitudeReached) { altitudeReached = true; OnAltitudeReached?.Invoke(); } }
private void ReceiveMessage(WebSocketSharp.MessageEventArgs e) { SaferizeEvent evt = JsonConvert.DeserializeObject <SaferizeEvent>(e.Data); switch (evt.EventType) { case "ApprovalStatusChangedEvent": HandleApprovalStatusChangedEvent(JsonConvert.DeserializeObject <ApprovalStatusChangedEvent>(e.Data)); break; case "ApprovalStateChangedEvent": HandleApprovalStateChangedEvent(JsonConvert.DeserializeObject <ApprovalStateChangedEvent>(e.Data)); break; case "UsageTimerTimeIsUpEvent": OnTimeIsUp?.Invoke(); break; case "PinChangedEvent": PinChangedEvent pinChanged = JsonConvert.DeserializeObject <PinChangedEvent>(e.Data); OnPINChange?.Invoke(pinChanged.pinHash); break; case "AppUserChangedAppFeaturesEvent": AppUserChangedAppFeaturesEvent appFeaturesChangedEvent = JsonConvert.DeserializeObject <AppUserChangedAppFeaturesEvent>(e.Data); OnAppFeaturesChange?.Invoke(appFeaturesChangedEvent.Features); break; default: break; } }
private IEnumerator StartCountdown() { while (_levelTime >= 0) { DisplayTime(); yield return(new WaitForSeconds(1f)); _levelTime--; } OnTimeIsUp?.Invoke(); }
private void HandleConnectUserWebException(WebException exception) { if ("Unable to read data from the transport connection: Connection timed out.".Equals(exception.Message) || exception.Response == null) { //assume that there is no internet StartOfflineWorkflow(); // but keep trying to connect anyway as long as we've not yet hit the maxretrycount reconnectTryCount++; if (reconnectTryCount < maxRetryCount) { ConnectUser(usertoken); } return; } var resp = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd(); GameSessionException gameSessionException = JsonConvert.DeserializeObject <GameSessionException>(resp); switch (gameSessionException.exceptionType) { case "com.saferize.core.entities.appusagesession.ApprovalPendingException": OnPause?.Invoke(); break; case "com.saferize.core.entities.appusagesession.ApprovalRejectedException": OnRevoke?.Invoke(); break; case "com.saferize.core.entities.appusagesession.UsageTimerTimeIsUpException": OnTimeIsUp?.Invoke(); break; case "com.saferize.core.entities.appusagesession.IllegalApprovalStateException": break; case "com.saferize.core.entities.approval.ApprovalNotFoundException": break; case "com.saferize.core.entities.app.IllegalAppStateException": break; case "com.saferize.core.security.PrincipalNotFoundException": break; } }
private IEnumerator WaitForCollision(float delay) { yield return(new WaitForSeconds(delay)); OnTimeIsUp?.Invoke(this); }