コード例 #1
0
 public void Check(double score, BadgeData badgeData)
 {
     if (score < 50)
     {
         ++badgeData.SmileLessThen50Days;
     }
 }
コード例 #2
0
        public SocialViewModel(BadgeData badgeData) : base(badgeData, Capitalize(badgeData.LeftText))
        {
            // original template: 
            //  ImageWidth:  it.widths[0] + 1 + (it.text[1] && it.text[1].length > 0 ? it.widths[1]+2 : 0)
            //  widths: [leftWidth + 10 + logoWidth + logoPadding, rightWidth + 10]

            m_Widths[0] = m_LeftTextWidth + 10;
            m_Widths[1] = m_RightTextWidth + 10;

            ImageWidth = m_Widths[0] + 1 + (Text[1] != null && Text[1].Length > 0 ? m_Widths[1] + 2 : 0);

            // As in the original template, decrement widths[1] by four after calculating image width
            // {{it.widths[1]-=4;}}
            m_Widths[1] -= 4;

            {
                // value in original template: {{=((it.widths[0]+it.logoWidth+it.logoPadding)/2)*10}}
                var x1 = (m_Widths[0] / 2) * 10;

                // value in original template: {{=(it.widths[0]+it.widths[1]/2+6)*10}}
                var x2 = (m_Widths[0] + m_Widths[1] / 2 + 6) * 10;

                TextPosition = new[] { new Point(x1, 0), new Point(x2, 0) };
            }
            {
                // value in original template: {{=(it.widths[0]-(10+it.logoWidth+it.logoPadding))*10}}
                var textWidth1 = (Widths[0] - 10) * 10;

                // value in original template: {{=(it.widths[1]-8)*10}}
                var textWidth2 = (Widths[1] - 8) * 10;

                TextWidth = new[] { textWidth1, textWidth2 };
            }
        }
コード例 #3
0
        /// <inheritdoc/>
        public void UpdateUserData()
        {
            BadgeData    badgeData   = m_BadgeService.currentBadges;
            IUserProfile currentUser = m_UserManager.CurrentUser;

            currentUser.totalBadgeCount += badgeData.GetWeightedAmountTotalCount();
        }
コード例 #4
0
 public void Check(double score, BadgeData badgeData)
 {
     if (score.ToString("0.00").Equals("100.00"))
     {
         ++badgeData.Smile100Days;
     }
 }
コード例 #5
0
 private void GetData()
 {
     _playerData      = FileOperations.Deserialize <PlayerData>(_playerDataFileName);
     _badgeData       = FileOperations.Deserialize <BadgeData>(_badgeDataFileName);
     _automationsData = FileOperations.Deserialize <AutomationsData>(_automationsDataFileName);
     _settingsData    = FileOperations.Deserialize <SettingsData>(_settingsDataFileName);
 }
コード例 #6
0
        internal static ViewModelBase GetViewModel(
            BadgeStyle style,
            string leftText,
            string rightText,
            string color      = null,
            string labelColor = null,
            Uri leftLink      = null,
            Uri rightLink     = null)
        {
            leftText  = leftText ?? "";
            rightText = rightText ?? "";

            leftText  = leftText.Trim();
            rightText = rightText.Trim();

            var badgeData = new BadgeData(
                leftText: leftText,
                rightText: rightText,
                leftLink: leftLink,
                rightLink: rightLink,
                colorA: Color.Get(labelColor),
                colorB: Color.Get(color)
                );

            return(GetViewModel(style, badgeData));
        }
コード例 #7
0
 public void Check(double score, BadgeData badgeData)
 {
     if (score >= 80)
     {
         ++badgeData.Smile80Days;
     }
 }
コード例 #8
0
        public void OnEvent(WorkflowLoadArgs arg)
        {
            m_CurrentBadges = BadgeData.Empty;
            int repetitionAmount = 0;
            int stepAmount       = 0;

            foreach (WorkflowStepData stepData in m_WorkflowService.currentWorkflowData.steps)
            {
                repetitionAmount = stepData.repetitions < repetitionAmount ? repetitionAmount : stepData.repetitions;
                if (stepData.repetitions > 0 && !stepData.automatic)
                {
                    ++stepAmount;
                }
            }
            ++repetitionAmount;
            m_AmountLevels = new int[] { Mathf.FloorToInt(repetitionAmount * 0.5f),
                                         Mathf.FloorToInt(repetitionAmount * 0.75f),
                                         repetitionAmount };
            m_FastLevels = new int[] { 0, Mathf.FloorToInt(stepAmount * 0.5f), stepAmount };
            //TODO: move this to a workflow configuration
            m_StreakLevels = new int[] { Mathf.FloorToInt(stepAmount * repetitionAmount * 0.5f),
                                         Mathf.FloorToInt(stepAmount * repetitionAmount * 0.75f),
                                         stepAmount *repetitionAmount };

            m_StreakCounter   = 0;
            m_FastCounter     = 0;
            m_PrevRepetitions = 0;
        }
コード例 #9
0
    public void Init(BadgeData badgeData)
    {
        _badgeData = badgeData;

        _badgeData.HpChanged    += UpdateSlider;
        _badgeData.MaxHpChanged += UpdateMaxSliderValue;
    }
