public void UpdateInventoryCategories() { Consumables.Clear(); Weapons.Clear(); KeyItems.Clear(); Statements.Clear(); foreach (var gameItemQuantity in _inventory) { if (gameItemQuantity.GameItem is Consumable) { Consumables.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is Weapon) { Weapons.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is KeyItem) { KeyItems.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is Statement) { Statements.Add(gameItemQuantity); } } }
public async Task <bool> Initialize() { // Create a filtered list of the product add-ons that are consumable string[] filterList = new string[] { "Consumable" }; var addOns = await storeContext.GetAssociatedStoreProductsAsync(filterList); if (addOns.ExtendedError != null) { if (addOns.ExtendedError.HResult == IAP_E_UNEXPECTED) { return(false); } } // Sort the list by price, lowest to highest foreach (StoreProduct product in addOns.Products.Values.OrderBy(x => x.Price.FormattedBasePrice.AsDouble())) { Consumables.Add(product); } // Get the current purchased balance from the Store Balance = await GetConsumableBalance(); return(true); }
private void SaveConsumableUpdate(ConsumableViewModel x) { EditingConsumable = null; EditingServingsConsumable = null; // new food item if (x.Id == null) { var newModel = new ConsumableViewModel(); newModel.Clone(x); newModel.Id = Guid.NewGuid().ToString(); Consumables.Add(newModel); } else { // Update existing food item var food = Consumables.FirstOrDefault(y => y.Id == x.Id); if (food == null) { var newModel = new ConsumableViewModel(); newModel.Clone(x); Consumables.Add(newModel); } else { food.Clone(x); // We save when we change the collection, so this is the only place we need to call save SaveConsumables(); } } }
public void AddConsumable([NotNull] ProtoEntityViewModel consumableViewModel, double intensity) { if (Consumables.Count == 0) { ConsumableEffect = new ConsumableEffectViewModel(this, consumableViewModel, intensity); EntityViewModelsManager.AddRecipe(ConsumableEffect); } else { ConsumableEffect.AddConsumable(consumableViewModel, intensity); } Consumables.Add(consumableViewModel); }
private void ExecuteAddConsumable(object parameter) { AssetModel cm = new AssetModel() { ID = 0, Name = string.Empty, ParentAssetID = Asset.ID, PONumber = string.Empty, DatePurchased = DateTime.Now }; cm.ID = AddConsumable(cm); Consumables.Add(cm); }
void Awake() { if (Instance != null && Instance != this) //si no existe o si existe y es otro que no sea el que ya se creó { Destroy(this.gameObject); } else { Instance = this; } foreach (Consumable consumable in GetComponents <Consumable>()) { Consumables.Add(consumable); Debug.Log(consumable.Name); } }
// Could use generic type and type checking to only have one func public void BuyItem(Thing item) { // this function takes an item checks if a user can afford it // then type checks it to and adds it to list unless player already owns it // then subtracts cost from gold if (Gold < item.Cost) { LineHelpers.PrintLineWithContinue("You cannot afford this item."); return; } if (item is Weapon) { Weapon weapon = item as Weapon; if (this.Weapons.Contains(weapon)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Weapons.Add(item as Weapon); } else if (item is Armor) { Armor armor = item as Armor; if (this.Armor.Contains(armor)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Armor.Add(armor); } else if (item is Consumable) { Consumable consumable = item as Consumable; if (this.Consumables.Contains(consumable)) { LineHelpers.PrintLineWithContinue("You already own this item."); return; } Consumables.Add(consumable); } LineHelpers.PrintLineWithContinue("The item has been added to your inventory."); Gold -= item.Cost; }