예제 #1
0
    internal void UseCard(int cardInstanceId, List <int> targetMechIds = null, List <int> targetEquipIds = null, List <int> targetClientIds = null, bool onlyTriggerNotUse = false)
    {
        CardBase useCard = GetCardByCardInstanceId(cardInstanceId);

        Utils.DebugLog("AI UseCard:" + useCard.CardInfo.BaseInfo.CardNames["zh"]);

        if (onlyTriggerNotUse)
        {
            CardBase copyCard = CardBase.InstantiateCardByCardInfo(useCard.CardInfo.Clone(), useCard.BattlePlayer, BattlePlayer.GameManager.GenerateNewTempCardInstanceId());

            BattlePlayer.GameManager.EventManager.Invoke(SideEffectExecute.GetTriggerTimeByCardType(copyCard.CardInfo.BaseInfo.CardType),
                                                         new ExecutorInfo(
                                                             clientId: BattlePlayer.ClientId,
                                                             targetClientIds: targetClientIds,
                                                             targetMechIds: targetMechIds,
                                                             cardId: copyCard.CardInfo.CardID,
                                                             cardInstanceId: copyCard.M_CardInstanceId,
                                                             targetEquipIds: targetEquipIds));
            copyCard.UnRegisterSideEffect();
        }
        else
        {
            BattlePlayer.BattleStatistics.UseCard(useCard.CardInfo);
            UseCardRequest request = new UseCardRequest(BattlePlayer.ClientId, useCard.M_CardInstanceId, useCard.CardInfo.Clone());
            BattlePlayer.MyClientProxy.BattleGameManager.Broadcast_AddRequestToOperationResponse(request);
            BattlePlayer.UseMetal(useCard.CardInfo.BaseInfo.Metal);
            BattlePlayer.UseEnergy(useCard.CardInfo.BaseInfo.Energy);
            BattlePlayer.GameManager.EventManager.Invoke(SideEffectExecute.GetTriggerTimeByCardType(useCard.CardInfo.BaseInfo.CardType),
                                                         new ExecutorInfo(
                                                             clientId: BattlePlayer.ClientId,
                                                             targetClientIds: targetClientIds,
                                                             targetMechIds: targetMechIds,
                                                             cardId: useCard.CardInfo.CardID,
                                                             cardInstanceId: cardInstanceId,
                                                             targetEquipIds: targetEquipIds));
            if (!useCard.CardInfo.BaseInfo.IsTemp)
            {
                if (useCard.CardInfo.BaseInfo.CardType == CardTypes.Spell || useCard.CardInfo.BaseInfo.CardType == CardTypes.Energy)
                {
                    BattlePlayer.CardDeckManager.CardDeck.RecycleCardInstanceID(cardInstanceId);
                }
            }

            Cards.Remove(useCard);
            UsableCards.Remove(useCard.M_CardInstanceId);
            useCard.UnRegisterSideEffect();
        }
    }
예제 #2
0
    private void OnPlayerUseCard(UseCardRequest r)
    {
        ClientPlayer cp = GetPlayerByClientId(r.clientId);

        cp.BattlePlayer.HandManager.UseCard(r.handCardInstanceId, r.cardInfo);
    }