public void GotHit(int damageValue) { BaseAttribute health = entityData.GetAttributesController.GetAttribute <HealthAttr>(); //health exists???, if so, then remove health from our character if (health == null) { return; } var levels = new List <BaseAttribute.LevelsAttribute>(15); for (var i = 0; i < health.UpdateLevels.Count; ++i) { levels.Add(new BaseAttribute.LevelsAttribute(health.UpdateLevels[i].IncreaseStep, health.UpdateLevels[i].Value)); } HealthAttr attr = new HealthAttr( -damageValue, health.MinValue, health.MaxValue, levels, GameEnums.Modifier.Addition); Modifier m = new Modifier( 1, -1, GameEnums.Modifier.Addition, attr); entityData.GetAttributesController.AddModifier(m); //as we've modified the health, let's check our current health float currentHealth = entityData.GetAttributesController.GetAttributeValue <HealthAttr>(); if (currentHealth <= 0f) { //player is dead, do something about it } else { //player is still alive, so maybe put a sound here or just do nothing... } }
public void GotHit(int damageValue) { BaseAttribute health = entityData.GetAttribute <HealthAttr>(); //health exists???, if so, then remove health from our character if (health == null) { return; } HealthAttr attr = new HealthAttr( -damageValue, health.MinValue, health.MaxValue, 0, GameEnums.Modifier.ADDITION); Modifier m = new Modifier( 1, GameEnums.Modifier.ADDITION, attr); entityData.AddModifier(m); //as we've modified the health, let's check our current health float currentHealth = entityData.GetAttributeValue <HealthAttr>(); if (currentHealth <= 0f) { //player is dead, do something about it } else { //player is still alive, so maybe put a sound here or just do nothing... } }
public HealthAttr(HealthAttr attr) : base(attr) { }