コード例 #1
0
        private Mascot getMascotClosestToNextLevel()
        {
            ProgressionService progressionService = Service.Get <ProgressionService>();
            Mascot             mascot             = null;

            foreach (Mascot mascot2 in Service.Get <MascotService>().Mascots)
            {
                if (mascot2.IsQuestGiver && (mascot == null || progressionService.MascotLevelPercent(mascot2.Definition.name) > progressionService.MascotLevelPercent(mascot.Definition.name)))
                {
                    mascot = mascot2;
                }
            }
            return(mascot);
        }
コード例 #2
0
        private void addProgressionWidget(Dictionary <CellPhoneActivityDefinition, int> widgetToPriority)
        {
            ProgressionService progressionService = Service.Get <ProgressionService>();

            if (definition.ProgressionPriority != ActivityScreenPriorities.Hidden && progressionService.Level < progressionService.MaxUnlockLevel)
            {
                Mascot mascotClosestToNextLevel = getMascotClosestToNextLevel();
                if (mascotClosestToNextLevel != null && progressionService.MascotLevelPercent(mascotClosestToNextLevel.Name) >= definition.PercentToNextLevelToShowProgressionWidget)
                {
                    string tipForMascot = getTipForMascot(mascotClosestToNextLevel.Definition);
                    Reward rewardForProgressionLevel = getRewardForProgressionLevel(progressionService.Level + 1);
                    CellPhoneProgressionActivityDefinition cellPhoneProgressionActivityDefinition = ScriptableObject.CreateInstance <CellPhoneProgressionActivityDefinition>();
                    cellPhoneProgressionActivityDefinition.Mascot          = mascotClosestToNextLevel;
                    cellPhoneProgressionActivityDefinition.TipToken        = tipForMascot;
                    cellPhoneProgressionActivityDefinition.RewardItems     = rewardForProgressionLevel;
                    cellPhoneProgressionActivityDefinition.WidgetPrefabKey = definition.ProgressionWidgetKey;
                    widgetToPriority.Add(cellPhoneProgressionActivityDefinition, (int)definition.ProgressionPriority);
                }
            }
        }
コード例 #3
0
        public int SetUpMascotLevel(bool isLocalPlayer, ProfileData profileData = null, long mascotXPLevel = -1L)
        {
            MascotDefinition   definition         = Service.Get <MascotService>().GetMascot(MascotKey.Id).Definition;
            ProgressionService progressionService = Service.Get <ProgressionService>();
            int   result = 0;
            float num    = 0f;
            bool  flag   = false;

            if (isLocalPlayer)
            {
                if (mascotXPLevel > -1)
                {
                    result = ProgressionService.GetMascotLevelFromXP(mascotXPLevel);
                    num    = ProgressionService.GetMascotLevelPercentFromXP(mascotXPLevel);
                    flag   = progressionService.IsMascotMaxLevel(definition.name, mascotXPLevel);
                }
                else
                {
                    result = progressionService.MascotLevel(definition.name);
                    num    = progressionService.MascotLevelPercent(definition.name);
                    flag   = progressionService.IsMascotMaxLevel(definition.name);
                }
            }
            else
            {
                if (profileData == null)
                {
                    throw new ArgumentNullException("profileData", "Profile data cannot be null if we are not viewing the local player");
                }
                if (MaxLevelText != null)
                {
                    MaxLevelText.SetActive(value: false);
                }
                if (profileData.MascotXP != null && profileData.MascotXP.TryGetValue(definition.name, out var value))
                {
                    result = ProgressionService.GetMascotLevelFromXP(value);
                    num    = ProgressionService.GetMascotLevelPercentFromXP(value);
                    flag   = progressionService.IsMascotMaxLevel(definition.name, value);
                }
            }
            if (MaxLevelText != null && ProgressBarGraphic != null)
            {
                if (flag)
                {
                    MaxLevelText.SetActive(value: true);
                    ProgressBarGraphic.color = new Color(1f, 1f, 1f, 0.4f);
                }
                else
                {
                    MaxLevelText.SetActive(value: false);
                    ProgressBarGraphic.color = new Color(1f, 1f, 1f, 1f);
                }
            }
            LevelText.text = result.ToString();
            if (ExperienceProgressBar != null)
            {
                if (num >= 0.95f && num < 1f)
                {
                    ExperienceProgressBar.AnimateProgress(0.95f);
                }
                else
                {
                    ExperienceProgressBar.AnimateProgress(num);
                }
            }
            return(result);
        }