private void Update()
    {
        if (dead)
        {
            if (markedForCleanup)
            {
                Destroy(gameObject);
            }
            return;
        }

        if (waitingtoRegenerate)
        {
            WaitToRegen();
        }

        if (currentlyRegenerating)
        {
            currentHealth += 1;
            if (currentHealth >= enemyType.MaximumHealth)
            {
                currentHealth         = enemyType.MaximumHealth;
                currentlyRegenerating = false;
            }
            Healthbar.SetHealthbar((int)currentHealth);
        }
    }
Beispiel #2
0
    public void RequestHealthbar(int instanceID, Transform trans, BattlerData data)
    {
        if (!IsCurrentlyActive(instanceID))
        {
            Healthbar healthbar = _healthbarPoolSO.Request();
            _currentlyActiveHealthbars.Add(healthbar);

            healthbar.SetHealthbar(instanceID, trans, data);
            healthbar.OnHealthbarFinishedDisplaying += OnHealthbarFinishedPlaying;
        }
    }
Beispiel #3
0
    public void DealDamage(float damage)
    {
        health -= damage;
        if (healthBar)          //Since player doesn't have a health bar (yet) and also uses this method, checks to see if healthBar == null
        {
            healthBar.SetHealthbar(health, maxHealth);
        }

        if (health <= 0)
        {
            Destroy(gameObject);
        }
    }