public void RestartGame()
    {
        StopAllCoroutines();

        foreach (var card in PlayerHandCards)
        {
            Destroy(card.gameObject);
        }
        foreach (var card in PlayerFieldCards)
        {
            Destroy(card.gameObject);
        }
        foreach (var card in EnemyHandCards)
        {
            Destroy(card.gameObject);
        }
        foreach (var card in EnemyFieldCards)
        {
            Destroy(card.gameObject);
        }

        PlayerHandCards.Clear();
        PlayerFieldCards.Clear();
        EnemyHandCards.Clear();
        EnemyFieldCards.Clear();

        StartGame();
    }
Example #2
0
 public void DestroyCard(CardInfoScr card)
 {
     card.GetComponent <CardMovementScr>().OnEndDrag(null);
     if (EnemyFieldCards.Exists(x => x == card))
     {
         EnemyFieldCards.Remove(card);
     }
     if (PlayerFieldCards.Exists(x => x == card))
     {
         PlayerFieldCards.Remove(card);
     }
     Destroy(card.gameObject);
 }
    void DestroyCard(CardInfoScript card)
    {
        card.GetComponent <CardMovementScript>().OnEndDrag(null); // для снятия прототипа карты с поля

        if (PlayerFieldCards.Exists(x => x == card))              //карта на поле игрока
        {
            PlayerFieldCards.Remove(card);
        }
        else /*if (EnemyFieldCards.Exists(x => x == card))*/ // поле соперника
        {
            EnemyFieldCards.Remove(card);
        }

        Destroy(card.gameObject);
    }
Example #4
0
    public void ChangeForEnemyAttack()
    {
        changeEnemyHp = AnimationAttack.formula;
        Debug.Log("TEMPP:" + IDforEnemyChange);
        for (int i = 0; i < ChosenCards.selectedCards.Count; i++)
        {
            if (ChosenCards.selectedCards[i].ID == IDforEnemyChange)
            {
                Debug.Log("ZAISHLO");

                var Temp = ChosenCards.selectedCards[i];
                Temp.HP = changeEnemyHp;
                Debug.Log(Temp.HP);
                if (changeEnemyHp > 0)
                {
                    Temp.Leader--;
                }
                if (Temp.HP <= 0)
                {
                    destroyID = IDforEnemyChange;
                    if (int.Parse(PlayerMain.text) - 50 < 0)
                    {
                        ResultText = "YOU ARE LOSER";
                        SceneManager.LoadScene("ResultScene");
                        Debug.Log("END GAME");
                    }
                    else
                    {
                        PlayerMain.text = (int.Parse(PlayerMain.text) - 50).ToString();
                    }
                    PlayerFieldCards.RemoveAt(rand2);
                }
                ChosenCards.selectedCards[i] = Temp;
                DestroyCardHP.was            = false;
            }
        }
    }
    IEnumerator EnemyTurn(List <CardController> 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 <CardController> cardsList = cards.FindAll(x => EnemyMana >= x.Card.Manacost && !x.Card.IsSpell);

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

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

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

            cardsList[0].transform.SetParent(EnemyField);

            cardsList[0].OnCast();
        }

        yield return(new WaitForSeconds(1));

        while (EnemyFieldCards.Exists(x => x.Card.CanAttack))
        {
            var  activeCard     = EnemyFieldCards.FindAll(x => x.Card.CanAttack)[0];
            bool hasProvocation = PlayerFieldCards.Exists(x => x.Card.IsProvocation);

            if (hasProvocation ||
                Random.Range(0, 2) == 0 &&
                PlayerFieldCards.Count > 0)
            {
                CardController enemy;

                if (hasProvocation)
                {
                    enemy = PlayerFieldCards.Find(x => x.Card.IsProvocation);
                }
                else
                {
                    enemy = PlayerFieldCards[Random.Range(0, PlayerFieldCards.Count)];
                }

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

                activeCard.Movement.MoveToTarget(enemy.transform);
                yield return(new WaitForSeconds(.75f));

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

                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();
    }
Example #6
0
    void DestroyCard(CardInfoScr card, int e)
    {
        if (IsPlayerTurn)
        {
            if (e == 1)
            {
                EnemyFieldCard1.Remove(card);
            }
            if (e == 2)
            {
                EnemyFieldCard2.Remove(card);
            }
            if (e == 3)
            {
                EnemyFieldCard3.Remove(card);
            }
            if (e == 4)
            {
                EnemyFieldCard4.Remove(card);
            }
            if (e == 5)
            {
                EnemyFieldCard5.Remove(card);
            }
            if (e == 6)
            {
                EnemyFieldCard6.Remove(card);
            }
            if (e == 7)
            {
                EnemyFieldCard7.Remove(card);
            }
            if (e == 8)
            {
                EnemyFieldCard8.Remove(card);
            }

            EnemyFieldCards.Remove(card);
        }
        else
        {
            if (e == 1)
            {
                PlayerFieldCard1.Remove(card);
            }
            if (e == 2)
            {
                PlayerFieldCard2.Remove(card);
            }
            if (e == 3)
            {
                PlayerFieldCard3.Remove(card);
            }
            if (e == 4)
            {
                PlayerFieldCard4.Remove(card);
            }
            if (e == 5)
            {
                PlayerFieldCard5.Remove(card);
            }
            if (e == 6)
            {
                PlayerFieldCard6.Remove(card);
            }
            if (e == 7)
            {
                PlayerFieldCard7.Remove(card);
            }
            if (e == 8)
            {
                PlayerFieldCard8.Remove(card);
            }

            PlayerFieldCards.Remove(card);
        }
        Destroy(card.gameObject);
    }