private void onInventoryChanged(ConsumableInventory inventory)
 {
     foreach (KeyValuePair <string, InventoryItemStock> item in inventory.inventoryMap)
     {
         if (inventoryItems.ContainsKey(item.Key))
         {
             if (item.Value.GetItemCount() > 0)
             {
                 if (inventoryItems.ContainsKey(item.Key))
                 {
                     inventoryItems[item.Key].SetCount(item.Value.GetItemCount());
                 }
             }
             else
             {
                 Object.Destroy(inventoryItems[item.Key]);
                 inventoryItems.Remove(item.Key);
             }
         }
         else if (item.Value.GetItemCount() > 0)
         {
             PropDefinition propDefinition = Service.Get <PropService>().Props[item.Key];
             GameObject     gameObject     = Object.Instantiate(inventoryItemPrefab);
             gameObject.transform.SetParent(ContentPanel.transform, worldPositionStays: false);
             gameObject.GetComponent <MarketplaceInventoryItem>().Init(itemSprites[propDefinition.GetIconContentKey().Key.ToLower()], propDefinition, item.Value.GetItemCount());
             inventoryItems[item.Key] = gameObject.GetComponent <MarketplaceInventoryItem>();
         }
     }
 }
Example #2
0
    protected override PropDefinition[] filterDefinitions(PropDefinition[] definitions)
    {
        List <PropDefinition> list = new List <PropDefinition>();

        if (definitions != null && definitions.Length > 0)
        {
            list.AddRange(definitions);
            list.RemoveAll((PropDefinition definition) => definition.PropType != PropDefinition.PropTypes.Consumable);
            list.RemoveAll((PropDefinition definition) => definition.ExperienceType != PropDefinition.ConsumableExperience.PartyGameLobby);
            list.RemoveAll((PropDefinition definition) => definition.ServerAddedItem);
            ConsumableInventory consumableInventory = Service.Get <CPDataEntityCollection>().GetComponent <ConsumableInventoryData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).ConsumableInventory;
            for (int num = list.Count - 1; num >= 0; num--)
            {
                if (consumableInventory.inventoryMap.ContainsKey(list[num].GetNameOnServer()))
                {
                    if (consumableInventory.inventoryMap[list[num].GetNameOnServer()].GetItemCount() == 0)
                    {
                        list.RemoveAt(num);
                    }
                }
                else
                {
                    list.RemoveAt(num);
                }
            }
        }
        return(list.ToArray());
    }
Example #3
0
    public void ConsumeItemFromUI()
    {
        PartyMember member = partyPanel.LookUpSelectedPartyMember();

        if (!IsCraftingItem(itemToConsume.item) && member != null)
        {
            ConsumableInventory consumableInventory = FindObjectOfType <ConsumableInventory>();
            bool success = consumableInventory.UseItemOutsideOfBattle(member, itemToConsume.item);
            if (success)
            {
                consumableInventory.ClearAndParseUInventory();
                UIPlayerInfoPanel infoPanel = FindObjectOfType <UIPlayerInfoPanel>();
                if (!infoPanel.gameObject.activeSelf)
                {
                    infoPanel.gameObject.SetActive(true);
                }
                infoPanel.Populate(member.characterName);
            }
            else
            {
                GiveItem(itemToConsume.item);
            }
        }
        itemToConsume.UpdateItem(null);
    }
Example #4
0
 protected void GetControllers()
 {
     inventoryController = FindObjectOfType <InventoryController>();
     craftingInventory   = FindObjectOfType <CraftingInventory>();
     consumableInventory = FindObjectOfType <ConsumableInventory>();
     characterController = FindObjectOfType <BattleSystem.CharacterController>();
     sceneController     = FindObjectOfType <SceneController>();
     questController     = FindObjectOfType <QuestController>();
 }
 void Awake()
 {
     craftingInventory   = FindObjectOfType <CraftingInventory>();
     consumableInventory = FindObjectOfType <ConsumableInventory>();
     characterController = FindObjectOfType <BattleSystem.CharacterController>();
     inventoryController = FindObjectOfType <InventoryController>();
     itemDatabase        = FindObjectOfType <ItemDatabase>();
     menuController      = FindObjectOfType <MenuController>();
     ClearSlots();
 }
