public void SetBadgeTier(int tier) { m_AnimationQueue.Clear(); m_FadeInDirector.RemoveTweenersAfter(-1); m_FadeOutDirector.RemoveTweenersAfter(-1); m_AnimationQueue.Enqueue(m_FadeInDirectorAnimation); QueueableAnimationSynchronizer synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); for (int i = 0; i < m_BadgeService.streakLevels[tier]; ++i) { Transform trans = transform.GetChild(i); trans.gameObject.SetActive(true); StreakParticleBadgeViewController viewController = trans.GetComponent <StreakParticleBadgeViewController>(); viewController.SetBadgeTier(tier); viewController.blendInTweener.delayTime = 0.2f * i; m_FadeInDirector.AddTweener(viewController.blendInTweener); m_FadeOutDirector.AddTweener(viewController.blendOutTweener); synchedAnim.Append(viewController.queueableParticleAnimation); } for (int i = m_BadgeService.streakLevels[tier]; i < transform.childCount; ++i) { transform.GetChild(i).gameObject.SetActive(false); } m_AnimationQueue.Enqueue(synchedAnim); m_AnimationQueue.Enqueue(m_FadeOutDirectorAnimation); }
/// <inheritdoc /> public void SetData(WorkflowStepData[] data) { m_AnimationQueue.Clear(); m_PrevRepetitions = 0; for (int i = 0; i < m_TimelineItems.Length; ++i) { Destroy(m_TimelineItems[i].gameObject); } while (m_TimelineBackgroundContainer.childCount > 0) { Destroy(m_TimelineBackgroundContainer.GetChild(0)); } Array.Resize(ref m_TimelineItems, data?.Length ?? 0); QueueableAnimationSynchronizer animSync = QueueableAnimationSynchronizer.Pool.Spawn(); for (int i = 0; i < m_TimelineItems.Length; ++i) { m_TimelineItems[i] = m_TimelineItemFactory.Create(data[i]); m_TimelineItems[i].gameObject.transform.SetParent(m_TimelineItemContainer, false); if (data[i].repetitions > 0) { animSync.Append(m_TimelineItems[i].progressResetAnimation); } } m_AnimationQueue.Enqueue(animSync); CalculateSpacing(data); }
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 void SetBadgeData(BadgeData data, bool applyInstantly = false) { // fast int fastCount = data.GetWeightedTimeTotalCount(); m_FastBadge.SetCounterTarget(m_FastBadge.currentValue + fastCount); // streak int streakCount = data.GetWeightedStreakTotalCount(); m_StreakBadge.SetCounterTarget(m_StreakBadge.currentValue + streakCount); // amount int amountCount = data.GetWeightedAmountTotalCount(); m_AmountBadge.SetCounterTarget(m_AmountBadge.currentValue + amountCount); if (applyInstantly) { m_AmountBadge.Play(); m_FastBadge.Play(); m_StreakBadge.Play(); return; } QueueableAnimationSynchronizer synchedAnim = null; if (amountCount > 0) { int badgeTier = data.AmountBadges[2] > 0 ? 2 : data.AmountBadges[1] > 0 ? 1 : 0; // fade out badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); m_AmountBadge.SetTier(badgeTier); m_AmountAnimationColorizer.SetTier((uint)badgeTier); synchedAnim.Append(m_AmountBadge.tierFadeInTweener, m_FastBadge.fadeOutTweener, m_StreakBadge.fadeOutTweener); m_AnimationQueue.Enqueue(synchedAnim); // badge counter + top bar highlight animation synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_AmountBadge, m_AmountAnimation); m_AnimationQueue.Enqueue(synchedAnim); // fade int badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_AmountBadge.tierFadeOutTweener, m_FastBadge.fadeInTweener, m_StreakBadge.fadeInTweener); m_AnimationQueue.Enqueue(synchedAnim); } if (fastCount > 0) { int badgeTier = data.TimeBadges[2] > 0 ? 2 : data.TimeBadges[1] > 0 ? 1 : 0; // fade out badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); m_FastBadge.SetTier(badgeTier); m_FastAnimationColorizer.SetTier((uint)badgeTier); synchedAnim.Append(m_AmountBadge.fadeOutTweener, m_FastBadge.tierFadeInTweener, m_StreakBadge.fadeOutTweener); m_AnimationQueue.Enqueue(synchedAnim); // badge counter + top bar highlight animation synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_FastBadge, m_FastAnimation); m_AnimationQueue.Enqueue(synchedAnim); // fade int badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_AmountBadge.fadeInTweener, m_FastBadge.tierFadeOutTweener, m_StreakBadge.fadeInTweener); m_AnimationQueue.Enqueue(synchedAnim); } if (streakCount > 0) { int badgeTier = data.StreakBadges[2] > 0 ? 2 : data.StreakBadges[1] > 0 ? 1 : 0; // fade out badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); m_StreakBadge.SetTier(badgeTier); synchedAnim.Append(m_AmountBadge.fadeOutTweener, m_FastBadge.fadeOutTweener, m_StreakBadge.tierFadeInTweener); m_AnimationQueue.Enqueue(synchedAnim); // badge counter + top bar highlight animation m_StreakAnimation.SetBadgeTier(badgeTier); synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_StreakBadge, m_StreakAnimation); m_AnimationQueue.Enqueue(synchedAnim); // fade int badges synchedAnim = QueueableAnimationSynchronizer.Pool.Spawn(); synchedAnim.Append(m_AmountBadge.fadeInTweener, m_FastBadge.fadeInTweener, m_StreakBadge.tierFadeOutTweener); m_AnimationQueue.Enqueue(synchedAnim); } }