コード例 #1
0
 //TakeDamage method which takes in an interger which is the amount of damage the enemy deals
 public void TakeDamage(int attackDamage)
 {
     damageCooldown++;
     if (damageCooldown >= 1 && currentHealth >= 1)
     {
         //Debug.Log("TakeDamage Called");
         //flashing and number indication
         damagePopUp.PopUp(attackDamage, damagePopUpPosition);
         segmentBarmanager.UpdateHealth(0 - attackDamage);
         currentHealth -= attackDamage;
         damageCooldown = 0;
     }
 }
コード例 #2
0
    void TakeDamage(Collider col)
    {
        if (health <= 0)
        {
            //Game over
        }


        damageCooldown++;
        if (damageCooldown > 100 && health >= 1)
        {
            //flashing and number indication
            StartCoroutine(DamageAnim(col));
            damagePopUp.PopUp(enemyDamage, damagePopUpPosition);
            segmentBarmanager.UpdateHealth(0 - enemyDamage);
            health        -= enemyDamage;
            damageCooldown = 0;
        }
    }