Esempio n. 1
0
        private IEnumerator ProcessBattle()
        {
            isBattling = true;
            var waitTime = new WaitForSeconds(0.75f);

            yield return(waitTime);

            while (currentAICard != null && currentPlayerCard != null)
            {
                if (isPlayerAttacking)
                {
                    yield return(StartCoroutine(cardAnim.PlayerCardAttack(currentPlayerCard)));

                    currentAICard.ReduceHp(currentPlayerCard.Atk);
                    if (currentAICard.IsDeath)
                    {
                        currentAICard.Hide();
                        aiCards.Remove(currentAICard);
                        currentAICard = null;
                        playerPoint++;
                        view.UpdatePlayerPoint(playerPoint);
                        if (aiCards.Count > 0)
                        {
                            isAIDrawing = true;
                        }
                        else
                        {
                            showResult = true;
                        }
                    }
                    else
                    {
                        isPlayerAttacking = false;
                    }
                }
                else
                {
                    yield return(StartCoroutine(cardAnim.AICardAttack(currentAICard)));

                    currentPlayerCard.ReduceHp(currentAICard.Atk);
                    if (currentPlayerCard.IsDeath)
                    {
                        currentPlayerCard.Hide();
                        playerCards.Remove(currentPlayerCard);
                        currentPlayerCard = null;
                        aiPoint++;
                        view.UpdateAIPoint(aiPoint);
                        if (playerCards.Count > 0)
                        {
                            isPlayerDrawing = true;
                        }
                        else
                        {
                            showResult = true;
                        }
                    }
                    else
                    {
                        isPlayerAttacking = true;
                    }
                }
                yield return(waitTime);
            }
            if (showResult)
            {
                isPlaying = false;
            }
            isBattling = false;
        }