コード例 #10
0
 public void OnBadgeCreated(BadgeData badgeData)
 {
     Debug.Log("Badge Created?????");
     //_badgePresentation.OnBadgeCreated();
     foreach (var mothership in _droppable)
     {
         mothership.Spawn(mothership.transform.position);
     }
 }
コード例 #11
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge105_30Days100)
     {
         if (badgeData.Smile100Days >= 30)
         {
             badgeData.Badge105_30Days100 = true;
         }
     }
 }
コード例 #12
0
 public BadgeBusinessRules(PlayerData playerData,
                           BadgeData badgeData,
                           AutomationsData automationsData,
                           IBossCountdown bossCountdown)
 {
     _playerData      = playerData;
     _badgeData       = badgeData;
     _automationsData = automationsData;
     _bossCountdown   = bossCountdown;
 }
コード例 #13
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge006_300DaysRecord)
     {
         if (badgeData.RecordDays >= 300)
         {
             badgeData.Badge006_300DaysRecord = true;
         }
     }
 }
コード例 #14
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge801_3DaysLessThan50)
     {
         if (badgeData.SmileLessThen50Days >= 3)
         {
             badgeData.Badge801_3DaysLessThan50 = true;
         }
     }
 }
コード例 #15
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge001_FirstRecord)
     {
         if (badgeData.RecordDays >= 1)
         {
             badgeData.Badge001_FirstRecord = true;
         }
     }
 }
コード例 #16
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge101_3Days80)
     {
         if (badgeData.Smile80Days >= 3)
         {
             badgeData.Badge101_3Days80 = true;
         }
     }
 }
コード例 #17
0
 public void Check(double score, BadgeData badgeData)
 {
     if (!badgeData.Badge102_3Days90)
     {
         if (badgeData.Smile90Days >= 3)
         {
             badgeData.Badge102_3Days90 = true;
         }
     }
 }
コード例 #18
0
 public void Init(
     PlayerData playerData,
     AutomationsData automationsData,
     BadgeData badgeData,
     DefaultAutomationsData defaultAutomations)
 {
     _progressResetter = new ProgressResetter(defaultAutomations);
     _playerData       = playerData;
     _automationsData  = automationsData;
     _badgeData        = badgeData;
 }
コード例 #19
0
    public void Init(PlayerData playerData, BadgeData badgeData, AutomationsData automationsData)
    {
        _playerData      = playerData;
        _badgeData       = badgeData;
        _automationsData = automationsData;

        if (_playerData.IsReturningPlayer && _automationsData.AutomationsPower > 0)
        {
            InitPanel();
        }
    }
コード例 #20
0
        public void Init(BadgeData badgeData, BadgeBusinessRules businessRules)
        {
            _badgeData          = badgeData;
            _badgeBusinessRules = businessRules;

            if (_badgeSpriteComponents.Contains(_badgeSprite) == false)
            {
                throw new Exception("BadgeSticker is not assigned!");
            }
            _badgeSpriteComponents[_badgeSpriteComponents.IndexOf(_badgeSprite)] = _badgeSprite;
        }
コード例 #21
0
        public void 連續超過80分的天數_超過80分時天數加1()
        {
            var badgeData = new BadgeData();

            badgeData.Smile80Days = 5;
            var score   = 80;
            var checker = new Smile80DaysChecker();

            checker.Check(score, badgeData);

            Assert.AreEqual(6, badgeData.Smile80Days);
        }
コード例 #22
0
        public void 連續超過80分的天數_未達80分時天數加0()
        {
            var badgeData = new BadgeData();

            badgeData.Smile80Days = 5;
            var score   = 79.99999;
            var checker = new Smile80DaysChecker();

            checker.Check(score, badgeData);

            Assert.AreEqual(5, badgeData.Smile80Days);
        }
コード例 #23
0
        public void 連續未滿50分的天數_未滿50分時天數加1()
        {
            var badgeData = new BadgeData();

            badgeData.SmileLessThen50Days = 5;
            var score   = 49.9999;
            var checker = new SmileLessThen50DaysChecker();

            checker.Check(score, badgeData);

            Assert.AreEqual(6, badgeData.SmileLessThen50Days);
        }
コード例 #24
0
        public void 連續達到100分的天數_高達100分時天數加1()
        {
            var badgeData = new BadgeData();

            badgeData.Smile100Days = 5;
            var score   = 99.99999;
            var checker = new Smile100DaysChecker();

            checker.Check(score, badgeData);

            Assert.AreEqual(6, badgeData.Smile100Days);
        }
コード例 #25
0
        public void Check(double score, BadgeData badgeData)
        {
            var lastRecordDate = Convert.ToDateTime(badgeData.LastRecordDate);

            if (IsContinuousDay(DateTime.Now.AddDays(-1), lastRecordDate))
            {
                badgeData.RecordDays++;
            }
            else
            {
                badgeData.RecordDays = 1;
            }
        }
