示例#1
0
        /// <summary>
        /// This method initializes all items to the dictionary, and sets up the shop
        /// </summary>
        public static void SetupItems()
        {
            Items = new Dictionary <uint, Item>();

            string j = FileManager.ReadFullFile(DataFileNames.ItemMapFile);

            Dictionary <uint, ItemInfoNode> data = JsonConvert.DeserializeObject <Dictionary <uint, ItemInfoNode> >(j) ?? new Dictionary <uint, ItemInfoNode>();

            AddSpecialItems();

            foreach (uint k in data.Keys)
            {
                ItemInfoNode i = data[k];

                if (Items.ContainsKey(k))
                {
                    Item it = Items[k];

                    it.Id          = k;
                    it.Name        = i.Name;
                    it.Description = i.Description;
                    it.Rarity      = i.Rarity;
                    it.BuyPrice    = i.BuyPrice;
                    it.Buyable     = i.Buyable;
                    it.ImageUrl    = i.ImageUrl;
                    it.SetRecipe(i.Recipe);
                    continue;
                }

                Items.Add(k, new Item(k, i.Name, i.Description, i.Rarity, i.Buyable, i.BuyPrice, i.Recipe, i.ImageUrl));
            }

            KLog.Info("Loaded Items.");
        }
示例#2
0
 public static void AddItem(uint id, ItemInfoNode i)
 {
     AddItem(id, i.BuyPrice, i.Buyable);
 }