Example #1
0
        /// <summary>
        /// Adds an item into an existing item container.
        /// </summary>
        /// <param name="itemCategory"></param>
        /// <param name="containerName"></param>
        /// <param name="addition"></param>
        public void addToItemContainer(string itemCategory, string containerName, RSItem addition)
        {
            MenuValue menuSpot = getValueByName(itemCategory);

            foreach (ItemContainer ic in itemGroups[menuSpot])
            {
                if (ic.CategoryName == containerName)
                {
                    ic.items.Add(addition);
                }
            }
        }
Example #2
0
 public void setFilledValue(RSItem item)
 {
     foreach (KeyValuePair <MenuValue, List <ItemContainer> > pair in itemGroups)
     {
         foreach (ItemContainer ic in pair.Value)
         {
             for (int i = 0; i < ic.items.Count; i++)
             {
                 if (ic.items[i].imageName == item.imageName)
                 {
                     ic.items[i] = item;
                 }
             }
         }
     }
 }
Example #3
0
        public RSItem lookForFilledValue(RSItem item)
        {
            foreach (KeyValuePair <MenuValue, List <ItemContainer> > pair in itemGroups)
            {
                foreach (ItemContainer ic in pair.Value)
                {
                    foreach (RSItem rsi in ic.items)
                    {
                        if (rsi.imageName == item.imageName)
                        {
                            if (rsi.ownedAmount > 0)
                            {
                                return(rsi);
                            }
                        }
                    }
                }
            }


            return(null);
        }
        public static void fillManagerWithResourceData(ItemManager manager, string menuValue)
        {
            string val = menuValue;

            val = val.Replace(" ", "_");
            List <string> skillFileNames = textfileFromResources(val + "_names");

            if (skillFileNames != null)
            {
                foreach (string container_name in skillFileNames)
                {
                    string        l          = val + "_";
                    string        actualName = container_name.Remove(0, l.Length);
                    ItemContainer ic         = new ItemContainer(actualName, actualName);
                    if (!manager.itemGroups[manager.getValueByName(menuValue)].Contains(ic))
                    {
                        List <string> ItemFileNames = textfileFromResources(container_name);
                        foreach (string item in ItemFileNames)
                        {
                            int seperatorIndex1 = item.IndexOf(":");
                            int seperatorIndex2 = item.IndexOf("(");
                            int seperatorIndex3 = item.IndexOf(")");

                            string itemName   = item.Substring(0, seperatorIndex1);
                            int    itemID     = Convert.ToInt16(item.Substring(seperatorIndex1 + 1, seperatorIndex2 - seperatorIndex1 - 1));
                            int    itemAmount = Convert.ToInt16(item.Substring(seperatorIndex2 + 1, seperatorIndex3 - seperatorIndex2 - 1));
                            RSItem rsItem     = new RSItem(itemName, itemID);
                            rsItem.ownedAmount = itemAmount;
                            if (rsItem.itemid == 0)
                            {
                                rsItem.shouldOnlyHaveOne = true;
                            }
                            ic.items.Add(rsItem);
                        }
                        manager.addToItemGroup(menuValue, ic);
                    }
                }
            }
        }
        public static void loadAllItems(ItemManager manager)
        {
            Dictionary <string, List <ItemContainer> > loadedValues = new Dictionary <string, List <ItemContainer> >();
            string contPath = folderPath + "\\Containers\\";

            if (Directory.Exists(contPath))
            {
                foreach (KeyValuePair <MenuValue, List <ItemContainer> > pair in manager.itemGroups)
                {
                    string containerPath = folderPath + "\\Containers\\" + pair.Key.menuItemName + "\\";

                    if (Directory.Exists(containerPath))
                    {
                        string[] files = Directory.GetFiles(containerPath);
                        foreach (string s in files)
                        {
                            string   fname    = s.Remove(0, containerPath.Length);
                            string   fileName = fname.Remove(fname.IndexOf("."), fname.Length - fname.IndexOf("."));
                            string[] entries  = File.ReadAllLines(s);

                            ItemContainer ic = new ItemContainer(fileName, fileName);

                            foreach (string line in entries)
                            {
                                int seperatorIndex1 = line.IndexOf(":");
                                int seperatorIndex2 = line.IndexOf("(");
                                int seperatorIndex3 = line.IndexOf(")");

                                string itemName   = line.Substring(0, seperatorIndex1);
                                int    itemID     = Convert.ToInt32(line.Substring(seperatorIndex1 + 1, seperatorIndex2 - seperatorIndex1 - 1));
                                int    itemAmount = Convert.ToInt32(line.Substring(seperatorIndex2 + 1, seperatorIndex3 - seperatorIndex2 - 1));
                                RSItem item       = new RSItem(itemName, itemID);
                                item.ownedAmount = itemAmount;
                                if (item.itemid == 0)
                                {
                                    item.shouldOnlyHaveOne = true;
                                }
                                ic.items.Add(item);

                                if (!manager.itemGroups[pair.Key].Contains(ic))
                                {
                                    manager.addToItemGroup(pair.Key.menuItemName, ic);
                                }
                            }
                        }
                    }
                    else
                    {
                        fillManagerWithResourceData(manager, pair.Key.menuItemName);
                    }
                }
            }
            else
            {
                //GET stuff from resources?
                foreach (KeyValuePair <MenuValue, List <ItemContainer> > pair in manager.itemGroups)
                {
                    fillManagerWithResourceData(manager, pair.Key.menuItemName);
                }
            }
        }