Example #6
0
    public void UseConsumable(string consumableType)
    {
        ConsumableInventory consumableInventory = default(ConsumableInventory);

        consumableInventory.inventoryMap = new Dictionary <string, InventoryItemStock>(this.consumableInventory.inventoryMap);
        InventoryItemStock inventoryItemStock = consumableInventory.inventoryMap[consumableType];

        inventoryItemStock.DecrementCount();
        ConsumableInventory = consumableInventory;
    }
 private void onInventoryChanged(ConsumableInventory inventory)
 {
     if (prop.ExperienceType == PropDefinition.ConsumableExperience.PartyGameLobby)
     {
         marketplaceController.SetPurchasedPartyGame();
     }
     removePurchaseListeners();
     hidePurchaseModal();
     Service.Get <EventDispatcher>().DispatchEvent(new MarketplaceEvents.ItemPurchased(prop, purchaseCount));
     setState(ConfirmationState.Complete);
 }
Example #8
0
 private void Awake()
 {
     characterController = FindObjectOfType <CharacterController>();
     inventoryController = FindObjectOfType <InventoryController>();
     questController     = FindObjectOfType <QuestSystem.QuestController>();
     soundController     = GetComponent <BattleSoundController>();
     items = FindObjectOfType <ConsumableInventory>();
     EventController.OnEnemyDied += AddEnemyExperience;
     EventController.OnEnemyDied += AddRandomItem;
     HideMenus();
 }
Example #9
0
 private void Awake()
 {
     craftingSlots       = FindObjectOfType <CraftingSlots>();
     equipmentSlots      = FindObjectOfType <EquipmentSlots>();
     partyPanel          = FindObjectOfType <UIPartyPanel>();
     tooltip             = FindObjectOfType <Tooltip>();
     selectedItem        = GameObject.Find("SelectedItem").GetComponent <UIItem>();
     spriteImage         = GetComponent <Image>();
     consumableInventory = FindObjectOfType <ConsumableInventory>();
     craftingInventory   = FindObjectOfType <CraftingInventory>();
     inventoryController = FindObjectOfType <InventoryController>();
     UpdateItem(null);
 }
 public override void OnEnter()
 {
     if (!Service.Get <CPDataEntityCollection>().LocalPlayerHandle.IsNull)
     {
         ConsumableInventory consumableInventory = Service.Get <CPDataEntityCollection>().GetComponent <ConsumableInventoryData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).ConsumableInventory;
         string nameOnServer = PropDefinition.GetNameOnServer();
         if (consumableInventory.inventoryMap.ContainsKey(nameOnServer))
         {
             OUT_ItemCount.Value = consumableInventory.inventoryMap[nameOnServer].GetItemCount();
         }
     }
     Finish();
 }
    private void Awake()
    {
        craftingInventory   = FindObjectOfType <CraftingInventory>();
        consumableInventory = FindObjectOfType <ConsumableInventory>();
        questController     = FindObjectOfType <QuestController>();
        menuController      = FindObjectOfType <MenuController>();
        characterController = FindObjectOfType <BattleSystem.CharacterController>();
        inventoryController = FindObjectOfType <InventoryController>();
        sceneController     = FindObjectOfType <SceneController>();
        battleLauncher      = FindObjectOfType <BattleLauncher>();

        SceneManager.sceneLoaded += OnSceneLoaded;
    }
 private void onPropRetrieved(Prop prop)
 {
     if (!prop.PropDef.ServerAddedItem && prop.PropDef.GetIconContentKey() != null && !string.IsNullOrEmpty(prop.PropDef.GetIconContentKey().Key))
     {
         LoadIcon(prop.PropDef.GetIconContentKey());
         ConsumableInventory consumableInventory = Service.Get <CPDataEntityCollection>().GetComponent <ConsumableInventoryData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).ConsumableInventory;
         if (consumableInventory.inventoryMap.ContainsKey(prop.PropDef.GetNameOnServer()))
         {
             ItemCountText.text = consumableInventory.inventoryMap[prop.PropDef.GetNameOnServer()].GetItemCount().ToString();
         }
         else
         {
             ItemCountText.text = "0";
         }
     }
 }
    private void onInventoryItemPrefabLoaded(string path, GameObject prefab)
    {
        inventoryItemPrefab = prefab;
        ConsumableInventory consumableInventory = Service.Get <CPDataEntityCollection>().GetComponent <ConsumableInventoryData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).ConsumableInventory;

        foreach (PropDefinition value in Service.Get <PropService>().Props.Values)
        {
            string nameOnServer = value.GetNameOnServer();
            if (value.PropType == PropDefinition.PropTypes.Consumable && !value.ServerAddedItem && !value.QuestOnly && value.GetIconContentKey() != null && !string.IsNullOrEmpty(value.GetIconContentKey().Key) && consumableInventory.inventoryMap.ContainsKey(nameOnServer) && consumableInventory.inventoryMap[nameOnServer].GetItemCount() > 0)
            {
                GameObject gameObject = Object.Instantiate(prefab);
                gameObject.transform.SetParent(ContentPanel.transform, worldPositionStays: false);
                gameObject.GetComponent <MarketplaceInventoryItem>().Init(itemSprites[value.GetIconContentKey().Key.ToLower()], value, consumableInventory.inventoryMap[nameOnServer].GetItemCount());
                inventoryItems[nameOnServer] = gameObject.GetComponent <MarketplaceInventoryItem>();
            }
        }
    }
        public void Init(PropDefinition def)
        {
            definition = def;
            Title.text = Service.Get <Localizer>().GetTokenTranslation(def.Name);
            Content.LoadAsync(onIconLoaded, def.GetIconContentKey());
            SelectButton.onClick.AddListener(onSelected);
            if (def.ExperienceType == PropDefinition.ConsumableExperience.PartyGameLobby)
            {
                breadcrumb.SetBreadcrumbId(PartyGameBreadcrumbType, definition.Id.ToString());
                TutorialBreadcrumb.SetBreadcrumbId($"PartyGame_{definition.Id}");
            }
            else if (def.PropType == PropDefinition.PropTypes.Consumable)
            {
                breadcrumb.SetBreadcrumbId(ConsumableBreadcrumbType, definition.Id.ToString());
                TutorialBreadcrumb.SetBreadcrumbId($"Consumable_{definition.Id}");
            }
            else
            {
                breadcrumb.SetBreadcrumbId(GearBreadcrumbType, definition.Id.ToString());
                TutorialBreadcrumb.SetBreadcrumbId($"Gear_{definition.Id}");
            }
            ConsumableInventory consumableInventory = Service.Get <CPDataEntityCollection>().GetComponent <ConsumableInventoryData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle).ConsumableInventory;

            if (consumableInventory.inventoryMap.ContainsKey(definition.GetNameOnServer()))
            {
                int itemCount = consumableInventory.inventoryMap[definition.GetNameOnServer()].GetItemCount();
                if (itemCount == 0)
                {
                    ItemCountIcon.SetActive(value: false);
                }
                else
                {
                    ItemCountIcon.SetActive(value: true);
                    ItemCountIcon.GetComponentInChildren <Text>().text = itemCount.ToString();
                }
            }
            else
            {
                ItemCountIcon.SetActive(value: false);
            }
            if (def.PropType == PropDefinition.PropTypes.Durable)
            {
                showSelectedState();
            }
        }
