public void TesteGeraMunicao() { GeradorMunicao gerador = new GeradorMunicao(); Municao municao = gerador.Gerar(rnd); Assert.IsNotNull(municao); }
public async Task <IActionResult> Put(int municaoId, Municao model) { try { var municao = await _repo.GetMunicaoAsyncById(municaoId); if (municao == null) { return(NotFound()); } _repo.Update(model); if (await _repo.SaveChangesAsync()) { return(Created($"/portal/municao/{model.Id}", model)); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou")); } return(BadRequest()); }
public void SpawnMunicao(int QuantidadeMunicao, int DistanciaLinhaSpawn, Vector2 Munipos) { Vector2 Position = Munipos; Position.y = DistanciaLinhaSpawn; for (int i = 0; i < QuantidadeMunicao; i++) { if (Listmunicao.Count > 0) { if (Listmunicao.OfType <Municao>().Any()) { int lugar = Listmunicao.FindLastIndex(x => x.GetType() == typeof(Municao)); GameObject muni = Listmunicao[lugar]; Listmunicao.RemoveAt(lugar); muni.transform.position = Position; muni.SetActive(true); } } else { Municao GameObject = Instantiate(municaoPrefab, Position, Quaternion.identity).GetComponent <Municao>(); } } }
private void OnTriggerEnter2D(Collider2D collision) { Municao municao = collision.GetComponentInParent <Municao>(); if (municao != null) { tomarDano(municao.Dano); } }
void GenerateAmmo() { Vector3 posicao = RandomPos(); Collider[] colliders = Physics.OverlapSphere(posicao, 2, layerAmmo); while (colliders.Length > 0) { posicao = RandomPos(); colliders = Physics.OverlapSphere(posicao, 2, layerAmmo); } Municao municao = Instantiate(ammo, posicao, transform.rotation).GetComponent <Municao>(); municao.ammoBoxScript = this; qtdAtualAmmo++; }
public async Task <IActionResult> Post(Municao model) { try { _repo.Add(model); if (await _repo.SaveChangesAsync()) { return(Created($"/portal/municao/{model.Id}", model)); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou")); } return(BadRequest()); }