Exemple #1
0
        private void RefreshCategories()
        {
            foreach (CategorySlot slot in slots)
            {
                slot.Hide();
            }

            PlayerCharacter player = parent_ui.GetPlayer();

            if (player != null)
            {
                int index = 0;
                List <GroupData> groups = player.Crafting.GetCraftGroups();

                foreach (GroupData group in groups)
                {
                    if (index < slots.Length)
                    {
                        CategorySlot     slot  = (CategorySlot)slots[index];
                        List <CraftData> items = CraftData.GetAllCraftableInGroup(parent_ui.GetPlayer(), group);
                        if (items.Count > 0)
                        {
                            slot.SetSlot(group);
                            index++;
                        }
                    }
                }

                CraftSubPanel.Get(GetPlayerID())?.Hide();
            }
        }
        void Update()
        {
            PlayerCharacter character = parent_ui.GetPlayer();

            if (character != null)
            {
                bar.SetMax(Mathf.RoundToInt(character.Attributes.GetAttributeMax(attribute)));
                bar.SetValue(Mathf.RoundToInt(character.Attributes.GetAttributeValue(attribute)));
            }
        }
 public virtual void InitPanel()
 {
     if (!IsPlayerSet())
     {
         PlayerUI        player_ui = GetComponentInParent <PlayerUI>();
         PlayerCharacter player    = player_ui ? player_ui.GetPlayer() : PlayerCharacter.GetFirst();
         if (player != null && current_player == null)
         {
             current_player = player; //Set default player
         }
     }
 }
Exemple #4
0
        public void RefreshCraftPanel()
        {
            foreach (ItemSlot slot in slots)
            {
                slot.Hide();
            }

            if (current_category == null || !IsVisible())
            {
                return;
            }

            //Show all items of a category
            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                List <CraftData> items = CraftData.GetAllCraftableInGroup(parent_ui.GetPlayer(), current_category);

                //Sort list
                items.Sort((p1, p2) =>
                {
                    return((p1.craft_sort_order == p2.craft_sort_order)
                        ? p1.title.CompareTo(p2.title) : p1.craft_sort_order.CompareTo(p2.craft_sort_order));
                });

                for (int i = 0; i < items.Count; i++)
                {
                    if (i < slots.Length)
                    {
                        CraftData item = items[i];
                        ItemSlot  slot = (ItemSlot)slots[i];
                        slot.SetSlot(item, 1, false);
                        slot.AnimateGain();
                    }
                }
            }
        }
        private void RefreshPanel()
        {
            slot.SetSlot(data, data.craft_quantity, true);
            title.text = data.title;
            desc.text  = data.desc;

            foreach (ItemSlot slot in craft_slots)
            {
                slot.Hide();
            }

            PlayerCharacter player = parent_ui.GetPlayer();

            CraftCostData cost  = data.GetCraftCost();
            int           index = 0;

            foreach (KeyValuePair <ItemData, int> pair in cost.craft_items)
            {
                if (index < craft_slots.Length)
                {
                    ItemSlot slot = craft_slots[index];
                    slot.SetSlot(pair.Key, pair.Value, false);
                    slot.SetFilter(player.Inventory.HasItem(pair.Key, pair.Value) ? 0 : 2);
                    slot.ShowTitle();
                }
                index++;
            }

            foreach (KeyValuePair <GroupData, int> pair in cost.craft_fillers)
            {
                if (index < craft_slots.Length)
                {
                    ItemSlot slot = craft_slots[index];
                    slot.SetSlotCustom(pair.Key.icon, pair.Key.title, pair.Value, false);
                    slot.SetFilter(player.Inventory.HasItemInGroup(pair.Key, pair.Value) ? 0 : 2);
                    slot.ShowTitle();
                }
                index++;
            }

            foreach (KeyValuePair <CraftData, int> pair in cost.craft_requirements)
            {
                if (index < craft_slots.Length)
                {
                    ItemSlot slot = craft_slots[index];
                    slot.SetSlot(pair.Key, pair.Value, false);
                    slot.SetFilter(player.Crafting.CountRequirements(pair.Key) >= pair.Value ? 0 : 2);
                    slot.ShowTitle();
                }
                index++;
            }

            if (index < craft_slots.Length)
            {
                ItemSlot slot = craft_slots[index];
                if (cost.craft_near != null)
                {
                    slot.SetSlotCustom(cost.craft_near.icon, cost.craft_near.title, 1, false);
                    bool isnear = player.IsNearGroup(cost.craft_near) || player.EquipData.HasItemInGroup(cost.craft_near);
                    slot.SetFilter(isnear ? 0 : 2);
                    slot.ShowTitle();
                }
            }

            craft_btn.interactable = player.Crafting.CanCraft(data);
        }
 public PlayerCharacter GetPlayer()
 {
     return(parent_ui ? parent_ui.GetPlayer() : PlayerCharacter.GetFirst());
 }