public static void CardSetHealth(Card card, int value) { if (card.HasComponent <CreatureComponent>()) { CreatureComponent creature = card.GetComponent <CreatureComponent>(); if (creature.CurrentHealth < value) { foreach (var ability in card.GetAbilities()) { ability.DoCardGetDamage(); } } if (creature.CurrentHealth > value && creature.CurrentHealth < creature.MaxHealth) { foreach (var ability in card.GetAbilities()) { ability.DoCardGetHeal(); } } creature.CurrentHealth = GameMath.Clamp(value, 0, creature.MaxHealth); } }
/// <summary> /// Восстанавливает здоровье карты не выше, чем до изначального максимума. /// </summary> /// <param name="card"></param> /// <param name="value"></param> public static void LimitedHealCreature(Card card, int value) { if (card != null && card.HasComponent <CreatureComponent>()) { CreatureComponent creature = card.GetComponent <CreatureComponent>(); CardManager.CardSetHealth(card, GameMath.Clamp(creature.CurrentHealth + value, 0, creature.BaseHealth)); } }
public static void DamageCreature(Card card, int value) { if (card != null && card.HasComponent <CreatureComponent>()) { CreatureComponent creature = card.GetComponent <CreatureComponent>(); CardManager.CardSetHealth(card, creature.CurrentHealth - value); } }
public IComponent Copy() { CreatureComponent copy = new CreatureComponent(BaseAttack, BaseHealth); copy.CurrentAttack = CurrentAttack; copy.MaxHealth = MaxHealth; copy.CurrentHealth = CurrentHealth; return(copy); }
public static void ResetCard(Card card) { card.IsTurned = false; if (card.HasComponent <CreatureComponent>()) { CreatureComponent creatureComponent = card.GetComponent <CreatureComponent>(); creatureComponent.CurrentAttack = creatureComponent.BaseAttack; creatureComponent.CurrentHealth = creatureComponent.BaseHealth; } }
/// <summary> /// Уменьшает максимальное количество здоровья карты. /// Если текущее здоровье оказывается больше максимального, /// то текущее здоровье понижается до нового значения максимального. /// </summary> /// <param name="card"></param> /// <param name="value"></param> public static void DecreaseCreatureMaxHealth(Card card, int value) { if (card != null && card.HasComponent <CreatureComponent>()) { CreatureComponent creature = card.GetComponent <CreatureComponent>(); creature.MaxHealth -= value; if (creature.CurrentHealth > creature.MaxHealth) { creature.CurrentHealth = creature.MaxHealth; } } }