public static bool BuyItem(Player player, int price, int currencyIndex)
        {
            CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
            bool overFlowing;
            long num1 = currency.CountCurrency(out overFlowing, player.inventory, 58, 57, 56, 55, 54);
            long num2 = currency.CountCurrency(out overFlowing, player.bank.item);
            long num3 = currency.CountCurrency(out overFlowing, player.bank2.item);
            long num4 = currency.CountCurrency(out overFlowing, player.bank3.item);
            long num5 = currency.CountCurrency(out overFlowing, player.bank4.item);

            if (currency.CombineStacks(out overFlowing, num1, num2, num3, num4, num5) < (long)price)
            {
                return(false);
            }
            List <Item[]> objArrayList = new List <Item[]>();
            Dictionary <int, List <int> > slotsToIgnore = new Dictionary <int, List <int> >();
            List <Point> pointList1 = new List <Point>();
            List <Point> slotCoins  = new List <Point>();
            List <Point> pointList2 = new List <Point>();
            List <Point> pointList3 = new List <Point>();
            List <Point> pointList4 = new List <Point>();
            List <Point> pointList5 = new List <Point>();

            objArrayList.Add(player.inventory);
            objArrayList.Add(player.bank.item);
            objArrayList.Add(player.bank2.item);
            objArrayList.Add(player.bank3.item);
            objArrayList.Add(player.bank4.item);
            for (int index = 0; index < objArrayList.Count; ++index)
            {
                slotsToIgnore[index] = new List <int>();
            }
            slotsToIgnore[0] = new List <int>()
            {
                58,
                57,
                56,
                55,
                54
            };
            for (int x = 0; x < objArrayList.Count; ++x)
            {
                for (int y = 0; y < objArrayList[x].Length; ++y)
                {
                    if (!slotsToIgnore[x].Contains(y) && currency.Accepts(objArrayList[x][y]))
                    {
                        slotCoins.Add(new Point(x, y));
                    }
                }
            }
            CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList1, 0);
            CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList2, 1);
            CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList3, 2);
            CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList4, 3);
            CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList5, 4);
            return(currency.TryPurchasing(price, objArrayList, slotCoins, pointList1, pointList2, pointList3, pointList4, pointList5));
        }
Exemple #2
0
        // Token: 0x06001040 RID: 4160 RVA: 0x003FEC60 File Offset: 0x003FCE60
        public static bool BuyItem(Player player, int price, int currencyIndex)
        {
            CustomCurrencySystem customCurrencySystem = CustomCurrencyManager._currencies[currencyIndex];
            bool flag;
            long num = customCurrencySystem.CountCurrency(out flag, player.inventory, new int[]
            {
                58,
                57,
                56,
                55,
                54
            });
            long num2 = customCurrencySystem.CountCurrency(out flag, player.bank.item, new int[0]);
            long num3 = customCurrencySystem.CountCurrency(out flag, player.bank2.item, new int[0]);
            long num4 = customCurrencySystem.CountCurrency(out flag, player.bank3.item, new int[0]);

            if (customCurrencySystem.CombineStacks(out flag, new long[]
            {
                num,
                num2,
                num3,
                num4
            }) < (long)price)
            {
                return(false);
            }
            List <Item[]> list = new List <Item[]>();
            Dictionary <int, List <int> > dictionary = new Dictionary <int, List <int> >();
            List <Point> list2 = new List <Point>();
            List <Point> list3 = new List <Point>();
            List <Point> list4 = new List <Point>();
            List <Point> list5 = new List <Point>();
            List <Point> list6 = new List <Point>();

            list.Add(player.inventory);
            list.Add(player.bank.item);
            list.Add(player.bank2.item);
            list.Add(player.bank3.item);
            for (int i = 0; i < list.Count; i++)
            {
                dictionary[i] = new List <int>();
            }
            dictionary[0] = new List <int>
            {
                58,
                57,
                56,
                55,
                54
            };
            for (int j = 0; j < list.Count; j++)
            {
                for (int k = 0; k < list[j].Length; k++)
                {
                    if (!dictionary[j].Contains(k) && customCurrencySystem.Accepts(list[j][k]))
                    {
                        list3.Add(new Point(j, k));
                    }
                }
            }
            CustomCurrencyManager.FindEmptySlots(list, dictionary, list2, 0);
            CustomCurrencyManager.FindEmptySlots(list, dictionary, list4, 1);
            CustomCurrencyManager.FindEmptySlots(list, dictionary, list5, 2);
            CustomCurrencyManager.FindEmptySlots(list, dictionary, list6, 3);
            return(customCurrencySystem.TryPurchasing(price, list, list3, list2, list4, list5, list6));
        }