Example #1
0
    //차례가 끝날때마다 호출되는 함수
    private void StartGame()
    {
        Debug.Log("Start Game");
        GameEvent.Trigger(GameEventType.GameStart);

        if (CardClick.canClick == false)
        {
            Card playerCard = cardField.playerHandler[index];
            Card enemyCard  = cardField.enemyHandler[index];


            int playerPriority = GetPriority(playerCard);
            int enemyPriority  = GetPriority(enemyCard);

            if (playerCard is GuardCard && enemyCard is AttackCard)
            {
                IsPlayerFirst = true; //player선
            }
            else if (enemyCard is GuardCard && playerCard is AttackCard)
            {
                IsPlayerFirst = false; //enemy선
            }
            else if (playerPriority < enemyPriority)
            {
                IsPlayerFirst = true;
            }
            else if (playerPriority >= enemyPriority)
            {
                IsPlayerFirst = false;
            }

            if (turn >= 1 && turn <= 3)
            {
                StartCoroutine(PlayerAction());
            }

            else
            {
                CardClick.canClick = true;
            }
        }
        else
        {
            if (CheckGame())
            {
                return;
            }
            coolDown.Restart(); //쿨타임 재시작
            turn           = 1;
            round         += 1;
            index          = 0;
            roundText.text = "Round : " + round.ToString();
            if (round > 1)
            {
                clickedCardCount += 1;           //추가로 하나 더
            }
            for (int i = 0; i < cardField.cardPos.Length; i++)
            {
                var cc = cardField.cardPos[i].GetComponent <CardComponent>();
                if (cc.GetIsUsed() == true)
                {
                    cc.OnCard();
                }
            }

            //if (cardField.cardList.Count < cardField.cardPos.Length)
            //{
            //    Card card2 = CardManager.Instance.GetRandomCard();
            //    if (CardManager.Instance.MaxCountCheck(card2, cardField.cardList))
            //    {
            //        cardField.AddCard(card2);
            //    }
            //}

            clickedCardCount = 0;

            StartCoroutine(CardSelectTime());
        }
    }