コード例 #1
0
    public IEnumerator BreakShields(GameObject attackingCard, Player shieldOwner)
    {
        CardBase cardInfo = attackingCard.GetComponent <CardBase>();

        for (int i = 0; i < cardInfo.numberOfShieldsToBreak; i++)
        {
            if (shieldOwner.Sheilds.Count > 0)
            {
                int        randomIndex = Random.Range(0, shieldOwner.Sheilds.Count);
                GameObject shield      = shieldOwner.Sheilds[randomIndex];
                shieldOwner.Hand.Add(shield);
                shieldOwner.Sheilds.Remove(shield);
                CardBase shieldInfo = shield.GetComponent <CardBase>();
                shieldInfo.currentLocation = DuelManager.CardLocations.Hand;

                duelManager.attackingCard = null;
                duelManager.activeCard    = null;
                duelManager.activeBlocker = null;
                battleInfo.SetActive(false);

                if (shieldInfo.keyWord.Contains(CardBase.KeyWordEffects.SheildTrigger))
                {
                    duelManager.activeCard = shieldInfo.gameObject;
                    if (shieldInfo.owner == duelManager.player2)
                    {
                        AITargeting targeting = new AITargeting();
                        if (targeting.FindTarget(shieldInfo))
                        {
                            StartCoroutine(Cast(shieldInfo.owner, shieldInfo.gameObject));
                        }
                        else
                        {
                            StartCoroutine(Cast(shieldInfo.owner, shieldInfo.gameObject));
                        }
                    }
                    else
                    {
                        StartCoroutine(Cast(shieldInfo.owner, shieldInfo.gameObject));
                    }

                    while (duelManager.duelState != DuelManager.DuelState.None)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                else
                {
                    duelManager.duelState = DuelManager.DuelState.None;
                }
                cardInfo.isTapped = true;
            }
        }
        yield return(null);
    }
コード例 #2
0
    public IEnumerator TriggerCast()
    {
        yield return(new WaitForSeconds(1));

        AITargeting targeting = new AITargeting();

        if (player.Hand.Count > 0)
        {
            for (int i = 0; i < player.Hand.Count; i++)
            {
                CardBase cardInfo = player.Hand[i].GetComponent <CardBase>();
                if (gameActions.CostIsMet(cardInfo.owner, cardInfo.gameObject))
                {
                    if (cardInfo.cardType == CardBase.CardType.Spell)
                    {
                        if (cardInfo.needsTarget)
                        {
                            for (int j = 0; j < cardInfo.numberOfTargets; j++)
                            {
                                if (targeting.FindTarget(cardInfo))
                                {
                                    gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                                    yield return(new WaitForSeconds(.5f));
                                }
                                yield return(new WaitForSeconds(2));
                            }
                        }
                        else
                        {
                            gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                        }
                    }
                    else
                    {
                        //summon creature
                        if (cardInfo.effectType.Contains(Effects.EffectType.OnSummon))
                        {
                            if (cardInfo.needsTarget)
                            {
                                for (int j = 0; j < cardInfo.numberOfTargets; j++)
                                {
                                    if (targeting.FindTarget(cardInfo))
                                    {
                                        gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                                    }
                                    else if (!cardInfo.keyWord.Contains(CardBase.KeyWordEffects.MustResolveEffect))
                                    {
                                        gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                                    }
                                }
                            }
                            else
                            {
                                gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                            }
                        }
                        else
                        {
                            gameActions.StartCoroutine(gameActions.Cast(player, cardInfo.gameObject));
                        }
                    }
                    yield return(new WaitForSeconds(1f));
                }
                while (duelManager.duelState != DuelManager.DuelState.None)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
        }
        duelManager.turnPhase = DuelManager.TurnPhase.Battle;
        //the AI will finish on its own
        yield return(null);
    }