private void OnCollisionEnter2D(Collision2D collision) { Status.Hp -= collision.gameObject.GetComponent <BaseAmmoController>().GetAttack(); rend.color = new Color(1.0f , (Status.Hp <= 0) ? 0 : ((float)Status.Hp / (float)Status.MaxHp) , (Status.Hp <= 0) ? 0 : ((float)Status.Hp / (float)Status.MaxHp) ); if (Status.Hp > 0) { return; } gameObject.SetActive(false); ParentGenerator.EraseEnemy(gameObject); }
public async Task CanQueryByParent() { var parent = ParentGenerator.Default; parent = await _parentRepository.AddAsync(parent); Assert.NotNull(parent?.Id); await _parentRepository.AddAsync(ParentGenerator.Generate()); var child = ChildGenerator.Default; child = await _childRepository.AddAsync(child, o => o.ImmediateConsistency()); Assert.NotNull(child?.Id); var childResults = await _childRepository.QueryAsync(q => q.ParentQuery(p => p.Id(parent.Id))); Assert.Equal(1, childResults.Total); }
public async Task GetByIds() { var parent1 = ParentGenerator.Generate(); parent1 = await _parentRepository.AddAsync(parent1, o => o.ImmediateConsistency()); Assert.NotNull(parent1?.Id); var child1 = ChildGenerator.Generate(parentId: parent1.Id); child1 = await _childRepository.AddAsync(child1, o => o.ImmediateConsistency()); Assert.NotNull(child1?.Id); var parent2 = ParentGenerator.Generate(); parent2 = await _parentRepository.AddAsync(parent2, o => o.ImmediateConsistency()); Assert.NotNull(parent2?.Id); var child2 = ChildGenerator.Generate(parentId: parent2.Id); child2 = await _childRepository.AddAsync(child2, o => o.ImmediateConsistency()); Assert.NotNull(child2?.Id); var ids = new Ids(child1.Id, child2.Id); var results = await _childRepository.GetByIdsAsync(ids); Assert.NotNull(results); Assert.Equal(2, results.Count); var idsWithRouting = new Ids(new Id(child1.Id, parent1.Id), new Id(child2.Id, parent2.Id)); var resultsWithRouting = await _childRepository.GetByIdsAsync(idsWithRouting); Assert.NotNull(resultsWithRouting); Assert.Equal(2, resultsWithRouting.Count); }
public async Task CanQueryByParent() { var parent = ParentGenerator.Default; parent = await _parentRepository.AddAsync(parent); Assert.NotNull(parent?.Id); await _parentRepository.AddAsync(ParentGenerator.Generate()); var child = ChildGenerator.Default; child = await _childRepository.AddAsync(child); Assert.NotNull(child?.Id); await _client.RefreshAsync(); var childResults = await _childRepository.QueryAsync(new MyAppQuery().WithParentQuery(q => q.WithId(parent.Id))); Assert.Equal(1, childResults.Total); }