public void AddingItems(string itemname) { int newAmount = 0; if (itemname == "SlowTime") { newAmount = itemsInventory.timeAmount + 1; itemsInventory = new SavedItems(newAmount, itemsInventory.destroyAmount); //ibmc.UpdateAmount(newAmount); } else if (itemname == "DestroyOrbs") { newAmount = itemsInventory.destroyAmount + 1; itemsInventory = new SavedItems(itemsInventory.timeAmount, newAmount); //ibmc.UpdateAmount(newAmount); } foreach (ItemButtonMenuController ib in buttons) { if (ib.spellName == itemname) { ib.UpdateAmount(newAmount); } } SavingItems(); }
public async Task <ActionResult <SavedItems> > PostSavedItems(SavedItems savedItems) { _context.SavedItems.Add(savedItems); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSavedItems", new { id = savedItems.Id }, savedItems)); }
public void PopulateButton(SpellItem spellOb, SavedItems itemamount) { spell = spellOb; itemIcon.sprite = spell.itemIcon; //buttonBase.color = spell.itemBackgroundColor; amountText.text = amount.ToString(); spellName = spell.itemName; if (spell.itemName == "SlowTime") { amount = itemamount.timeAmount; } else if (spell.itemName == "DestroyOrbs") { amount = itemamount.destroyAmount; } UpdateAmount(amount); foreach (ParticleSystem ps in bottleParticles) { var main = ps.main; Color temp = spell.itemBackgroundColor; main.startColor = temp; } }
public async Task <IActionResult> PutSavedItems(int id, SavedItems savedItems) { if (id != savedItems.Id) { return(BadRequest()); } _context.Entry(savedItems).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SavedItemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static void SaveItems(int time, int destroy) { itemAmounts = new SavedItems(time, destroy); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/items.gd"); bf.Serialize(file, SaveLoad.itemAmounts); file.Close(); }
public void Handle(UpdateSavedAnimations update) { ProtoService.Send(new GetSavedAnimations(), result => { if (result is Animations animation) { BeginOnUIThread(() => SavedItems.ReplaceWith(animation.AnimationsValue)); } }); }
public static SavedItems LoadItems() { if (File.Exists(Application.persistentDataPath + "/items.gd")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/items.gd", FileMode.Open); SaveLoad.itemAmounts = (SavedItems)bf.Deserialize(file); file.Close(); return(itemAmounts); } return(new SavedItems(0, 0)); }
public async Task <bool> IsDirty() { bool res = false; if (Items != null && SavedItems != null) { if (Items.Count() > SavedItems.Count()) { res = true; } else { foreach (PartUsage pu in Items) { if (pu.PartUsageId == 0) { //on the whole, items without id definitely haven't been saved yet res = true; break; } else if (!SavedItems.Any(i => i.PartUsageId == pu.PartUsageId)) { //Current item hasn't been saved yet res = true; break; } else if (SavedItems.Any(i => i.PartUsageId == pu.PartUsageId && (i.Amount != pu.Amount || i.Comment != pu.Comment))) { //Either Amount or Comment has changed for at least single item res = true; break; } } foreach (PartUsage pu in SavedItems) { if (!Items.Any(i => i.PartUsageId == pu.PartUsageId)) { //Current item must hvae been deleted but this info hasn't been saved res = true; break; } } } } return(res); }
public void Update() { if (_updated) { return; } _updated = true; ProtoService.Send(new GetSavedAnimations(), result => { if (result is Animations animation) { BeginOnUIThread(() => SavedItems.ReplaceWith(animation.AnimationsValue)); } }); }
public async Task <bool> IsDirty() { bool res = false; if (Items != null && SavedItems != null) { if (Items.Count() > SavedItems.Count()) { res = true; } else { foreach (File f in Items) { if (f.FileId == 0) { //on the whole, items without id definitely haven't been saved yet res = true; break; } else if (!SavedItems.Any(i => i.FileId == f.FileId)) { //Current item hasn't been saved yet res = true; break; } } foreach (File f in SavedItems) { if (!Items.Any(i => i.FileId == f.FileId)) { //Current item must hvae been deleted but this info hasn't been saved res = true; break; } } } } return(res); }
void UseItem(string itemname, ItemButtonMenuController ibmc) { //using in game, not during game you know int newAmount = 0; // SavedItems tempItems = new SavedItems(0,0); if (itemname == "SlowTime") { newAmount = itemsInventory.timeAmount - 1; itemsInventory = new SavedItems(newAmount, itemsInventory.destroyAmount); ibmc.UpdateAmount(newAmount); } else if (itemname == "DestroyOrbs") { newAmount = itemsInventory.destroyAmount - 1; itemsInventory = new SavedItems(itemsInventory.timeAmount, newAmount); ibmc.UpdateAmount(newAmount); } //itemsInventory = new SavedItems(tempItems.timeAmount, tempItems.destroyAmount); SavingItems(); }
public async Task <bool> IsDirty() { bool res = false; if (CheckedItems != null && SavedItems != null) { int checkedItems = CheckedItems.Where(i => i.IsChecked == true).Count(); int savedItems = SavedItems.Count(i => i.IsChecked == true); if (checkedItems > savedItems) { res = true; } else { foreach (ProcessAction pa in CheckedItems.Where(i => i.IsChecked == true)) { if (pa.ProcessActionId == 0) { //it's action user checked voluntarily //on the whole, items without id definitely haven't been saved yet res = true; break; } else if (SavedItems.Any(i => i.ProcessActionId == pa.ProcessActionId && i.IsChecked == false)) { //there's at least 1 item that IsChecked=true in CheckedItems that wasn't checked in saved items res = true; break; } } } } return(res); }
void LoadingItems() { itemsInventory = SaveLoad.LoadItems(); }