public void Start() { // Checking if all referencies are working if (movement == null) { movement = gameObject.GetComponent <MovementBehavior>(); } if (movement == null) { movement = gameObject.AddComponent <MovementBehavior>(); } if (movement.enemyBehavior == null) { movement.enemyBehavior = this; } // Getting a personnal healthbar healthBar = GameManager.instance.healthBarManager.GetBar(); healthBar.Show(); // Parsing values to the enemy visual = Instantiate(param.model, transform.position, Quaternion.identity, transform); // Checking if the enemy visual has a visualBehavior enemyVisualBehavior = visual.GetComponent <EnemyVisualBehavior>(); if (enemyVisualBehavior != null) { enemyVisualBehavior.enemyBehavior = this; } health = param.health; movement.speed = param.speed; }
// Start is called before the first frame update void Start() { //Create our healt panel on the canvas Raferences.canvas currentHealth = maxHealth; GameObject healthBarObject = Instantiate(healthBarPrefab, References.canvas.transform); myHealthBar = healthBarObject.GetComponent <HealthBarBehavior>(); }
public HealthBarBehavior GetBar() { foreach (HealthBarBehavior bar in activeHealthBars) { if (!bar.taken) { return(bar); } } HealthBarBehavior newBar = Instantiate(healthBarPrefab, Vector3.zero, Quaternion.identity).GetComponent <HealthBarBehavior>(); newBar.transform.SetParent(holder); activeHealthBars.Add(newBar); return(newBar); }