private IEnumerator updateXpDisplay() { ProgressionService progressionService = Service.Get <ProgressionService>(); Service.Get <EventDispatcher>().DispatchEvent(default(HudEvents.XPAdditionStart)); state = XPHudState.addingXP; int xpDelta = progressionService.MascotLevelXpDelta(currentMascotName, currentMascotLevel); int mascotLevelWithOffset = ProgressionService.GetMascotLevelFromXP(currentMascotLevel); float additionDelay = 2f / ((float)(targetMacotLevel - currentMascotLevel) / (float)xpDelta); bool leveledUp = false; while (currentMascotLevel < targetMacotLevel) { if (mascotLevelWithOffset != ProgressionService.GetMascotLevelFromXP(currentMascotLevel)) { mascotLevelWithOffset = ProgressionService.GetMascotLevelFromXP(currentMascotLevel); ShowLevelUp(Service.Get <ProgressionService>().Level); leveledUp = true; xpDelta = progressionService.MascotLevelXpDelta(currentMascotName, currentMascotLevel); } float percent = ProgressionService.GetMascotLevelPercentFromXP(currentMascotLevel); currentXpDisplay.LevelProgressImage.fillAmount = percent; yield return(new WaitForSeconds(additionDelay)); currentMascotLevel += xpDelta; } if (!leveledUp && mascotLevelWithOffset != ProgressionService.GetMascotLevelFromXP(targetMacotLevel)) { ShowLevelUp(Service.Get <ProgressionService>().Level); } currentXpDisplay.DisableParticleSystems(); state = XPHudState.waitingToClose; Service.Get <EventDispatcher>().DispatchEvent(default(HudEvents.XPAdditionStop)); Invoke("hideXpHud", HIDE_DELAY_TIME); }
private void Start() { unlockedItemsList = new List <T>(UnlockedArrayIncrement); progressionService = Service.Get <ProgressionService>(); questService = Service.Get <QuestService>(); itemGroups = new List <ItemGroup>(); localizer = Service.Get <Localizer>(); layoutElementPool = GetComponent <HorizontalScrollingLayoutElementPool>(); HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool = layoutElementPool; horizontalScrollingLayoutElementPool.OnPoolReady = (System.Action)Delegate.Combine(horizontalScrollingLayoutElementPool.OnPoolReady, new System.Action(onPoolReady)); HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool2 = layoutElementPool; horizontalScrollingLayoutElementPool2.OnElementShown = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool2.OnElementShown, new Action <int, GameObject>(onElementShown)); HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool3 = layoutElementPool; horizontalScrollingLayoutElementPool3.OnElementHidden = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool3.OnElementHidden, new Action <int, GameObject>(onElementHidden)); HorizontalScrollingLayoutElementPool horizontalScrollingLayoutElementPool4 = layoutElementPool; horizontalScrollingLayoutElementPool4.OnElementRefreshed = (Action <int, GameObject>)Delegate.Combine(horizontalScrollingLayoutElementPool4.OnElementRefreshed, new Action <int, GameObject>(onElementRefreshed)); zeroSpacing = Vector2.zero; groupSpacing = new Vector2(GroupSpacing, 0f); combinedGroupSpacing = new Vector2(CombinedGroupSpacing, 0f); spacingRulesMap = getSpacingRulesMap(); parseItemGroups(); Content.LoadAsync(onItemLoaded, ItemContentKey); Content.LoadAsync(onLockedItemsLoaded, LockedItemsContentKey); Content.LoadAsync(onGameObjectPoolLoaded, gameObjectPoolContentKey); start(); }
public async Task Get_Single_Progression(User user, Subject subject, Concept concept) { var context = TestSetup.SetupContext(); var progression = new Progression { UserId = user.Id, User = user, SubjectId = subject.Id, Subject = subject, ConceptId = concept.Id, Concept = concept }; await context.Users.AddAsync(user); await context.Subjects.AddAsync(subject); await context.Concepts.AddAsync(concept); await context.Progressions.AddAsync(progression); await context.SaveChangesAsync(); var service = new ProgressionService(context); var result = await service.Get(user, subject); result.Should().NotBeNull().And.BeEquivalentTo(progression); }
private void setRewards() { ProgressionService progressionService = Service.Get <ProgressionService>(); YourRewardsText.text = Service.Get <Localizer>().GetTokenTranslation("PartyGames.ScavengerHunt.YourRewards"); CPRewardDefinition cPRewardDefinition = (isWinner ? ((CPRewardDefinition)scavengerHuntData.WinRewardDefinition) : ((CPRewardDefinition)scavengerHuntData.LoseRewardDefinition)); CoinText.text = cPRewardDefinition.Coins.Amount.ToString(); bool flag = false; int num = 0; MascotXPRewardDefinition[] mascotXP = cPRewardDefinition.MascotXP; for (int i = 0; i < mascotXP.Length; i++) { num += mascotXP[i].XP; MascotDefinition mascot = mascotXP[i].Mascot; flag = progressionService.IsMascotMaxLevel(mascot.name); } if (num > 0) { if (flag) { XPText.gameObject.SetActive(value: false); MaxLevelText.SetActive(value: true); } else { XPText.text = num.ToString(); } } else { XPPanel.SetActive(value: false); } }
public async Task Check_If_Progression_Exists(User user, User badUser, Subject subject, Concept concept) { var context = TestSetup.SetupContext(); var progression = new Progression { UserId = user.Id, User = user, SubjectId = subject.Id, Subject = subject, ConceptId = concept.Id, Concept = concept }; await context.Users.AddRangeAsync(user, badUser); await context.Subjects.AddAsync(subject); await context.Concepts.AddAsync(concept); await context.Progressions.AddAsync(progression); await context.SaveChangesAsync(); var service = new ProgressionService(context); var result = await service.Exists(user, subject); var badResult = await service.Exists(badUser, subject); result.Should().BeTrue(); badResult.Should().BeFalse(); }
public void Init(string categoryToSelect) { this.categoryToSelect = categoryToSelect; progressionService = Service.Get <ProgressionService>(); displayedTemplates = new List <DisplayedTemplate>(); rewardTemplates = new List <DisplayedTemplate>(); if (inventoryData == null) { DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (!localPlayerHandle.IsNull) { inventoryData = Service.Get <CPDataEntityCollection>().GetComponent <InventoryData>(localPlayerHandle); if (inventoryData != null) { parseItemGroups(); setCategories(inventoryData.CategoryKeys, categoryToSelect); setupListeners(); setupPooledScrollRect(); } else { Log.LogError(this, "Unable to locate InventoryData object."); } } } else { parseItemGroups(); setupListeners(); setupPooledScrollRect(); } }
private void showCoinXPReward(Reward reward) { CoinsData component = dataEntityCollection.GetComponent <CoinsData>(dataEntityCollection.LocalPlayerHandle); if (reward.TryGetValue <CoinReward>(out var rewardable) && rewardable.Coins > 0) { component.RemoveCoins(rewardable.Coins); component.AddCoins(rewardable.Coins); } if (reward.TryGetValue <MascotXPReward>(out var rewardable2)) { using (Dictionary <string, int> .Enumerator enumerator = rewardable2.XP.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair <string, int> current = enumerator.Current; ProgressionService progressionService = Service.Get <ProgressionService>(); if (!progressionService.IsMascotMaxLevel(current.Key)) { dispatcher.DispatchEvent(new RewardEvents.AddXP(current.Key, progressionService.GetMascotXP(current.Key, -current.Value), progressionService.GetMascotXP(current.Key), current.Value, showReward: true)); } } } } RewardPopup.ShowReward(reward, lastSpinOutcomeId == widgetData.RespinSpinOutcomeId); }
public async Task Create_Progression(User user, Subject subject, Concept concept) { var context = TestSetup.SetupContext(); var progression = new Progression { UserId = user.Id, User = user, SubjectId = subject.Id, Subject = subject, ConceptId = concept.Id, Concept = concept }; await context.Users.AddAsync(user); await context.Subjects.AddAsync(subject); await context.Concepts.AddAsync(concept); await context.SaveChangesAsync(); var service = new ProgressionService(context); var result = await service.Create(user, subject, concept); var storedResult = context.Progressions.FirstOrDefault(); result.Should().BeTrue(); storedResult.Should().NotBeNull().And.BeEquivalentTo(progression, TestSetup.IgnoreTimestamps <Progression>()); }
private void logSpinBI(Reward reward, Reward chestReward) { string tier = ""; CoinReward rewardable; MascotXPReward rewardable2; if (lastSpinOutcomeId == widgetData.ChestSpinOutcomeId) { tier = "Chest"; } else if (reward.TryGetValue <CoinReward>(out rewardable) && rewardable.Coins > 0) { tier = "Coins"; } else if (reward.TryGetValue <MascotXPReward>(out rewardable2)) { using (Dictionary <string, int> .Enumerator enumerator = rewardable2.XP.GetEnumerator()) { if (enumerator.MoveNext()) { KeyValuePair <string, int> current = enumerator.Current; ProgressionService progressionService = Service.Get <ProgressionService>(); tier = ((!progressionService.IsMascotMaxLevel(current.Key)) ? "XP" : "Party Blaster"); } } } Service.Get <ICPSwrveService>().Action("daily_spin", currentChestDefinition.ChestNameToken, tier); }
private void Start() { progressionService = Service.Get <ProgressionService>(); PopupButton.SetActive(value: false); screenAnimator = GetComponent <Animator>(); LoadingModal.SetActive(value: false); Service.Get <EventDispatcher>().DispatchEvent(default(RewardEvents.SuppressLevelUpPopup)); }
private void checkRemainingXP() { if (currentMascotLevel < targetMacotLevel && ProgressionService.GetMascotLevelFromXP(currentMascotLevel) != Service.Get <ProgressionService>().MascotLevel(currentMascotName)) { Reward rewardForProgressionLevel = RewardUtils.GetRewardForProgressionLevel(Service.Get <ProgressionService>().Level); ShowRewardPopup pendingLevelUpPopup = new ShowRewardPopup.Builder(DRewardPopup.RewardPopupType.levelUp, rewardForProgressionLevel).setMascotName(currentMascotName).Build(); Service.Get <ProgressionService>().PendingLevelUpPopup = pendingLevelUpPopup; } }
private void Awake() { iglooPropertiesCards = new Dictionary <long, IglooPropertiesCard>(); progressionData = new List <IglooSlotProgressionData>(); iglooCreateButtonList = new List <IglooCreateButton>(); eventDispatcher = Service.Get <EventDispatcher>(); dataEntityCollection = Service.Get <CPDataEntityCollection>(); iglooService = Service.Get <INetworkServicesManager>().IglooService; progressionService = Service.Get <ProgressionService>(); stateController = ClubPenguin.Core.SceneRefs.Get <IglooUIStateController>(); igloosCount = 3; createButtonCount = 3; }
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); }
protected override void onButtonClick() { GameObject gameObject = TooltipPrefab; ProgressionService progressionService = Service.Get <ProgressionService>(); if ((Mascot != null && progressionService.IsMascotMaxLevel(Mascot.name)) || (Mascot == null && progressionService.Level == progressionService.MaxUnlockLevel)) { gameObject = MaxLevelTooltipPrefab; } if (gameObject != null) { GameObject tooltip = Object.Instantiate(gameObject); Service.Get <EventDispatcher>().DispatchEvent(new TutorialUIEvents.ShowTooltip(tooltip, GetComponent <RectTransform>(), Offset, FullscreenClose)); } }
private void checkTutorial() { ProgressionService progressionService = Service.Get <ProgressionService>(); TutorialManager tutorialManager = Service.Get <TutorialManager>(); if (progressionService != null && tutorialManager != null) { if (progressionService.Level == progressionService.MaxUnlockLevel) { tutorialManager.TryStartTutorial(MaxLevelTutorialDefinition.Id); } else if (progressionService.Level == 1 || progressionService.Level == 2) { tutorialManager.TryStartTutorial(ProgressTutorialDefinition.Id); } } }
private DateTime?questAvailableDate(QuestDefinition def, Dictionary <string, long> mascotsXp) { if (def.LevelRequirement > 0) { long value = 0L; mascotsXp.TryGetValue(def.Mascot.name, out value); if (def.LevelRequirement > ProgressionService.GetMascotLevelFromXP(value)) { return(null); } } DateTime dateTime = DateTime.UtcNow.AddMinutes(-1.0); if (def.CompletedQuestRequirement != null && def.CompletedQuestRequirement.Length > 0) { List <QuestStates.QuestState> quests = Service.Get <OfflineDatabase>().Read <QuestStates>().Quests; Dictionary <string, DateTime> dictionary = new Dictionary <string, DateTime>(quests.Count); foreach (QuestStates.QuestState item in quests) { if (item.timesCompleted > 0) { dictionary.Add(item.questId, item.completedTime); } } QuestDefinition[] completedQuestRequirement = def.CompletedQuestRequirement; foreach (QuestDefinition questDefinition in completedQuestRequirement) { if (!dictionary.ContainsKey(questDefinition.name)) { return(null); } if (def.TimeLock.TimeSpan.TotalSeconds > 0.0) { DateTime dateTime2 = dictionary[questDefinition.name].Add(def.TimeLock.TimeSpan); if (dateTime < dateTime2) { dateTime = dateTime2; } } } } return(dateTime); }
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); } } }
private IEnumerator loadXPHudPrefab(PrefabContentKey contentKey, string mascotName) { AssetRequest <GameObject> assetRequest = Content.LoadAsync(contentKey, mascotName); yield return(assetRequest); GameObject xpGO = UnityEngine.Object.Instantiate(assetRequest.Asset); xpGO.transform.SetParent(XpHudParentTransform, worldPositionStays: false); currentXpDisplay = xpGO.GetComponent <XPHudItem>(); currentXpDisplay.LevelProgressImage.fillAmount = ProgressionService.GetMascotLevelPercentFromXP(currentMascotLevel); XPHudItem xPHudItem = currentXpDisplay; xPHudItem.IntroAnimationCompleteAction = (System.Action)Delegate.Combine(xPHudItem.IntroAnimationCompleteAction, new System.Action(OnXPIntroAnimationComplete)); XPHudItem xPHudItem2 = currentXpDisplay; xPHudItem2.OutroAnimationCompleteAction = (System.Action)Delegate.Combine(xPHudItem2.OutroAnimationCompleteAction, new System.Action(OnXPOutroAnimationComplete)); XPLayoutElement.preferredHeight = 130f; showXPHud(); }
private void setLevelText() { ProgressionService progressionService = Service.Get <ProgressionService>(); getMascotNames(); for (int i = 0; i < mascotNames.Count; i++) { if (mascotNames[i] == popupController.PopupData.MascotName) { CurrentMascotLevelText.text = progressionService.MascotLevel(mascotNames[i]).ToString(); PrevMascotLevelText.text = (progressionService.MascotLevel(mascotNames[i]) - 1).ToString(); } Text mascotLevelText = getMascotLevelText(mascotNames[i]); if (mascotLevelText != null) { mascotLevelText.text = progressionService.MascotLevel(mascotNames[i]).ToString(); } } CurrentOverallLevelText.text = progressionService.Level.ToString(); PrevOverallLevelText.text = (progressionService.Level - 1).ToString(); LevelUpStarsAnimator.SetTrigger(popupController.PopupData.MascotName); }
public void SetUpLevelText(bool isLocalPlayer, ProfileData profileData = null) { int num = 0; if (isLocalPlayer) { num = Service.Get <ProgressionService>().Level; } else { if (profileData == null) { throw new ArgumentNullException("profileData", "Profile data cannot be null if we are not viewing the local player"); } if (profileData.MascotXP != null) { foreach (KeyValuePair <string, long> item in profileData.MascotXP) { num += ProgressionService.GetMascotLevelFromXP(item.Value); } } } LevelText.text = num.ToString(); }
public async Task Get_All_Progressions_By_User(User user, List <Progression> validProgressions, List <Progression> invalidProgressions) { var context = TestSetup.SetupContext(); foreach (var progression in validProgressions) { progression.User = user; progression.UserId = user.Id; } await context.Users.AddAsync(user); await context.Progressions.AddRangeAsync(invalidProgressions); await context.Progressions.AddRangeAsync(validProgressions); await context.SaveChangesAsync(); var service = new ProgressionService(context); var result = await service.GetAll(user); result.Should().NotBeNull().And.BeEquivalentTo(validProgressions); }
public void AddReward(Reward reward, CPResponse responseBody) { ClubPenguin.Net.Offline.PlayerAssets value = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>(); ProgressionService progressionService = Service.Get <ProgressionService>(); if (reward.TryGetValue <CoinReward>(out var rewardable)) { value.Assets.coins += rewardable.Coins; } if (reward.TryGetValue <MascotXPReward>(out var rewardable2)) { foreach (KeyValuePair <string, int> item in rewardable2.XP) { if (value.Assets.mascotXP.ContainsKey(item.Key)) { value.Assets.mascotXP[item.Key] = progressionService.addXp(item.Key, item.Value, value.Assets.mascotXP[item.Key]); } else { value.Assets.mascotXP[item.Key] = progressionService.addXp(item.Key, item.Value, 0L); } } int level = progressionService.Level; int num = 0; foreach (long value5 in value.Assets.mascotXP.Values) { num += ProgressionService.GetMascotLevelFromXP(value5); } if (num > level) { if (responseBody.wsEvents == null) { responseBody.wsEvents = new List <SignedResponse <WebServiceEvent> >(); } responseBody.wsEvents.Add(new SignedResponse <WebServiceEvent> { Data = new WebServiceEvent { details = num, type = 3 } }); } } if (reward.TryGetValue <CollectibleReward>(out var rewardable3)) { foreach (KeyValuePair <string, int> collectible in rewardable3.Collectibles) { if (value.Assets.collectibleCurrencies.ContainsKey(collectible.Key)) { value.Assets.collectibleCurrencies[collectible.Key] += collectible.Value; } else { value.Assets.collectibleCurrencies[collectible.Key] = collectible.Value; } } } if (reward.TryGetValue <DecalReward>(out var rewardable4)) { value.Assets.decals.AddRange(rewardable4.Decals); } if (reward.TryGetValue <FabricReward>(out var rewardable5)) { value.Assets.fabrics.AddRange(rewardable5.Fabrics); } if (reward.TryGetValue <EmoteReward>(out var rewardable6)) { value.Assets.emotePacks.AddRange(rewardable6.Emotes); } if (reward.TryGetValue <EquipmentTemplateReward>(out var rewardable7)) { value.Assets.equipmentTemplates.AddRange(rewardable7.EquipmentTemplates); } if (reward.TryGetValue <EquipmentInstanceReward>(out var rewardable8)) { System.Random random = new System.Random(); byte[] array = new byte[8]; CustomEquipmentCollection value2 = offlineDatabase.Read <CustomEquipmentCollection>(); foreach (CustomEquipment equipmentInstance in rewardable8.EquipmentInstances) { random.NextBytes(array); value2.Equipment.Add(new CustomEquipment { dateTimeCreated = DateTime.UtcNow.GetTimeInMilliseconds(), definitionId = equipmentInstance.definitionId, equipmentId = BitConverter.ToInt64(array, 0), parts = equipmentInstance.parts }); } offlineDatabase.Write(value2); } if (reward.TryGetValue <LotReward>(out var rewardable9)) { value.Assets.lots.AddRange(rewardable9.Lots); } if (reward.TryGetValue <DecorationInstanceReward>(out var rewardable10)) { DecorationInventoryEntity value3 = offlineDatabase.Read <DecorationInventoryEntity>(); foreach (KeyValuePair <int, int> decoration in rewardable10.Decorations) { DecorationId decorationId = new DecorationId(decoration.Key, DecorationType.Decoration); if (value3.Inventory.ContainsKey(decorationId)) { value3.Inventory[decorationId] += decoration.Value; } else { value3.Inventory[decorationId] = decoration.Value; } } offlineDatabase.Write(value3); } if (reward.TryGetValue <StructureInstanceReward>(out var rewardable11)) { DecorationInventoryEntity value3 = offlineDatabase.Read <DecorationInventoryEntity>(); foreach (KeyValuePair <int, int> decoration2 in rewardable11.Decorations) { DecorationId decorationId = new DecorationId(decoration2.Key, DecorationType.Structure); if (value3.Inventory.ContainsKey(decorationId)) { value3.Inventory[decorationId] += decoration2.Value; } else { value3.Inventory[decorationId] = decoration2.Value; } } offlineDatabase.Write(value3); } if (reward.TryGetValue <DecorationReward>(out var rewardable12)) { value.Assets.decorations.AddRange(rewardable12.Decorations); } if (reward.TryGetValue <StructureReward>(out var rewardable13)) { value.Assets.structures.AddRange(rewardable13.Structures); } if (reward.TryGetValue <MusicTrackReward>(out var rewardable14)) { value.Assets.musicTracks.AddRange(rewardable14.MusicTracks); } if (reward.TryGetValue <LightingReward>(out var rewardable15)) { value.Assets.lighting.AddRange(rewardable15.Lighting); } if (reward.TryGetValue <DurableReward>(out var rewardable16)) { value.Assets.durables.AddRange(rewardable16.Durables); } if (reward.TryGetValue <IglooSlotsReward>(out var rewardable17)) { value.IglooSlots += rewardable17.IglooSlots; } if (reward.TryGetValue <ConsumableReward>(out var rewardable18)) { value.Assets.partySupplies.AddRange(rewardable18.Consumable); } if (reward.TryGetValue <TubeReward>(out var rewardable19)) { value.Assets.tubes.AddRange(rewardable19.Tubes); } if (reward.TryGetValue <ConsumableInstanceReward>(out var rewardable20)) { ClubPenguin.Net.Offline.ConsumableInventory value4 = offlineDatabase.Read <ClubPenguin.Net.Offline.ConsumableInventory>(); foreach (KeyValuePair <string, int> consumable in rewardable20.Consumables) { if (value4.Inventory.ContainsKey(consumable.Key)) { value4.Inventory[consumable.Key].itemCount += consumable.Value; } else { value4.Inventory[consumable.Key] = new InventoryItemStock { itemCount = consumable.Value }; } value4.Inventory[consumable.Key].lastPurchaseTimestamp = DateTime.UtcNow.GetTimeInMilliseconds(); } offlineDatabase.Write(value4); } offlineDatabase.Write(value); }
private void parseItemGroups() { progressionService = Service.Get <ProgressionService>(); TemplateDefinition[] unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TemplateDefinition>(ProgressionUnlockCategory.equipmentTemplates); progressionUnlockedRewards = new HashSet <TemplateDefinition>(unlockedDefinitionsForCategory); userLevel = progressionService.Level; for (int i = 0; i <= progressionService.MaxUnlockLevel; i++) { TemplateDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, ProgressionUnlockCategory.equipmentTemplates).Definitions as TemplateDefinition[]; if (array == null || array.Length <= 0) { continue; } bool isProgressionLocked = i > userLevel; for (int j = 0; j < array.Length; j++) { if (array[j] != null && array[j].IsEditable) { DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array[j], i, null); addRewardTemplate(newDisplayTemplate, isProgressionLocked); if (progressionUnlockedRewards.Contains(array[j])) { progressionUnlockedRewards.Remove(array[j]); } } } } QuestService questService = Service.Get <QuestService>(); Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap; foreach (QuestDefinition knownQuest in questService.KnownQuests) { questToMascotMap.TryGetValue(knownQuest.name, out var value); if (value == null) { continue; } string mascotName = value.Name; Quest quest = questService.GetQuest(knownQuest); if (knownQuest.StartReward != null) { if (quest.State == Quest.QuestState.Active || quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.StartReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } if (knownQuest.CompleteReward != null) { if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.CompleteReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } if (knownQuest.ObjectiveRewards != null) { if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0) { mascotName = ""; } for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++) { parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.ObjectiveRewards[j].GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName); } } } if (progressionUnlockedRewards.Count <= 0) { return; } TemplateDefinition[] array2 = new TemplateDefinition[progressionUnlockedRewards.Count]; progressionUnlockedRewards.CopyTo(array2); for (int j = 0; j < array2.Length; j++) { if (array2[j].IsEditable) { DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array2[j], -1, null); lastUnlockedIndex++; rewardTemplates.Insert(lastUnlockedIndex, newDisplayTemplate); } } }
public int GetSpinResult(Reward spinReward, Reward chestReward) { CellPhoneDailySpinActivityDefinition widgetData = ClubPenguin.Core.SceneRefs.Get <CellPhoneActivityScreenDailySpinWidget>().WidgetData; ClubPenguin.Net.Offline.DailySpinData dailySpinData = offlineDatabase.Read <ClubPenguin.Net.Offline.DailySpinData>(); bool flag = dailySpinData.CurrentChestId == 0 && dailySpinData.NumPunchesOnCurrentChest == 0 && dailySpinData.NumChestsReceivedOfCurrentChestId == 0; CellPhoneDailySpinActivityDefinition.ChestDefinition chestDefinition = getChestDefinitionForId(dailySpinData.CurrentChestId, widgetData) ?? default(CellPhoneDailySpinActivityDefinition.ChestDefinition); dailySpinData.NumPunchesOnCurrentChest++; int num = -1; if (dailySpinData.NumPunchesOnCurrentChest >= chestDefinition.NumPunchesPerChest) { addChestReward(chestReward, widgetData, dailySpinData, chestDefinition); } if (flag && !widgetData.FirstTimeSpinReward.Reward.ToReward().isEmpty()) { num = widgetData.FirstTimeSpinReward.SpinOutcomeId; spinReward.AddReward(widgetData.FirstTimeSpinReward.Reward.ToReward()); } else { num = addWeightedRandomSpinReward(spinReward, widgetData, dailySpinData, chestDefinition); } if (num == widgetData.ChestSpinOutcomeId) { dailySpinData.NumSpinsSinceReceivedChest = 0; dailySpinData.NumSpinsSinceReceivedExtraSpin++; addChestReward(spinReward, widgetData, dailySpinData, chestDefinition); } else if (num == widgetData.RespinSpinOutcomeId) { dailySpinData.NumSpinsSinceReceivedExtraSpin = 0; if (isChestValidSpinReward(dailySpinData, chestDefinition)) { dailySpinData.NumSpinsSinceReceivedChest++; } } else { dailySpinData.NumSpinsSinceReceivedExtraSpin++; if (isChestValidSpinReward(dailySpinData, chestDefinition)) { dailySpinData.NumSpinsSinceReceivedChest++; } } if (num == widgetData.ChestSpinOutcomeId || !chestReward.isEmpty()) { dailySpinData.NumChestsReceivedOfCurrentChestId++; dailySpinData.NumPunchesOnCurrentChest = 0; if (dailySpinData.NumChestsReceivedOfCurrentChestId >= chestDefinition.NumChestsToNextLevel) { CellPhoneDailySpinActivityDefinition.ChestDefinition?chestDefinitionForId = getChestDefinitionForId(chestDefinition.ChestId + 1, widgetData); if (chestDefinitionForId.HasValue) { dailySpinData.CurrentChestId = chestDefinitionForId.Value.ChestId; dailySpinData.NumChestsReceivedOfCurrentChestId = 0; } } } if (spinReward.TryGetValue <MascotXPReward>(out var rewardable)) { bool flag2 = false; ProgressionService progressionService = Service.Get <ProgressionService>(); foreach (KeyValuePair <string, int> item in rewardable.XP) { if (progressionService.IsMascotMaxLevel(item.Key)) { flag2 = true; break; } } if (flag2) { rewardable.XP.Clear(); spinReward.AddReward(widgetData.DefaultReward.ToReward()); } } if (num != widgetData.RespinSpinOutcomeId) { dailySpinData.TimeOfLastSpinInMilliseconds = DateTime.UtcNow.GetTimeInMilliseconds(); } offlineDatabase.Write(dailySpinData); return(num); }
private static void parseRewardDefinition <T>(List <ParsedProgression <T> > parsedProgressionList, T[] unlocks, HashSet <T> progressionUnlockedRewards, ProgressionService progressionService, ProgressionUnlockCategory category, string mascotName, ref int lastUnlockedIndex) where T : StaticGameDataDefinition, IMemberLocked { if (unlocks == null || unlocks.Length <= 0) { return; } bool flag = false; bool isLocalPlayerMember = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember(); for (int i = 0; i < unlocks.Length; i++) { if ((UnityEngine.Object)unlocks[i] != (UnityEngine.Object)null) { if (!progressionService.IsUnlocked(unlocks[i], category)) { flag = true; } ParsedProgression <T> parsedProgression = new ParsedProgression <T>(unlocks[i], -1, mascotName, levelLocked: false, flag, unlocks[i].IsMemberOnly); addParsedProgression(parsedProgressionList, parsedProgression, flag, isLocalPlayerMember, ref lastUnlockedIndex); if (progressionUnlockedRewards.Contains(unlocks[i])) { progressionUnlockedRewards.Remove(unlocks[i]); } } } }
public static List <ParsedProgression <TDefinition> > RetrieveProgressionLockedItems <TDefinition, TReward>(ProgressionUnlockCategory category, Func <List <TReward>, TDefinition[]> getRewards) where TDefinition : StaticGameDataDefinition, IMemberLocked where TReward : AbstractStaticGameDataRewardDefinition <TDefinition> { ProgressionService progressionService = Service.Get <ProgressionService>(); TDefinition[] unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TDefinition>(category); HashSet <TDefinition> hashSet = new HashSet <TDefinition>(unlockedDefinitionsForCategory); int level = progressionService.Level; List <ParsedProgression <TDefinition> > list = new List <ParsedProgression <TDefinition> >(); int lastUnlockedIndex = -1; bool isLocalPlayerMember = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember(); for (int i = 0; i <= progressionService.MaxUnlockLevel; i++) { TDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, category).Definitions as TDefinition[]; if (array == null || array.Length <= 0) { continue; } bool flag = i > level; for (int j = 0; j < array.Length; j++) { if ((UnityEngine.Object)array[j] != (UnityEngine.Object)null) { ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array[j], i, null, flag, progressionLocked: false, array[j].IsMemberOnly); addParsedProgression(list, parsedProgression, flag, isLocalPlayerMember, ref lastUnlockedIndex); if (hashSet.Contains(array[j])) { hashSet.Remove(array[j]); } } } } QuestService questService = Service.Get <QuestService>(); Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap; foreach (QuestDefinition knownQuest in questService.KnownQuests) { questToMascotMap.TryGetValue(knownQuest.name, out Mascot value); if (value != null) { string name = value.Name; questService.GetQuest(knownQuest); if (knownQuest.StartReward != null) { parseRewardDefinition(list, getRewards(knownQuest.StartReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } if (knownQuest.CompleteReward != null) { parseRewardDefinition(list, getRewards(knownQuest.CompleteReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } if (knownQuest.ObjectiveRewards != null) { for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++) { parseRewardDefinition(list, getRewards(knownQuest.ObjectiveRewards[j].GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex); } } } } if (hashSet.Count > 0) { TDefinition[] array2 = new TDefinition[hashSet.Count]; hashSet.CopyTo(array2); for (int j = 0; j < array2.Length; j++) { ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array2[j], -1, null, levelLocked: false, progressionLocked: false, array2[j].IsMemberOnly); lastUnlockedIndex++; list.Insert(lastUnlockedIndex, parsedProgression); } } return(list); }
private void PopulateChallengeData(CurrentThemeData currentTheme) { bool flag = ((currentTheme.userSubmissionClothingCatalogId != 0) ? true : false); GoButton.SetActive(!flag); SubmittedButton.SetActive(flag); Button component = GoButton.transform.parent.GetComponent <Button>(); if (component != null) { component.enabled = !flag; } CatalogThemeDefinition themeByScheduelId = Service.Get <CatalogServiceProxy>().GetThemeByScheduelId(currentTheme.scheduledThemeChallengeId); bool flag2 = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember(); if (themeByScheduelId == null) { ChallengeMemberLock.transform.parent.gameObject.SetActive(value: false); return; } if (flag2) { ProgressionService progressionService = Service.Get <ProgressionService>(); int level = progressionService.Level; int num = 0; Dictionary <int, TemplateDefinition> dictionary = Service.Get <GameData>().Get <Dictionary <int, TemplateDefinition> >(); TagDefinition[] templateTags = themeByScheduelId.TemplateTags; List <TemplateDefinition> list = new List <TemplateDefinition>(); foreach (TagDefinition value in templateTags) { for (int j = 0; j < dictionary.Values.Count; j++) { TemplateDefinition templateDefinition = dictionary.Values.ToList()[j]; if (templateDefinition.Tags.Contains(value) && list.IndexOf(templateDefinition) < 0) { list.Add(templateDefinition); } } } for (int i = 0; i < list.Count; i++) { int unlockLevelFromDefinition = progressionService.GetUnlockLevelFromDefinition(list[i], ProgressionUnlockCategory.equipmentTemplates); if (unlockLevelFromDefinition < num) { num = unlockLevelFromDefinition; } } ChallengeProgressionLock.SetActive(value: false); if (num > level) { ChallengeProgressionLock.SetActive(value: true); if (ChallengeProgressionLockText != null) { ChallengeProgressionLockText.text = Service.Get <Localizer>().GetTokenTranslation(num.ToString()); } } } else { ChallengeMemberLock.SetActive(value: false); if (ChallengeMemberLock != null) { ChallengeMemberLock.SetActive(value: true); } } setBillboardTheme(themeByScheduelId); DateTime dateTime = Service.Get <ContentSchedulerService>().PresentTime(); int hours = 24 - dateTime.Hour - 1; int minutes = 60 - dateTime.Minute - 1; int seconds = 60 - dateTime.Second - 1; TimeSpan timeSpan = new TimeSpan(hours, minutes, seconds); endTime = DateTime.Now + timeSpan; isTimerRunning = true; }
private bool onAddXP(RewardEvents.AddXP evt) { if (!evt.ShowReward) { suppressedXP.Enqueue(evt); } else { switch (state) { case XPHudState.closed: currentMascotName = evt.MascotName; if (!Service.Get <ProgressionService>().IsMascotMaxLevel(currentMascotName, evt.PreviousLevel)) { Mascot mascot = Service.Get <MascotService>().GetMascot(currentMascotName); if (mascot != null) { Service.Get <EventDispatcher>().DispatchEvent(new PlayerScoreEvents.ShowPlayerScore(dataEntityCollection.LocalPlayerSessionId, $"+{evt.XPAdded}", PlayerScoreEvents.ParticleType.XP, mascot.Definition.XPTintColor)); } CoroutineRunner.Start(loadXPHudPrefab(mascotXPContentKey, evt.MascotName), this, "XPHud.loadXPHudPrefab"); currentMascotLevel = evt.PreviousLevel; targetMacotLevel = evt.CurrentLevel; state = XPHudState.opening; } break; case XPHudState.opening: case XPHudState.addingXP: if (currentMascotName == evt.MascotName) { targetMacotLevel = Math.Max(targetMacotLevel, evt.CurrentLevel); } else { pendingXP.Enqueue(evt); } break; case XPHudState.waitingToClose: if (currentMascotName == evt.MascotName) { CancelInvoke(); targetMacotLevel = Math.Max(targetMacotLevel, evt.CurrentLevel); CoroutineRunner.Start(updateXpDisplay(), this, "updateXpDisplay"); } else { pendingXP.Enqueue(evt); } break; case XPHudState.closing: pendingXP.Enqueue(evt); break; } if (ProgressionService.GetMascotLevelFromXP(targetMacotLevel) != ProgressionService.GetMascotLevelFromXP(currentMascotLevel)) { disableUI(); } } return(false); }
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); }