void Handle(LifeUIEvent e) { constraint.ForEachGameObject((egoComponent, healthUI, spriteRenderer) => { if (e.playerID == healthUI.playerID) { if (healthUI.lifes > e.lifes) { egoComponent.gameObject.SetActive(false); } } }); }
void Handle(DamageEvent e) { constraint.ForEachGameObject((egoComponent, healthComponent, player) => { if (e.playerID == player.playerID) { if (healthComponent.health <= -2) { var eve = new GameOverEvent(player.playerID); EgoEvents <GameOverEvent> .AddEvent(eve); } else { //healthComponent.lifeIcons.SetValue(null, healthComponent.health - 1); if (e.damage == true) { healthComponent.health--; } var ev = new LifeUIEvent(e.playerID, healthComponent.health); EgoEvents <LifeUIEvent> .AddEvent(ev); } } }); }