コード例 #26
0
        public object Convert(object value)
        {
            if (value == null)
            {
                return(m_NoBadgesGradient);
            }

            if (!(value is BadgeData))
            {
                throw new ArgumentException($"Expected {typeof(BadgeData)}.", nameof(value));
            }

            Gradient  gradient = new Gradient();
            BadgeData badges   = (BadgeData)value;

            if (badges.Equals(default(BadgeData)))
            {
                return(m_NoBadgesGradient);
            }

            // fast
            int fastCount = badges.TimeBadges.x + badges.TimeBadges.y + badges.TimeBadges.z;
            // streak
            int streakCount = badges.StreakBadges.x + badges.StreakBadges.y + badges.StreakBadges.z;
            // amount
            int amountCount = badges.AmountBadges.x + badges.AmountBadges.y + badges.AmountBadges.z;

            int total = fastCount + streakCount + amountCount;

            int tier1Count = badges.GetTotalCount(1);
            int tier2Count = badges.GetTotalCount(2);

            float tier1Normalized = (float)tier1Count / total;
            float tier2Normalized = (float)tier2Count / total;


            gradient.colorKeys = new GradientColorKey[]
            {
                new GradientColorKey(m_Colors[0], 0f),
                new GradientColorKey(m_Colors[1], tier1Normalized),
                new GradientColorKey(m_Colors[2], tier1Normalized + tier2Normalized),
                new GradientColorKey(m_Colors[3], 1f)
            };

            return(gradient);
        }
コード例 #27
0
        protected ViewModelBase(BadgeData badgeData, string?leftTextOverride = null, string?rightTextOverride = null)
        {
            m_BadgeData = badgeData ?? throw new ArgumentNullException(nameof(badgeData));

            // if left or right text is empty, replace it with null.
            // This makes checking the value in the liquid templates easier
            // as they do not need to check for null *or* empty
            // Both cases are treated the same anyways
            var leftText  = NullIfEmptyString(leftTextOverride ?? badgeData.LeftText);
            var rightText = NullIfEmptyString(rightTextOverride ?? badgeData.RightText);

            m_LeftTextWidth  = GetTextWidth(leftText);
            m_RightTextWidth = GetTextWidth(rightText);

            Text = new[] { EscapeXml(leftText), EscapeXml(rightText) };

            Links = new[] { NullIfEmptyString(badgeData.LeftLink?.ToString()), NullIfEmptyString(badgeData.RightLink?.ToString()) ?? NullIfEmptyString(badgeData.LeftLink?.ToString()) };
        }
        public void OnNavigatedTo(INavigationParameters navigationParameters)
        {
            BadgeData data = m_BadgeService.currentBadges;

            string reward = "Balloons";

            navigationParameters.TryGetValue("Reward", out reward);

            m_RewardParticleSystemFactory.Create(reward, new RewardParticleSystemFactoryParams(new SubEmitterParams(data.AmountBadges[0], data.AmountBadges[1], data.AmountBadges[2]),
                                                                                               new SubEmitterParams(data.TimeBadges[0], data.TimeBadges[1], data.TimeBadges[2]),
                                                                                               new SubEmitterParams(data.StreakBadges[0], data.StreakBadges[1], data.StreakBadges[2])));
            // Use this for testing:

            /*m_RewardParticleSystemFactory.Create(reward, new RewardParticleSystemFactoryParams(new SubEmitterParams(10, 0, 0),
             *                                                                                   new SubEmitterParams(0, 0, 0),
             *                                                                                   new SubEmitterParams(0, 0, 0)));*/

            m_ParticleSystem.GetComponent <ParticleSystemStoppedEventBridge>().particleSystemStopped.AddListener(ParticleSystemStopped);
            m_ParticleSystem.GetComponent <ParticleSystemStoppedEventBridge>().PlayAll();
        }
コード例 #29
0
        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;
        }
コード例 #30
0
        public void OnNavigatedTo(INavigationParameters navigationParameters)
        {
            // Create a tupled list
            List <(DateTime dateTime, BadgeData badgeData)> history = new List <(DateTime, BadgeData)>();

            for (int i = 0; i < m_UserProfile.badges.Count; i++)
            {
                history.Add((m_UserProfile.badgeDates[i], m_UserProfile.badges[i]));
            }

            // Sort from new to old
            history.Sort((x, y) => y.dateTime.CompareTo(x.dateTime));

            BadgeData data = history.FirstOrDefault().badgeData;

            m_RewardParticleSystemFactory.Create(m_UserProfile.selectedReward, new RewardParticleSystemFactoryParams(new SubEmitterParams(data.AmountBadges.x, data.AmountBadges.y, data.AmountBadges.z),
                                                                                                                     new SubEmitterParams(data.TimeBadges.x, data.TimeBadges.y, data.TimeBadges.z),
                                                                                                                     new SubEmitterParams(data.StreakBadges.x, data.StreakBadges.y, data.StreakBadges.z)));

            m_ParticleSystem.GetComponent <ParticleSystemStoppedEventBridge>().particleSystemStopped.AddListener(ParticleSystemStopped);
            m_ParticleSystem.GetComponent <ParticleSystemStoppedEventBridge>().PlayAll();
        }