Esempio n. 1
0
    void EnemyTurn(List <CardInfoScr> cards)
    {
        int count = cards.Count == 1 ? 1 :
                    Random.Range(0, cards.Count);

        for (int i = 0; i < count; i++)
        {
            if (EnemyFieldCards.Count > 5)
            {
                return;
            }

            cards[0].ShowCardInfo(cards[0].SelfCard, false);
            cards[0].transform.SetParent(EnemyField);

            EnemyFieldCards.Add(cards[0]);
            EnemyHandCards.Remove(cards[0]);
        }

        foreach (var activeCard in EnemyFieldCards.FindAll(x => x.SelfCard.CanAttack))
        {
            if (PlayerFieldCards.Count == 0)
            {
                return;
            }

            var enemy = PlayerFieldCards[Random.Range(0, PlayerFieldCards.Count)];

            Debug.Log(activeCard.SelfCard.Name + " (" + activeCard.SelfCard.Attack + ";" + activeCard.SelfCard.Defense + ") " + "---> " +
                      enemy.SelfCard.Name + " (" + enemy.SelfCard.Attack + ";" + enemy.SelfCard.Defense + ")");

            activeCard.SelfCard.ChangeAttackState(false);
            CardsFight(enemy, activeCard);
        }
    }
    void EnemyTurn(List <CardInfoScript> cards)
    {
        int count = Random.Range(0, cards.Count + 1);

        for (int i = 0; i < count; i++) //выставление карт соперником для проверки
        {
            if (EnemyFieldCards.Count > 5 /*баг с выкладыванием бльшего кол-ва карт*/ || EnemyEnergy == 0)
            {
                break;
            }

            List <CardInfoScript> cardsList = cards.FindAll(x => EnemyEnergy >= x.SelfCard.Cost); //карты с подходящей ценой в руке

            if (cardsList.Count == 0)
            {
                break;
            }

            ReduceEnergy(false, cardsList[0].SelfCard.Cost);

            cardsList[0].ShowCardInfo(cardsList[0].SelfCard, false);
            cardsList[0].transform.SetParent(EnemyField);

            EnemyFieldCards.Add(cardsList[0]);
            EnemyHandCards.Remove(cardsList[0]);
        }

        foreach (var activeCard in EnemyFieldCards.FindAll(x => x.SelfCard.CanAttack)) // атака соперником для проверки
        {
            if (Random.Range(0, 2) == 0 && PlayerFieldCards.Count > 0)
            {
                var enemy = PlayerFieldCards[Random.Range(0, PlayerFieldCards.Count)];

                Debug.Log(activeCard.SelfCard.Name);

                activeCard.SelfCard.ChangeAttackState(false);
                CardsFight(enemy, activeCard);
            }
            else
            {
                activeCard.SelfCard.ChangeAttackState(false);
                DamageHero(activeCard, false);
            }
        }
    }
Esempio n. 3
0
    private void EnemyTurn(List <CardInfoScr> cards)
    {
        int count = Random.Range(0, cards.Count - 1);

        for (int i = 0; i < count; i++)
        {
            if (EnemyFieldCards.Count > 5)
            {
                return;
            }
            else
            {
                CardInfoScr currentCard = cards[0];
                currentCard.ShowCardInfo(cards[0].SelfCard, false);
                currentCard.transform.SetParent(enemyField);
                EnemyHandCards.Remove(currentCard);
                EnemyFieldCards.Add(currentCard);
            }
        }
    }
Esempio n. 4
0
    public void EnemyPutCard(List <CardGiven> cards)
    {
        int field  = Random.Range(0, 2);
        int counts = Random.Range(1, EnemyHandCards.Count);             // 2 card

        for (int i = 0; i < counts; i++)
        {
            if (field == 1)
            {
                if ((int.Parse(EnemyGold.text) - cards[0].Cost) > 0)
                {
                    EnemyGold.text = (int.Parse(EnemyGold.text) - cards[0].Cost).ToString();
                    cards[0].ShowCardInfo(cards[0].SelfCard);
                    cards[0].transform.SetParent(EnemyFirstField);
                }
                else
                {
                    return;
                }
            }
            else
            {
                //Debug.Log((int.Parse(EnemyGold.text) - cards[0].Cost).ToString());
                Debug.Log(cards[0].Cost);
                if ((int.Parse(EnemyGold.text) - cards[0].Cost) > 0)
                {
                    EnemyGold.text = (int.Parse(EnemyGold.text) - cards[0].Cost).ToString();
                    cards[0].ShowCardInfo(cards[0].SelfCard);
                    cards[0].transform.SetParent(EnemySecondField);
                }
                else
                {
                    return;
                }
            }

            EnemyFieldCards.Add(cards[0]);
            EnemyHandCards.Remove(cards[0]);
            attackOrPut = 1;
        }
    }
    IEnumerator EnemyTurn(List <CardInfoScr> cards)
    {
        yield return(new WaitForSeconds(1));

        int count = cards.Count == 1 ? 1 :
                    Random.Range(0, cards.Count);

        for (int i = 0; i < count; i++)
        {
            if (EnemyFieldCards.Count > 3 || EnemyHandCards.Count == 0)
            {
                break; //Огранчение до 4 карт на поле
            }
            cards[0].GetComponent <CardMovementScr>().MoveToField(EnemyField);

            yield return(new WaitForSeconds(.31f));

            cards[0].ShowCardInfo(cards[0].SelfCard, false);
            cards[0].transform.SetParent(EnemyField);

            EnemyFieldCards.Add(cards[0]);
            EnemyHandCards.Remove(cards[0]);
        }

        yield return(new WaitForSeconds(1));

        foreach (var activeCard in EnemyFieldCards.FindAll(x => x.SelfCard.CanAttack))
        {
            if (Random.Range(0, 2) == 0 && PlayerFieldCards.Count > 0)
            {
                if (PlayerFieldCards.Count == 0)
                {
                    break;
                }

                var enemy = PlayerFieldCards[Random.Range(0, PlayerFieldCards.Count)];

                activeCard.SelfCard.ChangeAttackState(false);

                activeCard.GetComponent <CardMovementScr>().MoveToTarget(enemy.transform);
                yield return(new WaitForSeconds(.5f));

                CardsFight(enemy, activeCard);
            }
            else
            {
                activeCard.SelfCard.ChangeAttackState(false);

                activeCard.GetComponent <CardMovementScr>().MoveToTarget(PlayerHero.transform);
                yield return(new WaitForSeconds(.5f));

                DamageHero(activeCard, false);
            }

            yield return(new WaitForSeconds(.2f)); // 0.2 секунды перед новой анимацией
        }

        yield return(new WaitForSeconds(1));

        ChangeTurn();
    }
