void PlayerHealthUpdated(float number)
    {
        int currentHealth = (int)number;

        if (currentHealth < prevHealth)
        {
            currentInfectionProgress += prevHealth - currentHealth;
            while (currentInfectionProgress >= InfectionDamageThreshold.Value)
            {
                currentInfectionProgress -= (int)InfectionDamageThreshold.Value;
                infectionMultiplier++;
                onInfectionMultUpdate.Invoke(infectionMultiplier);
            }
            onInfectionCounterUpdate.Invoke(currentInfectionProgress);
        }
        prevHealth = currentHealth;
    }
 public void AddXP(int value)
 {
     xp += value * infectionMultiplier;
     while (xp >= xpToNextSkillPoint.Value)
     {
         xp -= (int)xpToNextSkillPoint.Value;
         upgradePoints++;
         OnLevelGain.Invoke(upgradePoints);
     }
     onXPGain.Invoke(xp);
 }
예제 #3
0
 public void TakeDamage(int damage, Enemy source)
 {
     Director.GetManager <SoundManager>().PlaySound(takeDamageSound);
     if (source)
     {
         knockback += ((Vector2)(transform.position - source.transform.position)).normalized * damage / 10;
     }
     _spriteRenderer.color = Color.red;
     currentHealth         = Mathf.Max(currentHealth - damage, 0);
     if (playerHealthUpdated)
     {
         playerHealthUpdated.Invoke(currentHealth);
     }
     if (currentHealth <= 0)
     {
         Instantiate(playerDeathParticle, transform.position, Quaternion.identity);
         Destroy(gameObject);
     }
 }