/// <inheritdoc /> public IMapLayer CreateLayer(IMapInstance parentMapInstance, int layerId) { var mapLayer = ActivatorUtilities.CreateInstance <MapLayer>(_serviceProvider, parentMapInstance, layerId); foreach (IMapRegion region in parentMapInstance.Regions) { if (region is IMapRespawnRegion respawnRegion) { if (respawnRegion.ObjectType == WorldObjectType.Mover) { for (int i = 0; i < respawnRegion.Count; i++) { IMonsterEntity monster = _monsterFactory.CreateMonster(parentMapInstance, mapLayer, respawnRegion.ModelId, respawnRegion); mapLayer.AddEntity(monster); } } else if (respawnRegion.ObjectType == WorldObjectType.Item) { var item = _itemFactory.CreateItem(respawnRegion.ModelId, 0, 0, 0); for (int i = 0; i < respawnRegion.Count; ++i) { IItemEntity itemEntity = _itemFactory.CreateItemEntity(parentMapInstance, mapLayer, item); itemEntity.Object.Position = respawnRegion.GetRandomPosition(); itemEntity.Region = respawnRegion; mapLayer.AddEntity(itemEntity); } } } } return(mapLayer); }
/// <summary> /// Verify all conditions to pickup a dropped item. /// </summary> /// <param name="droppedItem">The dropped item.</param> private void PickUpDroppedItem(IItemEntity droppedItem) { // TODO: check if drop belongs to a party. if (droppedItem.Drop.HasOwner && droppedItem.Drop.Owner != _player) { _textPacketFactory.SendDefinedText(_player, DefineText.TID_GAME_PRIORITYITEMPER, $"\"{droppedItem.Object.Name}\""); return; } if (droppedItem.Drop.IsGold) { int droppedGoldAmount = droppedItem.Drop.Item.Quantity; if (_playerDataSystem.IncreaseGold(_player, droppedGoldAmount)) { _textPacketFactory.SendDefinedText(_player, DefineText.TID_GAME_REAPMONEY, droppedGoldAmount.ToString("###,###,###,###"), _player.PlayerData.Gold.ToString("###,###,###,###")); } } else { _inventorySystem.CreateItem(_player, droppedItem.Drop.Item, droppedItem.Drop.Item.Quantity); _textPacketFactory.SendDefinedText(_player, DefineText.TID_GAME_REAPITEM, $"\"{droppedItem.Object.Name}\""); } _moverPacketFactory.SendMotion(_player, ObjectMessageType.OBJMSG_PICKUP); droppedItem.Delete(); }
public IventoryItemView Insert(int index, IItemEntity entity) { var ret = factory.Instantiate(entity); ret.transform.SetParent(transform); return(ret); }
public void ToDomain(IItemEntity entity, IItem domain) { domain.Id = entity.Id; domain.DateTimeCreated = entity.DateTimeCreated; domain.DateTimeLastModified = entity.DateTimeLastModified; domain.OwnedByUserId = entity.OwnedByUserId; domain.Active = entity.Active; domain.Name = entity.Name; domain.Comments = entity.Comments; }
private void AdicionarItem() { IItemEntity itemNovo = (ItemEntity)lstItens.SelectedItem; MovimentoEntradaItemEntity newItem = new MovimentoEntradaItemEntity { IdItem = itemNovo.IdItem }; int rowId = dtgridItensSelecionados.Rows.AddCopy(0); dtgridItensSelecionados.Rows[rowId].Cells["CodigoItem"].Value = newItem.item.IdItem; dtgridItensSelecionados.Rows[rowId].Cells["Nome"].Value = newItem.item.Nome; dtgridItensSelecionados.Rows[rowId].Cells["Deposito"].Value = newItem.item.IdDeposito; }
public IventoryItemView Instantiate(IItemEntity entity) { GameObject game = Instantiate(prefab); game.SetActive(true); var ret = game.GetComponent <IventoryItemView>(); ret.Name = entity.Name; ret.Money = entity.Money; ret.Weight = entity.Weight; return(ret); }
/// <inheritdoc /> public void DropItem(IWorldEntity entity, ItemDescriptor item, IWorldEntity owner, int quantity = 1) { Item droppedItem = _itemFactory.CreateItem(item.Id, item.Refine, item.Element, item.ElementRefine); IItemEntity newItem = _itemFactory.CreateItemEntity(entity.Object.CurrentMap, entity.Object.CurrentLayer, droppedItem, owner); newItem.Drop.Item.Quantity = quantity; newItem.Object.Position = Vector3.GetRandomPositionInCircle(entity.Object.Position, DropCircleRadius); if (newItem.Drop.HasOwner) { newItem.Drop.OwnershipTime = Time.TimeInSeconds() + _worldServerConfiguration.Drops.OwnershipTime; newItem.Drop.DespawnTime = Time.TimeInSeconds() + _worldServerConfiguration.Drops.DespawnTime; } owner.Object.CurrentLayer.AddEntity(newItem); }
public void ToEntity(IItem domain, IItemEntity entity) { entity.Id = domain.Id; // When mapping down to the entity model for the first time, populate these values. // These could get overridden during the save; this is mostly to fulfil the non-null constraint on the entity. entity.DateTimeCreated = domain.DateTimeCreated ?? DateTime.Now; entity.DateTimeLastModified = domain.DateTimeLastModified ?? DateTime.Now; entity.OwnedByUserId = domain.OwnedByUserId; entity.Active = domain.Active; // Guard against over-sized name/field comments (indicates problem with UI or user tampering with DOM) entity.Name = TruncateIfBeyond(domain.Name, 255, $"a name for a {domain.GetType()} (id {domain.Id}) "); entity.Comments = TruncateIfBeyond(domain.Comments, 65_535, $"comments for a {domain.GetType()} (id {domain.Id}) "); }
public void AlterarItem(IItemEntity item, int codigoItem) { String insSQL = "UPDATE ITEM SET " + " NOME = '" + item.Nome + "'," + " DESCRICAOITEM = '" + item.DescricaoItem + "'," + " IDTIPOITEM = '" + item.IdTipoItem + "'," + " IDDEPOSITO = '" + item.IdDeposito + "'" + " WHERE IDITEM = " + codigoItem; String strConn = conec; SQLiteConnection conn = new SQLiteConnection(conec); conn.Open(); SQLiteCommand sqlComm = new SQLiteCommand(insSQL, conn); sqlComm.ExecuteNonQuery(); conn.Close(); conn.Dispose(); }
public void IncluirItem(IItemEntity item) { String insSQL = "INSERT INTO ITEM(" + " NOME," + " DESCRICAOITEM," + " IDTIPOITEM," + " IDDEPOSITO) values (" + "'" + item.Nome + "'," + "'" + item.DescricaoItem + "'," + "'" + item.IdTipoItem + "'," + "'" + item.IdDeposito + "'" + ");"; String strConn = conec; SQLiteConnection conn = new SQLiteConnection(conec); conn.Open(); SQLiteCommand sqlComm = new SQLiteCommand(insSQL, conn); sqlComm.ExecuteNonQuery(); conn.Close(); conn.Dispose(); }
/// <summary> /// Verify all conditions to pickup a dropped item. /// </summary> /// <param name="player">The player trying to pick-up the dropped item.</param> /// <param name="droppedItem">The dropped item.</param> private void PickUpDroppedItem(IPlayerEntity player, IItemEntity droppedItem) { // TODO: check if drop belongs to a party. if (droppedItem.Drop.HasOwner && droppedItem.Drop.Owner != player) { WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_PRIORITYITEMPER, $"\"{droppedItem.Object.Name}\""); return; } if (droppedItem.Drop.IsGold) { int droppedGoldAmount = droppedItem.Drop.Item.Quantity; long gold = player.PlayerData.Gold + droppedGoldAmount; if (gold > int.MaxValue || gold < 0) // Check gold overflow { WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_TOOMANYMONEY_USE_PERIN); return; } else { player.PlayerData.Gold = (int)gold; WorldPacketFactory.SendUpdateAttributes(player, DefineAttributes.GOLD, player.PlayerData.Gold); WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_REAPMONEY, droppedGoldAmount.ToString("###,###,###,###"), gold.ToString("###,###,###,###")); } } else { var inventoryItemCreationEvent = new InventoryCreateItemEventArgs(droppedItem.Drop.Item.Id, droppedItem.Drop.Item.Quantity, -1, droppedItem.Drop.Item.Refine); player.NotifySystem <InventorySystem>(inventoryItemCreationEvent); WorldPacketFactory.SendDefinedText(player, DefineText.TID_GAME_REAPITEM, $"\"{droppedItem.Object.Name}\""); } WorldPacketFactory.SendMotion(player, ObjectMessageType.OBJMSG_PICKUP); droppedItem.Delete(); }
/// <summary> /// Resets a drop ownership. /// </summary> /// <param name="dropItem"></param> private void ResetDropOwnership(IItemEntity dropItem) { dropItem.Drop.Owner = null; dropItem.Drop.OwnershipTime = 0; }
public static void AlterarItem(IItemEntity item, int codigoItem) { ItemSqlFactory fac = new ItemSqlFactory(); fac.AlterarItem(item, codigoItem); }
public static void IncluirItem(IItemEntity item) { ItemSqlFactory fac = new ItemSqlFactory(); fac.IncluirItem(item); }
private void btnSalvarEntrada_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Deseja realmente criar um novo registro?", "Confirma a criação ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { MovimentoEntradaEntity entrada = new MovimentoEntradaEntity(); IList<MovimentoEntradaItemEntity> itens = new List<MovimentoEntradaItemEntity>(); entrada.IdFornecedor = _fornecedorSelecionado; entrada.DataMovimento = DateTime.Now; entrada.IdUsuario = Properties.Settings.Default.IdUsuarioLogado; foreach (DataGridViewRow row in dtgridItensSelecionados.Rows) { if (row.Cells["CodigoItem"].Value != null && row.Cells["CodigoItem"].Value.ToString() != "") { if (row.Cells["Quantidade"].Value == null) { MessageBox.Show("Preencha a quantidade para o item " + row.Cells["ItemId"].Value + " - " + row.Cells["ItemName"].Value, "Campo Inválido"); return; } IItemEntity item = ItemDao.ConsultarPorCodigo(Convert.ToInt32(row.Cells["CodigoItem"].Value)); MovimentoEntradaItemEntity entradaItem = new MovimentoEntradaItemEntity(); entradaItem.IdItem = item.IdItem; entradaItem.IdDeposito = Convert.ToInt32(row.Cells["Deposito"].Value); entradaItem.QtdTotal = Convert.ToInt32(row.Cells["Quantidade"].Value); itens.Add(entradaItem); } } entrada.IdMovimentacaoEntrada = MovimentoEntradaDao.Inserir(entrada); foreach (var entradaItem in itens) { entradaItem.IdMovimentoEntrada = entrada.IdMovimentacaoEntrada; MovimentoEntradaItemEntity movimento = new MovimentoEntradaItemEntity { IdMovimentoEntrada = entradaItem.IdMovimentoEntrada, IdItem = entradaItem.IdItem, IdDeposito = entradaItem.IdDeposito, QtdTotal = entradaItem.QtdTotal }; MovimentoEntradaItemDao.Inserir(movimento); EstoqueEntity estoque = new EstoqueEntity { IdItem = entradaItem.IdItem, QuantidadeTotal = entradaItem.QtdTotal, QuantidadeUtilizada = 0 }; IEstoqueEntity estoqueItem = EstoqueDao.ConsultarPorCodigoItem(entradaItem.IdItem); if (estoqueItem != null) { EstoqueEntity atualizarEstoque = new EstoqueEntity { IdItem = entradaItem.IdItem, QuantidadeTotal = entradaItem.QtdTotal + estoqueItem.QuantidadeTotal, QuantidadeUtilizada = 0 }; EstoqueDao.Atualizar(atualizarEstoque, entradaItem.IdItem); } else { EstoqueDao.Incluir(estoque); } } MessageBox.Show("Registro gravado com sucesso!"); this.Close(); } }
public ShopService(IProductService productService, IOrderEntity orderEntity, IItemEntity itemEntity) { ProductService = productService; OrderEntity = orderEntity; ItemEntity = itemEntity; }
private void btnSalvarSaida_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Deseja realmente criar um novo registro?", "Confirma a criação ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { MovimentoSaidaEntity saida = new MovimentoSaidaEntity(); IList <MovimentoSaidaItemEntity> itens = new List <MovimentoSaidaItemEntity>(); saida.IdCliente = 1; saida.DataMovimento = DateTime.Now; saida.IdUsuario = Properties.Settings.Default.IdUsuarioLogado; foreach (DataGridViewRow row in dtgridItensSelecionados.Rows) { if (row.Cells["CodigoItem"].Value != null && row.Cells["CodigoItem"].Value.ToString() != "") { if (row.Cells["Quantidade"].Value == null) { MessageBox.Show("Preencha a quantidade para o item " + row.Cells["CodigoItem"].Value + " - " + row.Cells["Nome"].Value, "Campo Inválido"); return; } IEstoqueEntity estoque = EstoqueDao.ConsultarPorCodigoItem(Convert.ToInt32(row.Cells["CodigoItem"].Value)); if (Convert.ToInt32(row.Cells["Quantidade"].Value) > estoque.QuantidadeDisponivel) { MessageBox.Show("A quantidade disponivel para o item " + row.Cells["CodigoItem"].Value + row.Cells["Nome"].Value + " é de " + estoque.QuantidadeDisponivel); return; } IItemEntity item = ItemDao.ConsultarPorCodigo(Convert.ToInt32(row.Cells["CodigoItem"].Value)); MovimentoSaidaItemEntity saidaItem = new MovimentoSaidaItemEntity(); saidaItem.IdItem = item.IdItem; saidaItem.IdDeposito = Convert.ToInt32(row.Cells["Deposito"].Value); saidaItem.QtdTotal = Convert.ToInt32(row.Cells["Quantidade"].Value); itens.Add(saidaItem); } } saida.IdMovimentoSaida = MovimentoSaidaDao.Inserir(saida); foreach (var saidaItem in itens) { saidaItem.IdMovimentoSaida = saida.IdMovimentoSaida; MovimentoSaidaItemEntity movimento = new MovimentoSaidaItemEntity { IdMovimentoSaida = saidaItem.IdMovimentoSaida, IdItem = saidaItem.IdItem, IdDeposito = saidaItem.IdDeposito, QtdTotal = saidaItem.QtdTotal }; MovimentoSaidaItemDao.Inserir(movimento); IEstoqueEntity estoqueItem = EstoqueDao.ConsultarPorCodigoItem(saidaItem.IdItem); EstoqueEntity estoque = new EstoqueEntity { QuantidadeTotal = estoqueItem.QuantidadeTotal - saidaItem.QtdTotal }; EstoqueDao.Atualizar(estoque, saidaItem.IdItem); } MessageBox.Show("Registro gravado com sucesso!"); this.Close(); } }