Beispiel #1
0
    public void UseCard(Card_Base card, HexCell cell)
    {
        if (card.CanUseCard(this, cell))
        {
            card.CardEffect(this, cell);
            AddToUsedCards(card);
            ActionPoint -= card.ActionPointCost();

            // 向服务器汇报使用卡的ID
            CardIDSystem.instance.GetCardID(card.CardName);
        }
    }
    private IEnumerator PlayCardProcess()
    {
        yield return(new WaitForSeconds(0.5f));

        EvaluateGridValue();
        bool haveCardToUse = true;

        while (haveCardToUse)
        {
            yield return(new WaitForSeconds(0.02f));

            haveCardToUse = false;
            for (int i = 0; i < cardManager.Cards.Count; i++)
            {
                Card_Base card = cardManager.Cards[i];
                HexCell   cell = null;

                List <HexCell> canUseCells = card.GetCanUseCells(cardManager);
                if (canUseCells.Count > 0)
                {
                    cell = GetMVC(canUseCells);
                }

                if (card.CanUseCard(cardManager, cell))
                {
                    print("AI use card:" + card);
                    haveCardToUse = true;
                    cardManager.UseCard(cardManager.Cards[i], cell);
                    break;
                }
            }

            if (!haveCardToUse)
            {
                cardManager.UpdateCanMoveCells();
                if (cardManager.CanMoveCells.Count > 0)
                {
                    cardManager.SetUnitMoveTo(GetMVC(cardManager.CanMoveCells));
                }
            }
        }
    }