Esempio n. 1
0
        public bool ReceiveItems(NetObjectList <Item> chest, int needed, string type)
        {
            if (needed == 0)
            {
                return(true);
            }
            List <int> items;

            if (!JunimoPaymentsToday.TryGetValue(type, out items))
            {
                items = new List <int>();
                JunimoPaymentsToday[type] = items;
            }
            int paidSoFar = items.Count();

            if (paidSoFar == needed)
            {
                return(true);
            }

            foreach (int i in Enumerable.Range(paidSoFar, needed))
            {
                Item foundItem = chest.FirstOrDefault(item => item.getCategoryName() == type);
                if (foundItem != null)
                {
                    items.Add(foundItem.ParentSheetIndex);
                    Util.ReduceItemCount(chest, foundItem);
                }
            }
            return(items.Count() == needed);
        }
Esempio n. 2
0
        private bool UseItemAbility(Guid id, Vector2 pos, int itemCategory, Func <Vector2, int, bool> useItem)
        {
            JunimoHut            hut   = Util.GetHutFromId(id);
            NetObjectList <Item> chest = hut.output.Value.items;

            Item foundItem = chest.FirstOrDefault(item => item.Category == itemCategory);

            if (foundItem == null)
            {
                return(false);
            }
            bool success = useItem(pos, foundItem.ParentSheetIndex);

            if (success)
            {
                Util.ReduceItemCount(chest, foundItem);
                UpdateHutItems(id);
            }
            return(success);
        }