Exemplo n.º 1
0
    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(this.selectedItem.ItemId);

        // build our list for displaying the container results
        List <ContainerResultItem> items = new List <ContainerResultItem>();

        foreach (var award in result.GrantedItems)
        {
            string      awardIcon            = "Default";
            CatalogItem catItem              = PF_GameData.catalogItems.Find((i) => { return(i.ItemId == award.ItemId); });
            Dictionary <string, string> kvps = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(catItem.CustomData);
            kvps.TryGetValue("icon", out awardIcon);

            items.Add(new ContainerResultItem()
            {
                displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon),
                displayName = award.DisplayName
            });
        }

        if (result.VirtualCurrency != null)
        {
            foreach (var award in result.VirtualCurrency)
            {
                items.Add(new ContainerResultItem()
                {
                    displayIcon = GameController.Instance.iconManager.GetIconById(award.Key),
                    displayName = string.Format("{1} Award: {0}", award.Value, award.Key)
                });
            }
        }
        else
        {
            CatalogItem catRef = PF_GameData.catalogItems.Find((i) => { return(i.ItemId == this.selectedItem.ItemId); });
            if (catRef.Container.VirtualCurrencyContents.Count > 0)
            {
                foreach (var vc in catRef.Container.VirtualCurrencyContents)
                {
                    items.Add(new ContainerResultItem()
                    {
                        displayIcon = GameController.Instance.iconManager.GetIconById(vc.Key),
                        displayName = string.Format("{1} Award: {0}", vc.Value, vc.Key)
                    });
                }
            }
        }

        this.CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open");
        this.openedBoxes.Add(this.selectedIndex, items);
        EnableUnlockedItemsView(items);

        DialogCanvasController.RequestInventoryPrompt();
    }
Exemplo n.º 2
0
 public void RefreshInventory()
 {
     if (this.activeMode == InventoryMode.Character)
     {
         PF_PlayerData.GetUserInventory();
         DialogCanvasController.RequestInventoryPrompt(null, this.activeFilter, this.showTransUi, FloatingInventoryController.InventoryMode.Character);
     }
     else
     {
         PF_PlayerData.GetCharacterInventory(PF_PlayerData.activeCharacter.characterDetails.CharacterId);
         DialogCanvasController.RequestInventoryPrompt(null, this.activeFilter, this.showTransUi, FloatingInventoryController.InventoryMode.Player);
     }
 }
Exemplo n.º 3
0
    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 void UseItem()
    {
        Action <string> afterPickItem = (string item) =>
        {
            Debug.Log("Using " + item);

            InventoryCategory obj;
            PF_PlayerData.characterInvByCategory.TryGetValue(item, out obj);

            if (obj != null)
            {
                var first = obj.inventory.FirstOrDefault();
                if (first != null)
                {
                    var attributes = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, string> >(obj.catalogRef.CustomData);
                    if (attributes.ContainsKey("modifies") && attributes.ContainsKey("modifyPercent") && attributes.ContainsKey("target"))
                    {
                        if (string.Equals(attributes["target"], "self"))
                        {
                            // item effect applies to the player
                            string mod        = attributes["modifies"];
                            float  modPercent = float.Parse(attributes["modifyPercent"]);

                            switch (mod)
                            {
                            case "HP":
                                this.pendingValue = Mathf.CeilToInt((float)this.LifeBar.maxValue * modPercent);
                                Debug.Log(string.Format("Player Heals {0}", this.pendingValue));
                                PF_PlayerData.activeCharacter.PlayerVitals.Health += this.pendingValue;
                                RequestShake(defaultShakeTime, PF_GamePlay.ShakeEffects.IncreaseHealth);
                                break;
                            }

                            gameplayController.DecrementPlayerCDs();
                            PF_GamePlay.ConsumeItem(first.ItemInstanceId);
                            PF_GamePlay.QuestProgress.ItemsUsed++;
                        }
                    }
                }
            }
        };


        DialogCanvasController.RequestInventoryPrompt(afterPickItem, DialogCanvasController.InventoryFilters.UsableInCombat, false, FloatingInventoryController.InventoryMode.Character);
    }
 public void RefreshInventory()
 {
     PF_PlayerData.GetUserInventory();
     DialogCanvasController.RequestInventoryPrompt(null, this.activeFilter);
 }
Exemplo n.º 6
0
    public void OpenInventory()
    {
        GameController.Instance.soundManager.PlaySound(Vector3.zero, GlobalStrings.BUTTON_CLICK_SOUND_EFFECT);

        DialogCanvasController.RequestInventoryPrompt(null, DialogCanvasController.InventoryFilters.AllItems);
    }
Exemplo n.º 7
0
 public void OpenInventory()
 {
     DialogCanvasController.RequestInventoryPrompt(null, DialogCanvasController.InventoryFilters.AllItems);
 }
 public void UseItem()
 {
     DialogCanvasController.RequestInventoryPrompt(UseCombatItem, DialogCanvasController.InventoryFilters.UsableInCombat);
 }
    public void AfterUnlock(UnlockContainerItemResult result)
    {
        // build our list for displaying the container results
        List <ContainerResultItem> items = new List <ContainerResultItem>();
        int counts = 0;

        foreach (var award in result.GrantedItems)
        {
            string      awardIcon            = "Default";
            CatalogItem catItem              = PF_GameData.catalogItems.Find((i) => { return(i.ItemId == award.ItemId); });
            Dictionary <string, string> kvps = PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(catItem.CustomData);
            //kvps.TryGetValue("icon", out awardIcon);

            items.Add(new ContainerResultItem()
            {
                displayIcon = new Sprite(),//GameController.Instance.iconManager.GetIconById(awardIcon),
                displayName = award.DisplayName
            });

            if (counts < 5)
            {
                UnpackedItemPrefab[counts].gameObject.SetActive(true);
                UnpackedItemPrefab[counts].BtnInitialize(new Sprite(), award.DisplayName, (int)award.UsesIncrementedBy);
            }
            else
            {
                return;
            }

            counts++;
        }

        if (result.VirtualCurrency != null)
        {
            foreach (var award in result.VirtualCurrency)
            {
                items.Add(new ContainerResultItem()
                {
                    displayIcon = new Sprite(),//GameController.Instance.iconManager.GetIconById(award.Key),
                    displayName = string.Format("{1} Award: {0}", award.Value, award.Key)
                });

                if (counts < 5)
                {
                    UnpackedItemPrefab[counts].gameObject.SetActive(true);
                    UnpackedItemPrefab[counts].BtnInitialize(new Sprite(), award.Key, (int)award.Value);
                }
                else
                {
                    return;
                }

                counts++;
            }
            PF_PlayerData.GetUserAccountInfo();
        }
        else
        {
            Debug.LogError("check plz");
            //CatalogItem catRef = PF_GameData.catalogItems.Find((i) => { return i.ItemId == this.selectedItem.ItemId; });
            //if (catRef.Container.VirtualCurrencyContents.Count > 0)
            //{
            //    foreach (var vc in catRef.Container.VirtualCurrencyContents)
            //    {
            //        items.Add(new ContainerResultItem()
            //        {
            //            displayIcon = GameController.Instance.iconManager.GetIconById(vc.Key),
            //            displayName = string.Format("{1} Award: {0}", vc.Value, vc.Key)
            //        });
            //    }
            //}
        }

        gameObject.SetActive(true);

        DialogCanvasController.RequestInventoryPrompt();
    }