Example #1
0
    public void CardsFight(CardController attacker, CardController defender)
    {
        attacker.Info.CanAttack = false;
        defender.Card.GetDamage(attacker.Card.Attack);
        attacker.OnDamageDeal();
        defender.OnTakeDamage(attacker);

        if (!attacker.Card.Ranged)
        {
            attacker.Card.GetDamage(defender.Card.Attack);
            attacker.OnTakeDamage();
        }

        attacker.CheckIfAlive();
        defender.CheckIfAlive();


        if (!attacker.Card.IsAlive && !IsPlayerTurn)
        {
            CurrentGame.Enemy.Gold++;
        }

        if (!defender.Card.IsAlive && IsPlayerTurn)
        {
            CurrentGame.Player.Gold++;
        }
        CheckIfCardsPlayable();
    }
Example #2
0
    public void UseSpell(CardController target)
    {
        var spellCard = (SpellCard)Card;

        switch (spellCard.Spell)
        {
        case SpellCard.SpellType.ADD_GOLD:
            if (IsPlayerCard)
            {
                GameManagerScr.Instance.CurrentGame.Player.Gold += spellCard.SpellValue;
            }
            else
            {
                GameManagerScr.Instance.CurrentGame.Enemy.Gold += spellCard.SpellValue;
            }
            UIController.Instance.UpdateResources();
            break;

        case SpellCard.SpellType.ADD_MANA:
            if (IsPlayerCard)
            {
                GameManagerScr.Instance.CurrentGame.Player.Mana += spellCard.SpellValue;
            }
            else
            {
                GameManagerScr.Instance.CurrentGame.Enemy.Mana += spellCard.SpellValue;
            }
            UIController.Instance.UpdateResources();
            break;

        case SpellCard.SpellType.BUFF_CARD_DAMAGE:
            target.Card.Attack += spellCard.SpellValue;
            break;

        case SpellCard.SpellType.DAMAGE_ENEMY_FIELD_CARDS:
            var enemyCards = IsPlayerCard ?
                             new List <CardController>(GameManager.EnemyFieldCards) :
                             new List <CardController>(GameManager.PlayerFieldCards);

            foreach (var card in enemyCards)
            {
                GiveDamageTo(card, spellCard.SpellValue);
            }
            break;

        case SpellCard.SpellType.DAMAGE_ENEMY_HERO:
            if (IsPlayerCard)
            {
                GameManagerScr.Instance.CurrentGame.Enemy.HP -= spellCard.SpellValue;
            }
            else
            {
                GameManagerScr.Instance.CurrentGame.Player.HP -= spellCard.SpellValue;
            }
            UIController.Instance.UpdateResources();
            GameManager.CheckResult();
            break;

        case SpellCard.SpellType.DEBUFF_CARD_DAMAGE:
            target.Card.Attack = Mathf.Clamp(target.Card.Attack - spellCard.SpellValue, 0, int.MaxValue);
            break;

        case SpellCard.SpellType.HEAL_ALLY_FIELD_CARDS:
            Debug.Log("Healing Inside");
            var allyCards = IsPlayerCard ? GameManager.PlayerFieldCards : GameManager.EnemyFieldCards;

            foreach (var card in allyCards)
            {
                card.Card.Defense = Mathf.Min(card.Card.Defense + spellCard.SpellValue, card.Card.MaxDefense);
                card.Info.Refresh();
            }

            break;

        case SpellCard.SpellType.HEAL_ALLY_HERO:
            if (IsPlayerCard)
            {
                GameManagerScr.Instance.CurrentGame.Player.HP += spellCard.SpellValue;
            }
            else
            {
                GameManagerScr.Instance.CurrentGame.Enemy.HP += spellCard.SpellValue;
            }
            UIController.Instance.UpdateResources();
            break;

        case SpellCard.SpellType.PROVOCATION_ON_ALLY_CARD:
            if (!target.Card.Abilities.Exists(x => x == Card.abilityType.PROVOCATION))
            {
                target.Card.Abilities.Add(Card.abilityType.PROVOCATION);
            }
            break;

        case SpellCard.SpellType.SHIELD_ON_ALLY_CARD:
            if (!target.Card.Abilities.Exists(x => x == Card.abilityType.HOLY_SHIELD))
            {
                target.Card.Abilities.Add(Card.abilityType.HOLY_SHIELD);
            }
            break;

        case SpellCard.SpellType.DAMAGE_CARD:
            GiveDamageTo(target, spellCard.SpellValue);
            break;

        case SpellCard.SpellType.HEAL_CARD:
            target.Card.Defense = Mathf.Min(target.Card.Defense + spellCard.SpellValue, target.Card.MaxDefense);
            target.Info.Refresh();
            break;

        default:
            break;
        }

        if (target != null)
        {
            target.Ability.OnCast();
            target.CheckIfAlive();
        }
        Debug.Log("Destroying Card");
        DestroyCard();
    }
Example #3
0
 public void GiveDamageTo(CardController card, int damage)
 {
     card.Card.GetDamage(damage);
     card.OnTakeDamage();
     card.CheckIfAlive();
 }