Пример #1
0
        public void ResetMaxComboStreak()
        {
            var achievements = AchievementsService.GetAchievements();

            achievements.MaxComboStreak = 0;
            AchievementsService.SaveToStorage(achievements);
        }
Пример #2
0
        public void OnTextBufferChanged(IAdornmentLayer adornmentLayer, IWpfTextView view, int streakCount)
        {
            if (titleImage == null)
            {
                titleImage = new Image();
                titleImage.UpdateSource(GetTitleImage(IsDarkMode(view.Background)));
                adornmentLayer.RefreshImage(titleImage, view.ViewportRight - RightMargin - ADORNMENT_WIDTH, view.ViewportTop + TopMargin);
            }


            var comboNumberImageTuple = GetStreakCounterImage(streakCount);

            if (streakCounterImage == null)
            {
                streakCounterImage = new Image();
            }
            streakCounterImage.UpdateSource(comboNumberImageTuple.Item1);
            adornmentLayer.RefreshImage(streakCounterImage, view.ViewportRight - RightMargin - ADORNMENT_WIDTH, view.ViewportTop + TopMargin + ADORNMENT_TITLE_HEIGHT);

            ScaleTransform trans = new ScaleTransform();

            streakCounterImage.RenderTransformOrigin = new Point((ADORNMENT_WIDTH - comboNumberImageTuple.Item2.Width / 2) / ADORNMENT_WIDTH, (comboNumberImageTuple.Item2.Height / 2) / comboNumberImageTuple.Item2.Height);
            streakCounterImage.RenderTransform       = trans;

            trans.BeginAnimation(ScaleTransform.ScaleXProperty, GetStreakCounterImageSizeAnimation(streakCount));
            trans.BeginAnimation(ScaleTransform.ScaleYProperty, GetStreakCounterImageSizeAnimation(streakCount));


            if (ComboService.ShowExclamation(streakCount))
            {
                ShowExclamation(adornmentLayer, view, GetExclamationImage(streakCount), comboNumberImageTuple.Item2.Height);
            }

            var achievevments = AchievementsService.GetAchievements();

            if (streakCount > 0 && achievevments.MaxComboStreak < streakCount && !newMaxComboStreakReached)
            {
                ShowExclamation(adornmentLayer, view, GetNewMaxExclamationImage(streakCount), comboNumberImageTuple.Item2.Height);
                newMaxComboStreakReached = true;
            }

            if (streakCount == 0 && newMaxComboStreak > 0)
            {
                achievevments.MaxComboStreak = newMaxComboStreak;
                AchievementsService.SaveToStorage(achievevments);
                newMaxComboStreakReached = false;
            }
            newMaxComboStreak = streakCount;
        }