Beispiel #1
0
    public void AttackCard(Card attackingCard, Card attackedCard)
    {
        BattleRow attackedCardRow = attackedCard.currentRow;

        attackedCard.OnCardAttacked(attackingCard);
        attackingCard.OnCardAttack();

        if (attackedCard.ShouldBeDestroyed())
        {
            UnitAttackType attackingUnitAttackType = attackingCard.GetUnitInstance().GetUnit().unitAttackType;
            if (attackingUnitAttackType == UnitAttackType.Melee)
            {
                if (attackedCardRow.GetCardsFromCountryOtherThatArgument(attackingCard.Country).Count <= 0)
                {
                    MoveCardToRow(attackingCard, attackedCardRow.RowIndex);
                }
            }

            attackedCard.currentRow.RemoveCardFromRow(attackedCard);

            //Remove card from proper controller (AI or Player)
            if (attackedCard.Country.isPlayerCountry)
            {
                RemovePlayerCard(attackedCard);
            }
            else
            {
                BattleAI.instance.RemoveCard(attackedCard);
            }

            Destroy(attackedCard.gameObject);
        }
    }
Beispiel #2
0
    void HighlightRowOnProperColor(int i, Card card, int maxMoveDistance, ref bool foundEnemyCard)
    {
        BattleRow targetRow = GetBattleRowByIndex(i);

        if (i != card.currentRow.RowIndex)
        {
            if (targetRow.GetCardsFromCountryOtherThatArgument(card.Country).Count > 0)
            {
                foundEnemyCard = true;
                rows[i].SetHighlightActive(true, BattleRow.HighlightType.Attack);
            }
            else if (!foundEnemyCard && Mathf.Abs(i - card.currentRow.RowIndex) <= maxMoveDistance)
            {
                rows[i].SetHighlightActive(true, BattleRow.HighlightType.Normal);
            }
        }
    }
Beispiel #3
0
    IEnumerator MakeTurnWait()
    {
        List <Card> cards = myCards.GetCards();

        for (int i = 0; i < cards.Count; i++)
        {
            Card      currCard = cards[i];
            BattleRow nextRow  = GetRowWithOffsetFromCard(currCard, 1);
            if (nextRow)
            {
                //Move(currCard);
                int maxRowsAvailableToMove = 0;
                for (int j = 0; j <= currCard.GetUnitInstance().currentStamina; j++)
                {
                    StartCoroutine(AttackIfCan(currCard));
                    yield return(new WaitUntil(() => attackFinished));

                    attackFinished = false;

                    if (nextRow)
                    {
                        if (nextRow.GetCardsFromCountryOtherThatArgument(currCard.Country).Count <= 0)
                        {
                            maxRowsAvailableToMove++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    BattleRow destinationRow = GetRowWithOffsetFromCard(currCard, 1);
                    BattleController.instance.MoveCardToOtherRow(currCard, destinationRow.RowIndex);

                    yield return(new WaitUntil(() => BattleController.instance.IsCardActionFinished()));
                }
            }

            yield return(new WaitUntil(() => BattleController.instance.IsCardActionFinished()));
        }
    }
Beispiel #4
0
    IEnumerator AttackIfCan(Card controlledCard)
    {
        int       rowOffset = 1;
        BattleRow nextRow   = GetRowWithOffsetFromCard(controlledCard, rowOffset);

        while (nextRow && controlledCard.GetUnitInstance().currentStamina >= 1 && controlledCard.GetUnitInstance().GetUnit().attackRange >= rowOffset)
        {
            List <Card> cardsToAttack = nextRow.GetCardsFromCountryOtherThatArgument(controlledCard.Country);
            Card        cardToAttack  = null;
            if (cardsToAttack.Count > 0)
            {
                cardToAttack = cardsToAttack[0];
                BattleController.instance.AttackCard(controlledCard, cardToAttack);
                yield return(new WaitUntil(() => BattleController.instance.IsCardActionFinished()));
            }
            else
            {
                rowOffset++;
                nextRow = GetRowWithOffsetFromCard(controlledCard, rowOffset);
            }
        }

        attackFinished = true;
    }