public void Execute(PlayerView playerView, int damage) { var health = playerRepository.GetHealth(); var newhealth = Mathf.Max(health - damage, 0); playerRepository.SetHealth(newhealth); if (newhealth.Equals(0)) { var lives = playerRepository.GetLives() - 1; playerRepository.SetLives(lives); playerRepository.SetHealth(configuration.Player.Health); playerView.Explote(); gamePlayEventObserver.OnNext(lives.Equals(0) ? GamePlayEvent.GameOver() : GamePlayEvent.LostLife()); } else { playerView.Hit().Subscribe(_ => collisionRepository.Put(playerView)); } }
public void AddCollision(GameCollision collision) { collisionRepository.Put(collision); collisionEventObserver.OnNext(CollisionEvent.InstantiatedCollision(collision.Id)); }