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

        if (Health < maxHealth)
        {
            return;
        }

        OnCarRepaired();
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 4
0
 public void Start()
 {
     isAlive          = true;
     currentHealth    = maxHealth;
     OnHealthUpdated += HealthUpdate;
 }