Esempio n. 1
0
    void IFlipEffect.OnFlip(bool flippedFaceUp, Action callback)
    {
        if (flippedFaceUp)
        {
            List <byte> cardsInGraveyard = new List <byte>();
            cardsInGraveyard.AddRange(Networking.TheDiscardPile.Contents);
            cardsInGraveyard.Remove((byte)Card.Index);

            Card.StartCoroutine(Networking.PickACardCOR(Card.LastOwner.PlayerIndex,
                                                        cardsInGraveyard.ToArray(),
                                                        (choice) =>
            {
                if (cardsInGraveyard.Contains(choice))
                {
                    Networking.TheDiscardPile.RemoveIndex(choice);

                    Card foundCard  = Networking.TheCardIndex.GetCard(choice);
                    foundCard.Owner = Card.LastOwner;

                    foundCard.IsAlive  = true;
                    foundCard.IsFaceUp = true;

                    Networking.AddCardToBoards(Card.LastOwner.PlayerIndex, choice);
                }
                callback();
            },

                                                        () =>
            {
                callback();
            },
                                                        Color.green,
                                                        true));
        }
    }
Esempio n. 2
0
    IEnumerator triggerCOR(System.Action callback)
    {
        //Look at the to 2 cards
        List <byte> targets = Networking.TheDeck.TopCards(2);

        bool choiceMade = false;
        Card toGiveAway = null;
        Card toKeep     = null;

        System.Action cancel = () =>
        {
            choiceMade = true;
            //Otherwise, discard the top 2 cards
            foreach (byte b in targets)
            {
                Networking.TheDeck.PullCard(b);
                Networking.SendToDiscard(Networking.TheCardIndex.GetCard(b));
            }
        };

        foreach (byte b in targets)
        {
            Card c = Networking.TheCardIndex.GetCard(b);
            if (c.HasKeyword(Keyword.CANT_BE_DISCARDED))
            {
                cancel = null;
            }
        }



        Card.StartCoroutine(Networking.PickACardCOR(
                                Card.Owner.PlayerIndex,
                                targets.ToArray(),
                                (choice) =>
        {
            //You may choose 1 and give it to another player face-up

            Networking.TheDeck.PullCard(choice);
            toGiveAway = Networking.TheCardIndex.GetCard(choice);
            targets.Remove(choice);

            byte other = targets[0];

            Networking.TheDeck.PullCard(other);
            toKeep = Networking.TheCardIndex.GetCard(other);

            choiceMade = true;
        },
                                cancel,
                                Color.black,
                                true));

        while (!choiceMade)
        {
            yield return(null);
        }


        if (toGiveAway != null)
        {
            List <byte> playerTargets = new List <byte>();
            foreach (MasqueradePlayer m in Networking.MasqueradePlayers)
            {
                playerTargets.Add(m.Identity.Index);
            }
            playerTargets.Remove(Card.Owner.Identity.Index);
            bool playerChoiceMade = false;
            byte chosenPlayer     = 205;

            Card.StartCoroutine(Networking.PickAPlayerCOR(
                                    Card.Owner.PlayerIndex,
                                    playerTargets.ToArray(),
                                    (choice) =>
            {
                chosenPlayer     = choice;
                playerChoiceMade = true;
            },
                                    null,
                                    Color.black,
                                    true));

            while (!playerChoiceMade)
            {
                yield return(null);
            }


            toGiveAway.IsAlive  = true;
            toGiveAway.IsFaceUp = true;
            toGiveAway.Owner    = Networking.MasqueradePlayers[chosenPlayer];
            Networking.AddCardToBoards(chosenPlayer, (byte)toGiveAway.Index);

            toKeep.IsAlive = true;
            toKeep.Owner   = Card.Owner;
            bool facingPicked = false;
            Card.StartCoroutine(Networking.ChooseFacingCOR(
                                    (byte)toKeep.Index,
                                    Card.Owner.PlayerIndex,
                                    (choice) =>
            {
                facingPicked = true;
            }));

            while (!facingPicked)
            {
                yield return(null);
            }
        }



        callback();
    }