private void Awake() { if (barType == BarType.Player) { PlayerStatsController stats = transform.parent.GetComponent <PlayerStatsController>(); _healthStat = stats.health; _manaStat = stats.mana; } else if (barType == BarType.Enemy) { EnemyStatsController stats = transform.parent.GetComponent <EnemyStatsController>(); _healthStat = stats.health; // apply enemy name as label string label = gameObject.GetComponentInParent <EntityStatsController>().gameObject.name; Text labelText = gameObject.GetComponentInChildren <Text>(); labelText.text = label; } }
private void Awake() { switch (barType) { case BarType.Player: { PlayerStatsController stats = transform.parent.GetComponent <PlayerStatsController>(); _healthStat = stats.health; _manaStat = stats.mana; break; } case BarType.Enemy: case BarType.Boss: { EnemyStatsController stats = transform.parent.GetComponent <EnemyStatsController>(); _healthStat = stats.health; // Handle boss specific setup if (barType == BarType.Boss) { // Use the boss' gameObject name for the label string label = stats.gameObject.name; Text labelText = gameObject.GetComponentInChildren <Text>(); labelText.text = label; } break; } } _canvas = GetComponent <Canvas>(); // Start the bars hidden if not set to always show them if (!alwaysShow) { Hide(); } }
public void Setup() { instance = new RegenerableStat(); instance.maxValue = 10f; instance.minValue = 0f; }