static public void SellItem(int itemID) { bool soldItem = false; for (int transactionIndex = 0; transactionIndex < Data.buyMultiplier; transactionIndex++) { if (itemsPurchased[Data.profile[Data.mode]].ContainsKey(itemID)) { itemsPurchased[Data.profile[Data.mode]][itemID] -= 1; if (itemsPurchased[Data.profile[Data.mode]][itemID] == 0) { itemsPurchased[Data.profile[Data.mode]].Remove(itemID); } soldItem = true; } else { break; } } if (soldItem) { Data.MakeDirectoryExist(); Data.SaveConfigProfile(); UIDrawer.Refresh(); } }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- static public void BuyItem(int itemID) { bool boughtItem = false; for (int transactionIndex = 0; transactionIndex < Data.buyMultiplier; transactionIndex++) { if (userPoints >= Data.GetItemPrice(itemID)) { if (!itemsPurchased[Data.profile[Data.mode]].ContainsKey(itemID)) { itemsPurchased[Data.profile[Data.mode]].Add(itemID, 0); } itemsPurchased[Data.profile[Data.mode]][itemID] += 1; userPoints -= Data.GetItemPrice(itemID); boughtItem = true; } else { break; } } if (boughtItem) { Data.MakeDirectoryExist(); Data.SaveConfigProfile(); UIDrawer.Refresh(); } }
static public void ToggleItem(int givenID, bool shouldRefresh = true) { if (Data.mode == mode) { if (shopMode == 0) { if (!blueprintsPurchased.Contains(givenID)) { itemsClicked.Add(new List <float>() { givenID, Time.time }); if (itemsClicked.Count == 2) { if (itemsClicked[0][0] == itemsClicked[1][0] && itemsClicked[1][1] - itemsClicked[0][1] <= doubleClickWindow) { int itemTier = Data.GetItemTier(givenID); if (scrap[itemTier] >= prices[itemTier]) { blueprintsPurchased.Add(givenID); scrap[itemTier] -= prices[itemTier]; SetScrapStarting(); UIDrawerShop.PurchaseItem(givenID); if (shouldRefresh) { Data.SaveConfigProfile(); UIDrawer.Refresh(); } } } itemsClicked.RemoveAt(0); } } } else if (shopMode == 1) { if (canDisablePurchasedBlueprints) { if (itemsToDrop[Data.profile[mode]].Contains(givenID)) { itemsToDrop[Data.profile[mode]].Remove(givenID); if (shouldRefresh) { Data.SaveConfigProfile(); UIDrawer.Refresh(); } } else { itemsToDrop[Data.profile[mode]].Add(givenID); if (shouldRefresh) { Data.SaveConfigProfile(); UIDrawer.Refresh(); } } } } } }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- static public void ToggleItem(int givenID, bool shouldRefresh = true) { if (Data.mode == mode) { if (itemsToDrop[Data.profile[mode]].Contains(givenID)) { itemsToDrop[Data.profile[mode]].Remove(givenID); if (shouldRefresh) { Data.SaveConfigProfile(); UIDrawer.Refresh(); } } else { itemsToDrop[Data.profile[mode]].Add(givenID); if (shouldRefresh) { Data.SaveConfigProfile(); UIDrawer.Refresh(); } } } }