/// <summary> /// Произвести атаку /// </summary> /// <param name="attackerCard">Атакующая карта</param> /// <param name="defenderCard">Карта-защитник</param> private void CardsFight(CardController attackerCard, CardController defenderCard) { defenderCard.Card.Defense = Mathf.Clamp(defenderCard.Card.Defense.Value - attackerCard.Card.Attack.Value, 0, int.MaxValue); defenderCard.OnTakeDamage(attackerCard); attackerCard.OnDamageDeal(); attackerCard.Card.Defense = Mathf.Clamp(attackerCard.Card.Defense.Value - defenderCard.Card.Attack.Value, 0, int.MaxValue); attackerCard.OnTakeDamage(); }
/// <summary> /// Атаковать героя противника /// </summary> /// <param name="attacker">Карта, которая атакует</param> private void AttackHero(CardController attacker) { if (GameContext.Turn == PlayerType.Player) { GameContext.EnemyHeroHp = Mathf.Clamp(GameContext.EnemyHeroHp - attacker.Card.Attack.Value, 0, int.MaxValue); } else { GameContext.PlayerHeroHp = Mathf.Clamp(GameContext.PlayerHeroHp - attacker.Card.Attack.Value, 0, int.MaxValue); } Debug.Log($"{attacker.Card.Name} ({attacker.Card.Attack};{attacker.Card.Defense}) attacked hero"); attacker.OnDamageDeal(); RefreshHeroHpDisplay(); }