Esempio n. 6
0
    IEnumerator EnemyTurn(List <CardInfoScr> cards)
    {
        yield return(new WaitForSeconds(1));


        int count = cards.Count == 1 ? 1 :
                    Random.Range(0, cards.Count);

        for (int i = 0; i < count; i++)
        {
            if (EnemyFieldCards.Count > 5 ||
                EnemyMana == 0 || EnemyHandCards.Count == 0)
            {
                break;
            }

            List <CardInfoScr> cardsList = cards.FindAll(x => EnemyMana >= x.SelfCard.Manacost);

            if (cardsList.Count == 0)
            {
                break;
            }


            cardsList[0].GetComponent <CardMovementScr>().MoveToField(EnemyField);

            ReduceMana(false, cardsList[0].SelfCard.Manacost);

            yield return(new WaitForSeconds(.51f));


            cardsList[0].ShowCardInfo(cardsList[0].SelfCard, false);
            cardsList[0].transform.SetParent(EnemyField);

            EnemyFieldCards.Add(cardsList[0]);
            EnemyHandCards.Remove(cardsList[0]);
        }

        yield return(new WaitForSeconds(1));

        // enemy's possibility attack hero card's
        foreach (var activeCard in EnemyFieldCards.FindAll(x => x.SelfCard.CanAttack))
        {
            if (Random.Range(0, 2) == 0 &&
                PlayerFieldCards.Count > 0)
            {
                var enemy = PlayerFieldCards[Random.Range(0, PlayerFieldCards.Count)];

                Debug.Log(activeCard.SelfCard.Name + " (" + activeCard.SelfCard.Attack + ";" + activeCard.SelfCard.Defense + " )" + "--->" +
                          enemy.SelfCard.Name + " (" + enemy.SelfCard.Attack + ";" + enemy.SelfCard.Defense + " )");

                activeCard.SelfCard.ChageAttackState(false);

                activeCard.GetComponent <CardMovementScr>().MoveToTarget(enemy.transform);
                yield return(new WaitForSeconds(.75f));

                CardsFight(enemy, activeCard);
            }
            else
            {
                Debug.Log(activeCard.SelfCard.Name + " (" + activeCard.SelfCard.Attack + ") Attacked hero");

                activeCard.SelfCard.ChageAttackState(false);


                activeCard.GetComponent <CardMovementScr>().MoveToTarget(PlayerHero.transform);
                yield return(new WaitForSeconds(.75f));

                DamageHero(activeCard, false);
            }

            yield return(new WaitForSeconds(.2f));
        }

        yield return(new WaitForSeconds(1));

        ChangeTurn();
    }
Esempio n. 7
0
    void EnemyTurn(List <CardInfoScr> cards)
    {
        List <CardInfoScr> cardlist = cards.FindAll(x => x.SelfCard.Preparation == 0);
        //Debug.Log("count=" + cardlist.Count);



        int n = 1;

        for (int i = 0; i < cardlist.Count; i++)
        {
            if (EnemyFieldCards.Count > 7)
            {
                return;
            }
            n = 1;
            while (n == 1)
            {
                int j = Random.Range(1, 9);
                if (j == 1 && EnemyFieldCard1.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField1);


                    EnemyFieldCard1.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 2 && EnemyFieldCard2.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField2);

                    EnemyFieldCard2.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 3 && EnemyFieldCard3.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField3);

                    EnemyFieldCard3.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 4 && EnemyFieldCard4.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField4);

                    EnemyFieldCard4.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 5 && EnemyFieldCard5.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField5);

                    EnemyFieldCard5.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 6 && EnemyFieldCard6.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField6);

                    EnemyFieldCard6.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 7 && EnemyFieldCard7.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField7);

                    EnemyFieldCard7.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);


                    n = 0;
                }
                if (j == 8 && EnemyFieldCard8.Count == 0)
                {
                    cardlist[i].ShowCardInfo(cardlist[i].SelfCard);
                    cardlist[i].transform.SetParent(EnemyField8);

                    EnemyFieldCard8.Add(cardlist[i]);
                    EnemyFieldCards.Add(cardlist[i]);
                    EnemyHandCards.Remove(cardlist[i]);



                    n = 0;
                }
            }
        }
    }