private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == dataGridView1.Columns["Save"].Index) { if (!Access.Instance.CanProceed(Modules.Item, Actions.Edit)) { return; } Item record = (Item)dataGridView1.Rows[e.RowIndex].DataBoundItem; record.CompanyId = Session.Instance.AuthUser.CompanyId; ItemBS.AddItem(record); PopulateInventory(); return; } if (e.ColumnIndex == dataGridView1.Columns["Delete"].Index) { if (!Access.Instance.CanProceed(Modules.Inventory, Actions.Edit)) { return; } ItemBS.DeleteItem(((Item)dataGridView1.Rows[e.RowIndex].DataBoundItem).ItemId); PopulateInventory(); return; } }
// makes shooting noise when called public void makeSound() { shotspawn = transform; item = GetComponent <ItemBS>(); if (shotClip != null) { AudioSource.PlayClipAtPoint(shotClip, shotspawn.position); } }
// puts in inventory if possible public bool pickUp(ItemBS item) { if (canCarry(item)) { if (false == inventory.Contains(item)) { inventory.Add(item); return(true); } } return(false); }
// TODO: can the character carry this item? public bool canCarry(ItemBS item) { if (item.size == ItemBS.Size.Small) { float w = getWeight(); // You cant carry more than weight capacity if ((w + item.weight) <= (weightCapacity)) { return(true); } } return(false); }
// TODO TEST public void dropItem(ItemBS item) { if (inventory.Contains(item)) { inventory.Remove(item); } GameObject go = item.gameObject; SpriteRenderer sr = go.GetComponent <SpriteRenderer>(); sr.enabled = true; // make it visible Collider2D c = item.coldr; c.enabled = true; Vector3 newPos = transform.position; go.transform.SetParent(GAMESTATE.transform); go.transform.position = transform.position; }
private void PopulateInventory() { List <Item> records = null; records = ItemBS.GetAllItems().Where(item => item.IsActive && item.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var categories = CategoryBS.GetAllCategories().Where(item => item.IsActive && item.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var itemList = new BindingList <Item>(records); dataGridView1.DataSource = itemList; HideUnwantedColumns(); var itelList = (from rec in categories select new { CategoryId = rec.CategoryId, CategoryName = rec.CategoryName }).ToList().Distinct(); foreach (var item in itelList) { if (!mCategoryDict.ContainsKey(item.CategoryId)) { mCategoryDict.Add(item.CategoryId, item.CategoryName); } } //DataGridViewComboBoxCell bc = new DataGridViewComboBoxCell(); //bc.DataSource = mCategoryDict.ToArray(); //bc.ValueMember = "Key"; //bc.DisplayMember = "Value"; //DataGridViewColumn cc = new DataGridViewColumn(bc); //cc.Name = "Category"; //cc.HeaderText = "Category"; //int columnIndex = dataGridView1.Columns.Add(cc); //foreach (DataGridViewRow item in dataGridView1.Rows) //{ // item.Cells[columnIndex].Value = item.Cells["CategoryId"].Value; //} GenerateCommonColumns(); }
// Use this for initialization void Start() { item = GetComponent <ItemBS>(); }