private Task HealthUpdate(int health)
 {
     if (debug)
     {
         Console.WriteLine($"OBSERVER: NetworkManagerClient HealthUpdate");
     }
     HealthUpdated?.Invoke(health);
     return(Task.CompletedTask);
 }
Example #2
0
    private void OnHealthUpdated()
    {
        HealthUpdated?.Invoke();
        progressBar.BarValue = Health;

        if (Health < maxHealth)
        {
            return;
        }

        OnCarRepaired();
    }
Example #3
0
    public void Damage(int amount)
    {
        var newHp = health - amount;

        if (newHp < 0)
        {
            newHp = 0;
        }
        HealthUpdated?.Invoke(this, newHp);

        health = newHp;
        if (health <= 0)
        {
            Kill();
        }
    }
Example #4
0
 public void Start()
 {
     isAlive          = true;
     currentHealth    = maxHealth;
     OnHealthUpdated += HealthUpdate;
 }