public void SetButton(Sprite icon, string sId, StoreItem sItem) { storeId = sId; storeItem = sItem; catalogItem = PF_GameData.GetCatalogItemById(sItem.ItemId); var displayName = catalogItem != null ? catalogItem.DisplayName : "Unknown item"; ActivateButton(); image.overrideSprite = icon; gameObject.name = displayName; ItemDesc.text = displayName; btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { controller.selectedItem = this; InitiatePurchase(); }); uint salePrice, basePrice; finalPrice = GetPrice(out salePrice, out basePrice, out currencyKey); SetIcon(); SetPrice(salePrice, basePrice, currencyKey); }
public void UpdateFriendsLB(string stat) { Debug.Log("Update Friend LB UI"); UnityAction afterGetLB = () => { if (PF_GameData.friendsLB.Count > 0) { int count = 0; foreach (var rank in PF_GameData.friendsLB) { this.FriendsLB.items[count].Rank.text = "" + (rank.Position + 1); this.FriendsLB.items[count].Name.text = string.IsNullOrEmpty(rank.DisplayName) ? rank.PlayFabId : rank.DisplayName; this.FriendsLB.items[count].Value.text = "" + rank.StatValue; count++; } if (count < 10) { for (int z = count; z < 10; z++) { this.FriendsLB.items[z].Rank.text = "" + (z + 1); this.FriendsLB.items[z].Name.text = string.Empty; this.FriendsLB.items[z].Value.text = string.Empty; } } } }; //PF_GameData.GetCharacterLeaderboard(stat, afterGetLB); // not using this based on the character LB issues. PF_GameData.GetFriendsLeaderboard(stat, afterGetLB); }
public void SelectBanner() { displayPromoIndex = promos.Count == 0 ? 0 : displayPromoIndex % promos.Count; activePromo = promos.Count == 0 ? UB_PromoDisplay.EMPTY_PROMO : promos[displayPromoIndex]; AdjustSlotDisplay(displayPromoIndex); ViewSaleBtn.SetActive(!string.IsNullOrEmpty(PF_GameData.GetEventSaleStore(activePromo.EventKey))); PlayEventBtn.SetActive(activePromo.linkedAd == null && PF_GameData.GetEventAssociatedLevels(activePromo.EventKey).Count > 0); WatchAdBtn.SetActive(activePromo.linkedAd != null); if (activePromo.EventKey != null) // Event Type { selectedDesc.text = activePromo.Description; selectedTitle.text = activePromo.Title; } else if (activePromo.linkedAd != null) // Ad Type { var qtyString = string.Format("{0}", activePromo.linkedAd.Details.PlacementViewsRemaining == null ? "UNLIMITED rewarded ads." : activePromo.linkedAd.Details.PlacementViewsRemaining + " more rewarded ads."); selectedDesc.text = activePromo.linkedAd.Details.RewardDescription + " You may watch " + qtyString; selectedTitle.text = activePromo.linkedAd.Details.RewardName; } else { selectedDesc.text = GlobalStrings.NO_EVENTS_MSG; selectedTitle.text = ""; } if (activePromo.assets.Banner != null) { PromoBanner.overrideSprite = Sprite.Create(activePromo.assets.Banner, new Rect(0, 0, activePromo.assets.Banner.width, activePromo.assets.Banner.height), new Vector2(0.5f, 0.5f)); } }
public void InitiateViewer(List <string> items) // need a new flag to determine if we should unpack to a player or a character { pfItems.Clear(); openedBoxes.Clear(); if (PF_GameData.catalogItems == null || PF_GameData.catalogItems.Count == 0) { return; } foreach (var item in items) { var catalogItem = PF_GameData.GetCatalogItemById(item); if (catalogItem != null) { pfItems.Add(catalogItem); } } PrevItemButton.interactable = false; NextItemButton.interactable = pfItems.Count != 1; //select the first in the list SetSelectedItem(pfItems[0]); selectedIndex = 0; gameObject.SetActive(true); }
public void UpdateTop10LB(string stat) { UnityAction afterGetLB = () => { Debug.Log("Update Top10 LB UI"); if (PF_GameData.currentTop10LB.Count > 0) { int count = 0; foreach (var rank in PF_GameData.currentTop10LB) { this.Top10LB.items[count].Rank.text = "" + (rank.Position + 1); this.Top10LB.items[count].Name.text = string.IsNullOrEmpty(rank.DisplayName) ? rank.PlayFabId : rank.DisplayName; this.Top10LB.items[count].Value.text = "" + rank.StatValue; count++; } if (count < 10) { for (int z = count; z < 10; z++) { this.Top10LB.items[z].Rank.text = "" + (z + 1); this.Top10LB.items[z].Name.text = string.Empty; this.Top10LB.items[z].Value.text = string.Empty; } } } }; PF_GameData.GetPlayerLeaderboard(stat, afterGetLB); }
public static void CharacterSelectDataRefresh() { //Debug.Log("Ran CharacterSelectDataRefresh"); PF_GameData.GetTitleData(); PF_GameData.GetTitleNews(); PF_GameData.GetCatalogInfo(); PF_GameData.GetOffersCatalog(); PF_PlayerData.GetPlayerCharacters(); PF_PlayerData.GetUserStatistics(); }
public void UpdateMyRank(string stat) { UnityAction <int> afterRank = (int rank) => { this.myPosition.text = rank > 0 ? "" + rank : "--"; }; //PF_GameData.GetMyCharacterLeaderboardRank(stat, afterRank); PF_GameData.GetMyPlayerLeaderboardRank(stat, afterRank); }
public static void CharacterSelectDataRefresh() { //Debug.Log("Ran CharacterSelectDataRefresh"); PF_GameData.GetEventData(); // PF_GameData.GetActiveEventData(); // now called directly from GetEventData to ensure ordering PF_GameData.GetTitleData(); PF_GameData.GetTitleNews(); PF_GameData.GetCatalogInfo(); PF_GameData.GetOffersCatalog(); PF_PlayerData.GetPlayerCharacters(); PF_PlayerData.GetUserStatistics(); }
public void ViewSale() { var storeId = PF_GameData.GetEventSaleStore(activePromo.EventKey); DialogCanvasController.RequestStore(storeId); Dictionary <string, object> eventData = new Dictionary <string, object> { { "SalePromo", activePromo.assets.PromoId }, { "Character_ID", PF_PlayerData.activeCharacter.characterDetails.CharacterId } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_SaleClicked, eventData); }
public void CheckUnlock() { var item = this.controller.selectedItem.ItemId; if (controller.UnpackToPlayer) { PF_GameData.TryOpenContainer(item, null, this.afterUnlock); } else { var character = PF_PlayerData.activeCharacter.characterDetails.CharacterId; PF_GameData.TryOpenContainer(item, character, this.afterUnlock); } }
public void AfterUnlock(UnlockContainerItemResult result) { // unlocking a container will automatically add the returned items, this ensures that items are not added twice. PF_GamePlay.QuestProgress.ItemsFound.Remove(selectedItem.ItemId); // build our list for displaying the container results List <ContainerResultItem> items = new List <ContainerResultItem>(); foreach (var award in result.GrantedItems) { var awardIcon = PF_GameData.GetIconByItemById(award.ItemId); items.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon, IconManager.IconTypes.Item), displayName = award.DisplayName }); } if (result.VirtualCurrency != null) { foreach (var award in result.VirtualCurrency) { string friendlyName; switch (award.Key) { case GlobalStrings.GOLD_CURRENCY: friendlyName = "Gold"; break; case GlobalStrings.HEART_CURRENCY: friendlyName = "Lives"; break; case GlobalStrings.GEM_CURRENCY: friendlyName = "Gems"; break; default: friendlyName = ""; break; } items.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(award.Key, IconManager.IconTypes.Item), displayName = award.Value + " " + friendlyName }); } } CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open", IconManager.IconTypes.Item); openedBoxes.Add(selectedIndex, items); EnableUnlockedItemsView(items); DialogCanvasController.RequestInventoryPrompt(); }
public static void GetUserInventory(Action callback = null) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetUserInventory); PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), (GetUserInventoryResult result) => { virtualCurrency.Clear(); playerInventory.Clear(); foreach (var pair in result.VirtualCurrency) { virtualCurrency.Add(pair.Key, pair.Value); } foreach (var eachItem in result.Inventory) { playerInventory.Add(eachItem); } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { if (inventoryByCategory.ContainsKey(item.ItemId)) { continue; } var catalogItem = PF_GameData.GetCatalogItemById(item.ItemId); if (catalogItem == null) { continue; } var items = playerInventory.FindAll(x => { return(x.ItemId.Equals(item.ItemId)); }); var customIcon = PF_GameData.GetIconByItemById(catalogItem.ItemId); var icon = GameController.Instance.iconManager.GetIconById(customIcon, IconManager.IconTypes.Item); inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalogItem, items, icon)); } } if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetUserInventory, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
public void NextPage() { HideSelectedItem(); int nextPage = currentPage + 1; int lowerBound = this.itemsPerPage * currentPage; int upperBound = lowerBound + this.itemsPerPage; this.pageDisplay.text = string.Format(GlobalStrings.PAGE_NUMBER_MSG, nextPage, pageCount); int uiIndex = 0; for (int z = lowerBound; z < upperBound; z++, uiIndex++) { if (z < itemsToDisplay.Count) { CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(itemsToDisplay[z]); string iconName = "Default"; if (!string.Equals(CI.CustomData, null)) //should be !string.IsNullOrEmpty(CI.CustomData) { Dictionary <string, string> kvps = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(CI.CustomData); kvps.TryGetValue("icon", out iconName); } Sprite icon = GameController.Instance.iconManager.GetIconById(iconName); this.inventory[uiIndex].Init(); this.inventory[uiIndex].SetButton(icon, CI); } else { this.inventory[uiIndex].ClearButton(); } } this.prevPage.interactable = true; if (pageCount > nextPage) { this.nextPage.interactable = true; } else { this.nextPage.interactable = false; } this.currentPage++; }
public static void CharacterSelectDataRefresh() { //Debug.Log("Ran CharacterSelectDataRefresh"); PF_PlayerData.GetUserAccountInfo(); PF_GameData.GetTitleData(); //PF_GameData.GetTitleNews(); PF_GameData.GetCatalogInfo(); //PF_GameData.GetOffersCatalog(); System.Action action = () => { PF_PlayerData.GetCharacterData(); }; PF_PlayerData.GetPlayerCharacters(action); //PF_PlayerData.GetCharacterData(); //PF_PlayerData.GetUserStatistics(); }
public void PlayEvent() { var levelNames = PF_GameData.GetEventAssociatedLevels(activePromo.EventKey); UnityAction <int> playEventIndex = index => { _levelPicker.LevelItemClicked(levelNames[index]); _levelPicker.PlaySelectedLevel(); }; if (levelNames.Count > 1) { DialogCanvasController.RequestSelectorPrompt(GlobalStrings.QUEST_SELECTOR_PROMPT, levelNames, playEventIndex); } else if (levelNames.Count == 1) { playEventIndex(0); } }
public void Init() { SetCheckBoxSprite(RaidMode.GetComponent <Image>(), PF_GamePlay.UseRaidMode); for (var z = 0; z < levelItems.Count; z++) { Destroy(levelItems[z].gameObject); } levelItems.Clear(); if (PF_GameData.Levels.Count == 0) { return; } foreach (var levelData in PF_GameData.Levels) { //TODO show locked levels if (levelData.Value.MinEntryLevel != null && levelData.Value.MinEntryLevel.Value > PF_PlayerData.activeCharacter.characterData.CharacterLevel) { continue; // Hide high level dungeons } if (PF_GameData.IsEventActive(levelData.Value.RestrictedToEventKey) != PromotionType.Active) { continue; } var slot = Instantiate(levelButtonPrefab); slot.SetParent(gridView, false); var li = slot.GetComponent <LevelItem>(); li.levelData = levelData.Value; li.levelName = levelData.Key; li.levelIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(levelData.Value.Icon, IconManager.IconTypes.Misc); levelItems.Add(li); } LevelItemClicked(levelItems[0].levelName); }
public void SetupSlider(UnityAction <UnlockContainerItemResult> callback = null) { afterUnlock = callback; ItemDescription.text = controller.selectedItem.Description; if (controller.selectedItem.Container != null) { var keyId = controller.selectedItem.Container.KeyItemId; var keyReference = PF_GameData.GetCatalogItemById(keyId); endIcon.gameObject.SetActive(keyReference != null); if (keyReference != null) { var chestQty = PF_PlayerData.GetItemQty(controller.selectedItem.ItemId); var keyQty = PF_PlayerData.GetItemQty(keyId); var useColor = (chestQty > 0 && keyQty > 0) ? Color.cyan : Color.red; endIcon.color = useColor; sliderMessage.text = string.Format("{0} Required ({1} available)", keyReference.DisplayName, Mathf.Min(chestQty, keyQty)); sliderMessage.color = useColor; var iconName = PF_GameData.GetIconByItemById(keyReference.ItemId, GlobalStrings.BRONZE_KEY_ICON); var icon = GameController.Instance.iconManager.GetIconById(iconName, IconManager.IconTypes.Item); handle.overrideSprite = icon; } else { handle.overrideSprite = GameController.Instance.iconManager.GetIconById(GlobalStrings.DARKSTONE_LOCK_ICON, IconManager.IconTypes.Misc); sliderMessage.text = GlobalStrings.UNLOCKED_MSG; } } else { sliderMessage.text = GlobalStrings.UNLOCKED_MSG; // set default key icon or lock or something... } }
private static void OnGetUserAccountInfoSuccess(GetPlayerCombinedInfoResult result) { playerInventory.Clear(); foreach (var eachItem in result.InfoResultPayload.UserInventory) { playerInventory.Add(eachItem); } accountInfo = result.InfoResultPayload.AccountInfo; if (result.InfoResultPayload.UserData.ContainsKey("IsRegisteredForPush")) { isRegisteredForPush = result.InfoResultPayload.UserData["IsRegisteredForPush"].Value == "1"; } else { isRegisteredForPush = false; } if (result.InfoResultPayload.UserData.ContainsKey("ShowAccountOptionsOnLogin") && result.InfoResultPayload.UserData["ShowAccountOptionsOnLogin"].Value == "0") { showAccountOptionsOnLogin = false; } else //if (PF_Authentication.hasLoggedInOnce == false) { //PF_Authentication.hasLoggedInOnce = true; DialogCanvasController.RequestAccountSettings(); } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { if (inventoryByCategory.ContainsKey(item.ItemId)) { continue; } var catalogItem = PF_GameData.GetCatalogItemById(item.ItemId); if (catalogItem == null) { continue; } var items = new List <ItemInstance>(playerInventory.FindAll((x) => { return(x.ItemId.Equals(item.ItemId)); })); var customIcon = PF_GameData.GetIconByItemById(catalogItem.ItemId); var icon = GameController.Instance.iconManager.GetIconById(customIcon, IconManager.IconTypes.Item); inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalogItem, items, icon)); } } if (PF_Authentication.GetDeviceId(true)) { Debug.Log("Mobile Device ID Found!"); var deviceId = string.IsNullOrEmpty(PF_Authentication.android_id) ? PF_Authentication.ios_id : PF_Authentication.android_id; PlayerPrefs.SetString("LastDeviceIdUsed", deviceId); } else { Debug.Log("Custom Device ID Found!"); if (string.IsNullOrEmpty(PF_Authentication.custom_id)) { PlayerPrefs.SetString("LastDeviceIdUsed", PF_Authentication.custom_id); } } virtualCurrency.Clear(); foreach (var eachPair in result.InfoResultPayload.UserVirtualCurrency) { virtualCurrency.Add(eachPair.Key, eachPair.Value); } PF_Bridge.RaiseCallbackSuccess("Player Account Info Loaded", PlayFabAPIMethods.GetAccountInfo, MessageDisplayStyle.none); }
public void CheckUnlock() { var chestItemId = controller.selectedItem.ItemId; PF_GameData.TryOpenContainer(chestItemId, afterUnlock); }
public void SetSelectedItem(CatalogItem item) { selectedItem = item; CurrentItemName.text = selectedItem.DisplayName; CurrentItemDesc.text = selectedItem.Description; ItemCount.text = string.Format("{0}/{1}", selectedIndex + 1, pfItems.Count); // refresh the UI currentIconId = PF_GameData.GetIconByItemById(item.ItemId); var icon = GameController.Instance.iconManager.GetIconById(currentIconId, IconManager.IconTypes.Item); CurrentIcon.overrideSprite = icon; if (openedBoxes.ContainsKey(selectedIndex)) { // this container has been opened, show the items... if (PF_GameData.IsContainer(selectedItem.ItemId)) { CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open", IconManager.IconTypes.Item); } EnableContainerMode(true); return; } // test bundles here.... // if bundle, we need to show the contents, but not remove it from the list, as it will be unpacked and added automatically if (selectedItem.Bundle != null && (selectedItem.Bundle.BundledItems != null || selectedItem.Bundle.BundledResultTables != null || selectedItem.Bundle.BundledVirtualCurrencies != null)) { var bundleItems = new List <ContainerResultItem>(); if (selectedItem.Bundle.BundledItems != null && selectedItem.Bundle.BundledItems.Count > 0) { foreach (var award in selectedItem.Bundle.BundledItems) { var catalogItem = PF_GameData.GetCatalogItemById(award); var awardIcon = PF_GameData.GetIconByItemById(award); bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon, IconManager.IconTypes.Item), displayName = catalogItem.DisplayName }); } } if (selectedItem.Bundle.BundledResultTables != null && selectedItem.Bundle.BundledResultTables.Count > 0) { foreach (var award in selectedItem.Bundle.BundledResultTables) { bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById("DropTable", IconManager.IconTypes.Misc), displayName = string.Format("Drop Table: {0}", award) }); } } if (selectedItem.Bundle.BundledVirtualCurrencies != null && selectedItem.Bundle.BundledVirtualCurrencies.Count > 0) { foreach (var award in selectedItem.Bundle.BundledVirtualCurrencies) { bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(award.Key, IconManager.IconTypes.Item), displayName = string.Format("{1} Award: {0:n0}", award.Value, award.Key) }); } } if (bundleItems.Count > 0) { openedBoxes.Add(selectedIndex, bundleItems); EnableContainerMode(true); // dont fall through the rest of the logic. return; } } if (PF_GameData.IsContainer(selectedItem.ItemId)) { EnableContainerMode(); } else { DisableContainerMode(); } }
//TODO solve the confusion with what VC balances are checked player VS character // close also needs to fire a callback to the calling area of the code public void InitiateStore(string name, List <StoreItem> items) { Dictionary <string, object> eventData = new Dictionary <string, object>() { { "store_name", name } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_StoreVisit, eventData); //reset this.currenciesInUse.Clear(); this.currentPage = 1; this.pageCount = Mathf.CeilToInt((float)items.Count / (float)this.itemsPerPage); this.pageDisplay.text = string.Format("{0} / {1}", this.currentPage, this.pageCount); //HideSelectedItem(); foreach (var item in this.inventory) { item.ClearButton(); } this.itemsToDisplay = items; this.StoreName.text = name; if (pageCount > 1) { nextPage.interactable = true; } else { nextPage.interactable = false; } prevPage.interactable = false; for (int z = 0; z < items.Count; z++) { if (z >= this.itemsPerPage) { break; } CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(items[z]); string iconName = "Default"; if (CI.CustomData != null && !string.Equals(CI.CustomData, "null")) { try { Dictionary <string, string> kvps = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(CI.CustomData); kvps.TryGetValue("icon", out iconName); } catch (Exception e) { Debug.LogException(e); } } Sprite icon = GameController.Instance.iconManager.GetIconById(iconName); this.inventory[z].Init(); this.inventory[z].SetButton(icon, CI); // keep track of what currencies are being used in the store. List <string> VCs = items[z].VirtualCurrencyPrices.Keys.ToList(); foreach (var vc in VCs) { int index = this.currenciesInUse.FindIndex((key) => { return(string.Equals(key, vc)); }); // make sure not already in the list. if (index < 0) { this.currenciesInUse.Add(vc); } } } //hide selected this.Currencies.Init(); this.gameObject.SetActive(true); }
//TODO solve the confusion with what VC balances are checked player VS character // close also needs to fire a callback to the calling area of the code public void InitiateStore(string name, List <StoreItem> items) { foreach (var slot in itemInventory) { slot.gameObject.SetActive(false); } //Dictionary<string, object> eventData = new Dictionary<string, object>() //{ // { "store_name", name } //}; //PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_StoreVisit, eventData); //reset //itemInventory = new StoreDisplayItem[items.Count]; this.currenciesInUse.Clear(); //foreach (var item in this.itemInventory) //{ // item.ClearButton(); //} this.itemsToDisplay = items; this.StoreName.text = name; for (int z = 0; z < items.Count; z++) { //todo : instance the item buttom and initialize itemInventory[z].gameObject.SetActive(true); itemInventory[z].ClearButton(); // CatalogItem CI = PF_GameData.ConvertStoreItemToCatalogItem(items[z]); string iconName = "Default"; if (CI.CustomData != null && !string.Equals(CI.CustomData, "null")) { try { Dictionary <string, string> kvps = PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(CI.CustomData); kvps.TryGetValue("icon", out iconName); } catch (Exception e) { Debug.LogException(e); } } Sprite icon = GameController.Instance.iconManager.GetIconById(iconName); this.itemInventory[z].Init(); this.itemInventory[z].SetButton(icon, CI); // keep track of what currencies are being used in the store. List <string> VCs = items[z].VirtualCurrencyPrices.Keys.ToList(); foreach (var vc in VCs) { int index = this.currenciesInUse.FindIndex((key) => { return(string.Equals(key, vc)); }); // make sure not already in the list. if (index < 0) { this.currenciesInUse.Add(vc); } } } //hide selected //this.Currencies.Init(); this.gameObject.SetActive(true); }
private static void GetItemIcon(StoreItem storeItem, out Sprite icon) { var iconName = PF_GameData.GetIconByItemById(storeItem.ItemId); icon = GameController.Instance.iconManager.GetIconById(iconName, IconManager.IconTypes.Item); }
public void PlaySelectedLevel() { //SceneController.Instance.RequestSceneChange(SceneController.GameScenes.Gameplay, .333f); //Init(); // build an encounters' pools list. from these pools we can randomize an order to the encounters. List <string> encounters = new List <string>(); //TODO sometimes this throws a nullref ? foreach (var act in selectedLevel.levelData.Acts) { if (!string.IsNullOrEmpty(act.Value.CreepEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.CreepEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.CreepEncounters.EncounterPool); } } if (!string.IsNullOrEmpty(act.Value.MegaCreepEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.MegaCreepEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.MegaCreepEncounters.EncounterPool); } } if (!string.IsNullOrEmpty(act.Value.RareCreepEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.RareCreepEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.RareCreepEncounters.EncounterPool); } } if (!string.IsNullOrEmpty(act.Value.BossCreepEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.BossCreepEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.BossCreepEncounters.EncounterPool); } } if (!string.IsNullOrEmpty(act.Value.StoreEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.StoreEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.StoreEncounters.EncounterPool); } } if (!string.IsNullOrEmpty(act.Value.HeroEncounters.EncounterPool)) { int exists = encounters.IndexOf(act.Value.HeroEncounters.EncounterPool); if (exists == -1) { encounters.Add(act.Value.HeroEncounters.EncounterPool); } } } PF_GameData.GetEncounterLists(encounters); //TODO Set difficulty level on the selected level item. }
public void SetButton(Sprite icon, CatalogItem cItem) { ActivateButton(); this.image.overrideSprite = icon; this.ItemDesc.text = cItem.DisplayName; string currencyKey = "RM"; string currencyFormat = "{0:C2}"; ItemCurrencyIcon.sprite = CurrencyIcons[0]; //For now disable uses: Savings.gameObject.SetActive(false); if (cItem.VirtualCurrencyPrices.ContainsKey(GlobalStrings.GEM_CURRENCY)) { currencyKey = GlobalStrings.GEM_CURRENCY; currencyFormat = "{0}"; ItemCurrencyIcon.sprite = CurrencyIcons[1]; } else if (cItem.VirtualCurrencyPrices.ContainsKey(GlobalStrings.GOLD_CURRENCY)) { currencyKey = GlobalStrings.GOLD_CURRENCY; currencyFormat = "{0}"; ItemCurrencyIcon.sprite = CurrencyIcons[2]; } // check prices to see if this is a better deal than MSRP this.Savings.gameObject.SetActive(false); CatalogItem msrp = PF_GameData.GetCatalogItemById(cItem.ItemId); uint msrpPrice; if (msrp != null && msrp.VirtualCurrencyPrices != null && msrp.VirtualCurrencyPrices.TryGetValue(currencyKey, out msrpPrice)) { // check prices to see if this is a better deal than MSRP uint salePrice; cItem.VirtualCurrencyPrices.TryGetValue(currencyKey, out salePrice); if (salePrice < msrpPrice) { // VC only, not adjusting RM prices yet. float percent = (((float)msrpPrice - (float)salePrice) / (float)msrpPrice); this.SavingsText.text = string.Format("Save\n{0}%", Mathf.RoundToInt(percent * 100f)); this.Savings.gameObject.SetActive(true); } } string price = string.Empty; if (currencyKey == "RM" && cItem.VirtualCurrencyPrices.ContainsKey(currencyKey)) { uint pennies = cItem.VirtualCurrencyPrices[currencyKey]; price = string.Format(currencyFormat, (float)pennies / 100f); } else if (cItem.VirtualCurrencyPrices.ContainsKey(currencyKey)) { price = string.Format(currencyFormat, cItem.VirtualCurrencyPrices[currencyKey]); } this.ItemPrice.text = price; btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { controller.selectedItem = this; controller.InitiatePurchase(); }); this.catalogItem = cItem; }
public void CheckUnlock(string id) { string item = selectedItem.ItemId; PF_GameData.TryOpenContainer(id, null, AfterUnlock); }