private void OnEntityDisposed(IEventData eventData) { EntityDisposeEvent entityEvent = eventData as EntityDisposeEvent; if (healthBars.ContainsKey(entityEvent.Entity)) { EntityHealthController healthController = healthBars[entityEvent.Entity]; healthBars.Remove(entityEvent.Entity); Destroy(healthController.gameObject); } }
private void ProcessNewEntity(Entity entity) { Health health = entity.GetComponent <Health>(); if (health != null && health.Entity != gameManager.Player) { EntityHealthController healthBar = Instantiate(healthControllerPrefab, transform); RectTransform rectTransform = healthBar.GetComponent <RectTransform>(); rectTransform.localScale = Vector3.one; healthBar.Initialize(health); healthBars.Add(entity, healthBar); } }