//Set references to the health panel references. void InitializeUIHealthController() { playerHealthPanel = transform.FindChild("Player Health Controller").FindChild("HealthPanelPlayer").GetComponent <PlayerHealthPanelReference> (); enemyHealthPanel1 = transform.FindChild("Enemy Health Controller").FindChild("HealthPanel1").GetComponent <HealthPanelReference> (); enemyHealthPanel2 = transform.FindChild("Enemy Health Controller").FindChild("HealthPanel2").GetComponent <HealthPanelReference> (); enemyHealthPanel3 = transform.FindChild("Enemy Health Controller").FindChild("HealthPanel3").GetComponent <HealthPanelReference> (); }
// Called when player enters radius of the character health controller. void OnThisEnemyActivated() { healthPanelReference = uiHealthController.GetEnemyHealthPanelReference(); if (healthPanelReference != null) { healthPanelReference.InitializePanel(characterHeadSprite, lifePoints, currentHealth); } }
//Called when the object is de-activated, or on death. public void DisableHealthPanel() { if (healthPanelReference != null) { healthPanelReference.Clear(); healthPanelReference = null; } }
//Called by the HealthController when this object has a health panel available to use. public void HealthPanelNewlyAvailable(HealthPanelReference healthPanel) { healthPanelReference = healthPanel; healthPanelReference.InitializePanel(characterHeadSprite, lifePoints, currentHealth); }