/// <summary> /// Sets up shop items based on previous purchases, meaning we /// set them to 'purchased' thus not purchasable in the GUI. /// Also select the items that were selected by the player before. /// </summary> public static void SetItemState() { //this method is based on data from the database, //so if we don't have a DBManager instance don't continue if (!DBManager.GetInstance()) { return; } //get array of purchased item ids, look them up in our //shop item dictionary and set them to purchased List <string> purchasedItems = DBManager.GetAllPurchased(); for (int i = 0; i < purchasedItems.Count; i++) { if (instance.IAPItems.ContainsKey(purchasedItems[i]) && IAPManager.GetIAPUpgrades(purchasedItems[i]).Count == 0) { instance.IAPItems[purchasedItems[i]].Purchased(true); } } //get dictionary of selected item ids, look them up in our //shop item dictionary and set the checkbox component to selected Dictionary <string, List <string> > selectedItems = DBManager.GetAllSelected(); foreach (string key in selectedItems.Keys) { for (int i = 0; i < selectedItems[key].Count; i++) { if (instance.IAPItems.ContainsKey(selectedItems[key][i])) { instance.IAPItems[selectedItems[key][i]].IsSelected(true); } } } }