Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
 public void AddCollision(GameCollision collision)
 {
     collisionRepository.Put(collision);
     collisionEventObserver.OnNext(CollisionEvent.InstantiatedCollision(collision.Id));
 }