Example #15
0
        private void setInventoryCount(ConsumableInventory inventory)
        {
            int num = 0;

            if (inventory.inventoryMap != null && inventory.inventoryMap.ContainsKey(consumableType))
            {
                num = inventory.inventoryMap[consumableType].GetItemCount();
            }
            if (num > 0)
            {
                InventoryCount.text = num.ToString();
            }
            else
            {
                InventoryCount.text = "$" + consumableCost;
            }
            inventoryCount = num;
        }
        public void BuildItemList()
        {
            ClearItemPanel();
            ConsumableInventory items           = BattleController.Instance.items;
            List <string>       listOfItemNames = new List <string>();

            if (items.playerItems.Count > 0)
            {
                foreach (Item item in items.playerItems)
                {
                    if (!listOfItemNames.Contains(item.itemName))
                    {
                        Button itemButton = Instantiate <Button>(button, itemPanel.transform);
                        itemButton.GetComponentInChildren <Text>().text = item.itemName;
                        itemButton.onClick.AddListener(() => SelectItem(item));
                        listOfItemNames.Add(item.itemName);
                    }
                }
            }
        }
 private void onInventoryChanged(ConsumableInventory inventory)
 {
     base.Fsm.Event(ChangedEvent);
     Finish();
 }
Example #18
0
 public InventoryRecieved(ConsumableInventory inventory)
 {
     Inventory = inventory;
 }