public EnemyDescription(EnemySettings settings) { armorHolder = new ArmorHolder(); healthHolder = new HealthHolder(); moveSpeedHolder = new MoveSpeedHolder(); Armor = settings.Armor; MaxHealth = settings.Health; CurrentHealth = settings.Health; MoveSpeed = settings.MoveSpeed; }
/// <summary> /// Updates the display for player health in User Interface. /// </summary> /// <param name="amount">The amount of health that the player has remaining.</param> /// <param name= "max">The max amount of health that the player could have.</param> public void UpdateHealth(float amount, float max) { //Initializes values var percent = amount / max; var barColor = HealthFillColor; var newColor = (barColor * percent) + (Color.red * (1 - percent)); //Shows the images if the player has lost health and puts them away if they are maxed out HealthHolder.SetActive(amount < max); //Displays the amount of health to the player through image and text HealthFillRight.fillAmount = percent; HealthFillLeft.fillAmount = percent; HealthText.text = amount.ToString("00") + " / " + max.ToString("00"); //Changes the color from base color to red HealthFillLeft.color = newColor; HealthFillRight.color = newColor; }