Ejemplo n.º 1
0
        private void SetHealth(float newHealth)
        {
            if (CheckIfNumberIsPercent(newHealth))
            {
                _healthLevel = newHealth;
                HealthChanged?.Invoke(this, new ValueChangedEventArgs(newHealth));
            }

            if (Health == GameConstants.HelthDeathLimit)
            {
                PetDied?.Invoke(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        private void SetAge(float newAge)
        {
            if (newAge > _age)
            {
                var previousAge = _age;
                _age = newAge;
                AgeChanged?.Invoke(this, new AgeChangedEventArgs(previousAge, newAge));
            }

            if (Age == _lifeDuration)
            {
                PetDied?.Invoke(this, EventArgs.Empty);
            }
        }