private void Start() { inventoryWindowItems = new List <InventoryWindowSection>(); // Иницилизируем список с индексами и пустыми ItemInInventoryWindowGrid, здесь же создаем префабы для отображения айтемов for (int i = 0; i < inventory.maxCountItem; i++) { inventoryWindowItems.Add(new InventoryWindowSection { item = null, index = i }); // В таблицу ItemIn obj = Instantiate(prefabGridItem, gridParent); obj.Init(inventoryWindowItems[i], this); // В список ItemIn obj2 = Instantiate(prefabListItem, listParent); obj2.Init(inventoryWindowItems[i], this); } // Добавляем в предметы, которые находяться в инвентаре for (int i = 0; i < inventory.items.Count; i++) { InventoryAddItem(inventory.items[i]); } // Слушатель на добавление новых предметов inventory.items.OnAddEvent.AddListener(InventoryAddItem); inventory.items.OnRemoveEvent.AddListener(InventoryRemoveItem); }
public IActionResult Update(long id, ItemIn itemNoId) { if (!AuthenticationController.CheckToken(HttpContext, out string _)) { return(Unauthorized()); } using (var db = new DatabaseAccess()) { var itemOld = db.Items.Find(id); if (itemOld == null) { return(NotFound()); } if (itemOld.QRCode != itemNoId.QRCode && itemNoId.QRCode != null && db.Items.Where(i => i.QRCode == itemNoId.QRCode).Any()) { return(Conflict("An item with that qr code already exists")); } itemOld.Copy(itemNoId); db.SaveChanges(); return(Accepted()); } }
public override void Click(float X, float Y) { if (!CanGrab && !CanPut) //nothing to do here { return; } IActionIcon mouseItem = WM.MouseGrab; IActionIcon currentItem = this.Item; if (mouseItem == null) { if (currentItem == null) //nothing to do here { return; } else // take the item { WM.MouseGrab = currentItem; this.Item = null; ItemOut?.Invoke(this, new ItemEventArgs(currentItem)); } } else //if mouse has something { if (!CanPut) //can't grab item: mouse full { return; } ItemEventArgs iargs = new ItemEventArgs(mouseItem); BeforeItemChanged?.Invoke(this, iargs); if (iargs.Cancel) //custom function declined the item or no custom function { return; } if (currentItem == null) //put in item { iargs = new ItemEventArgs(mouseItem); ItemIn?.Invoke(this, iargs); this.Item = mouseItem; WM.MouseGrab = null; } else //swap items { iargs = new ItemEventArgs(mouseItem); ItemIn?.Invoke(this, iargs); if (iargs.Cancel) { return; } this.Item = mouseItem; WM.MouseGrab = currentItem; iargs = new ItemEventArgs(mouseItem); ItemOut?.Invoke(this, iargs); } } base.Click(X, Y); }
public virtual void OnDrop(PointerEventData pointer) { ItemIn com = pointer.pointerDrag.GetComponent <ItemIn>(); if (com != null && com.selfItem.item != null) { window.Move(GetComponent <ItemIn>().selfItem, pointer.pointerDrag.GetComponent <ItemIn>().selfItem); window.SetSelectedItem(this.selfItem); } }
public async Task <IActionResult> ItemRegister(ItemIn item) { double cost = 0; if (Double.TryParse(item.cost, NumberStyles.Number, CultureInfo.CreateSpecificCulture("en-US"), out cost) && cost > 0.01) { cost = Math.Round(cost, 2); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _context.Database.ExecuteSqlInterpolatedAsync($"INSERT INTO Items VALUES ({null}, {cost}, {item.provider_name}, {item.name});"); } else { return(BadRequest(new { errorText = "Invalid cost input! Example: 25,55" })); } return(Ok()); }