private void battle(GameObject obj) { HeroCard card = obj.GetComponent <HeroCard>(); card.subscribeToBattle(); if (card.data.type == Type.HERO) { int damage = tempCard.power - card.armor; if (damage > 0) { card.armor = 0; card.health -= damage; } else if (damage == 0) { card.armor = 0; } else { card.armor -= tempCard.power; } if (battleLog != null) { battleLog(); } if (card.health <= 0) { moveToDead(obj, card); } } StopCoroutine(cancelCoroutine); tempCard.canAttack = false; tempCard.updateState(State.SLEEPING); }
private void attackingCard(GameObject card) { tempCard = card.GetComponent <HeroCard>(); tempCard.subscribeToBattle(); cancelCoroutine = StartCoroutine(waitingToCancel()); }