/// <inheritdoc /> public async void OnEvent(WorkflowStepEndedArgs arg) { m_CurKnowledge |= Knowledge.JustAdvancedStep; await Task.Delay((int)(retentionTime * 1000)); m_CurKnowledge ^= Knowledge.JustAdvancedStep; }
public void OnEvent(WorkflowStepEndedArgs args) { //update title WorkflowData wf = m_WorkflowService.currentWorkflowData; UpdateTitle(wf.name, m_WorkflowService.currentStep + 1, wf.numTotalSteps); //check for completion OnWorkflowCompleted(); }
/// <inheritdoc /> public void OnEvent(WorkflowStepEndedArgs arg) { if (arg.lastDataStep == -1) { return; } m_TimelineItems[arg.lastDataStep].active = false; if (arg.lastStep > arg.newStep) { return; } m_TimelineItems[arg.lastDataStep].completed = true; if (m_PrevRepetitions < arg.executedRepetitions) { m_AnimateBubbleUp = true; m_PrevRepetitions = arg.executedRepetitions; } }
public async void OnEvent(WorkflowStepEndedArgs arg) { //wait until all other end events have been handled await new WaitForEndOfFrame(); // queue counter background animation int index = m_RepetitionSteps.IndexOf(arg.lastDataStep); if (index != -1) { float fill = (float)(index + 1) / (float)m_RepetitionSteps.Count; QueueableAnimationSynchronizer sync = QueueableAnimationSynchronizer.Pool.Spawn(); m_AssemblyProgressViewController.SetTarget(fill); sync.Append(m_GamificationTimeline.GetItemProgressAnimation(arg.lastDataStep), m_AssemblyProgressViewController); m_AnimationQueue.Enqueue(sync); } // queue repetition finished animation if (m_PrevRepetitions < arg.executedRepetitions) { QueueableAnimationSynchronizer sync = QueueableAnimationSynchronizer.Pool.Spawn(); sync.Append(m_WaveBubbles, m_AssemblyProgressBubbles); m_AnimationQueue.Enqueue(sync); sync = QueueableAnimationSynchronizer.Pool.Spawn(); m_AssemblyCounterViewController.SetTarget(arg.executedRepetitions); sync.Append(m_GamificationTimeline, m_AssemblyCounterViewController); m_AnimationQueue.Enqueue(sync); } // queue badge animations BadgeData changedBadges = m_BadgeService.currentBadges - m_PrevBadgeData; if (changedBadges != BadgeData.Empty) { m_PrevBadgeData = m_BadgeService.currentBadges; m_BadgeOverviewController.SetBadgeData(changedBadges); m_AnimationQueue.Enqueue(m_BadgeOverviewController); } await m_AnimationQueue.Play(); finalized = true; }
public async void OnEvent(WorkflowStepEndedArgs arg) { await new WaitForEndOfFrame(); BadgeData gainedBadges = m_BadgeService.currentBadges - m_PrevBadgeData; if (arg.lastStep < 0) { m_PrevBadgeData = BadgeData.Empty; finalized = true; return; } PredefinedFeedbackActivity p = null; // check whether we earned badges and give feedback accordingly for (int i = 2; i >= 0; --i) { if (gainedBadges.TimeBadges[i] > 0) { p = m_ActivityLibrary.Get(FeedbackType.fastBadge, i); break; } if (gainedBadges.StreakBadges[i] > 0) { p = m_ActivityLibrary.Get(FeedbackType.streakBadge, i); break; } if (gainedBadges.AmountBadges[i] > 0) { p = m_ActivityLibrary.Get(FeedbackType.amountBadge, i); break; } } m_PrevBadgeData = m_BadgeService.currentBadges; if (p == null && !m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep].automatic) { float expected = m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep].durations[m_AdaptivityService.level]; if (expected <= 0f) { finalized = true; return; } float actual = m_TimeTrackingRepo.currentTime.durationsPerStep[arg.lastStep]; float diff = expected - actual; FeedbackType targetType = diff > 3f ? FeedbackType.assertive : diff < -3f ? FeedbackType.neutral : FeedbackType.supportive; p = m_ActivityLibrary.Get(targetType); } if (p == null) { finalized = true; return; } m_Bot.SimulateMessageReceived(m_Factory.Create(p.activity)); string audioTrackUrl = assetsUrl + "/" + p.audioClip; using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip($"file:///{audioTrackUrl}", AudioType.WAV)) { await www.SendWebRequest(); if (www.isNetworkError) { Aci.Unity.Logging.AciLog.LogError("SceneAudio", www.error); } else { try { AudioClip clip = DownloadHandlerAudioClip.GetContent(www); await m_AudioService.PlayAudioClipAsync(clip, AudioChannels.Assistant); } catch (Exception e) { Debug.LogException(e); } } } finalized = true; }
public async void OnEvent(WorkflowStepEndedArgs arg) { // Wait for badges to be awarded await new WaitForEndOfFrame(); Activity activity = null; // Get the amount of badges gained. if (arg.lastStep < 0) { finalized = true; return; } // If the previous step was automatic or the last step, then ignore. if (m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep].automatic) { finalized = true; return; } // Get the time it took to complete the last step and compare with the expected duration for the current adaptivity level. float expectedDuration = m_WorkflowService.currentWorkflowData.steps[arg.lastDataStep].durations[m_AdaptivityService.level]; float currentDuration = m_TimeTracker.currentTime.durationsPerStep[arg.lastStep]; float delta = expectedDuration - currentDuration; m_AnswerCount--; // If we're below the time threshold, then ignore. if (Mathf.Abs(delta) < adaptivityTimeThreshold) { finalized = true; return; } // Check if user was faster or slower, and update counter. if (delta > 0) { m_ThresholdPassedCount++; } else { m_ThresholdPassedCount--; } // If counter was surpassed then create the message. if (Mathf.Abs(m_ThresholdPassedCount) >= adaptivityRepeatThreshold) { // If faster, check if we've already reached the minimum adaptivity level. Reset counter if necessary. if (m_ThresholdPassedCount > 0) { if (m_AdaptivityService.level > m_AdaptivityService.minLevel && m_AnswerCount < 0) { activity = m_Factory.Create(m_Library.DecreaseAdaptivityLevelMessage.activity); } m_ThresholdPassedCount = 0; } // If slower, check if we've already reached the maximum adaptivity level. Reset counter if necessary. else if (m_ThresholdPassedCount < 0) { if (m_AdaptivityService.level < m_AdaptivityService.maxLevel && m_AnswerCount < 0) { activity = m_Factory.Create(m_Library.IncreaseAdaptivityLevelMessage.activity); } m_ThresholdPassedCount = 0; } } // If message is available, fire message otherwise set the finalized flag. if (activity != null) { m_Bot.SimulateMessageReceived(activity); } else { finalized = true; } }