Example #1
0
    public void ReShuffleIn(Card_Placement deck, Card_Placement discard)
    {
        while (discard.m_Cards.Count > 0)
        {
            deck.GiveCard(discard.TakeFromTop());
        }
        deck.Shuffle();

        foreach (Card c in deck.m_Cards)
        {
            if (c.m_faceUp)
            {
                c.Flip();
            }
        }
        UpdatePlayerCardCounts();
    }
Example #2
0
    public void newGame()
    {
        GameEnd = false;

        WinTXT.SetActive(false);
        WinTXTp1.gameObject.SetActive(false);
        WinTXTp2.gameObject.SetActive(false);

        P1Deck.Clear();
        P2Deck.Clear();
        P1War.Clear();
        P2War.Clear();
        P1Discard.Clear();
        P2Discard.Clear();

        m_Deck.Dropbox();
        m_Deck.Shuffle(m_Deck.Cards);

        bool GiveP1 = true;

        foreach (Card c in m_Deck.Cards)
        {
            if (GiveP1)
            {
                P1Deck.GiveCard(c);
            }
            else
            {
                P2Deck.GiveCard(c);
            }

            c.gameObject.transform.localScale = new Vector3(1, 1, 1);

            c.gameObject.GetComponent <Button>().interactable = false;

            GiveP1 = !GiveP1;
        }

        P1Deck.Shuffle();
        P2Deck.Shuffle();

        m_Deck.Cards.Clear();
        UpdatePlayerCardCounts();
    }
Example #3
0
    public void NextRound()
    {
        if (GameEnd)
        {
            return;
        }

        if (m_winningDeck != null)
        {
            while (P1War.m_Cards.Count > 0)
            {
                Card card = P1War.TakeFromTop();
                m_winningDeck.GiveCard(card);
            }

            while (P2War.m_Cards.Count > 0)
            {
                Card card = P2War.TakeFromTop();
                m_winningDeck.GiveCard(card);
            }
            UpdatePlayerCardCounts();
            m_winningDeck.Shuffle();

            m_winningDeck = null;
            IsWar         = false;
        }

        try
        {
            if (IsWar)
            {
                WarCount++;

                if (P1Deck.m_Cards.Count < 4)
                {
                    ReShuffleIn(P1Deck, P1Discard);

                    if (P1Deck.m_Cards.Count < 4)
                    {
                        GameWin(true);
                        return;
                    }
                }
                if (P2Deck.m_Cards.Count < 4)
                {
                    ReShuffleIn(P2Deck, P2Discard);

                    if (P2Deck.m_Cards.Count < 4)
                    {
                        GameWin(false);
                        return;
                    }
                }

                Card POne1 = P1Deck.TakeFromTop();
                Card POne2 = P1Deck.TakeFromTop();
                Card POne3 = P1Deck.TakeFromTop();
                Card POne4 = P1Deck.TakeFromTop();

                Card PTwo1 = P2Deck.TakeFromTop();
                Card PTwo2 = P2Deck.TakeFromTop();
                Card PTwo3 = P2Deck.TakeFromTop();
                Card PTwo4 = P2Deck.TakeFromTop();

                P1War.GiveCard(POne1);
                P1War.GiveCard(POne2);
                P1War.GiveCard(POne3);
                P1War.GiveCard(POne4);

                P2War.GiveCard(PTwo1);
                P2War.GiveCard(PTwo2);
                P2War.GiveCard(PTwo3);
                P2War.GiveCard(PTwo4);

                POne1.transform.localPosition += new Vector3(0, 15, 0) + (new Vector3(0, 60, 0) * (WarCount - 1));
                POne2.transform.localPosition += new Vector3(0, 15, 0) * 2 + (new Vector3(0, 60, 0) * (WarCount - 1));
                POne3.transform.localPosition += new Vector3(0, 15, 0) * 3 + (new Vector3(0, 60, 0) * (WarCount - 1));
                POne4.transform.localPosition += new Vector3(0, 15, 0) * 4 + (new Vector3(0, 60, 0) * (WarCount - 1));

                PTwo1.transform.localPosition -= new Vector3(0, 15, 0) + (new Vector3(0, 60, 0) * (WarCount - 1));
                PTwo2.transform.localPosition -= new Vector3(0, 15, 0) * 2 + (new Vector3(0, 60, 0) * (WarCount - 1));
                PTwo3.transform.localPosition -= new Vector3(0, 15, 0) * 3 + (new Vector3(0, 60, 0) * (WarCount - 1));
                PTwo4.transform.localPosition -= new Vector3(0, 15, 0) * 4 + (new Vector3(0, 60, 0) * (WarCount - 1));

                POne4.Flip();
                PTwo4.Flip();

                RoundWinCheck(POne4, PTwo4);
            }
            else
            {
                if (P1Deck.m_Cards.Count < 1)
                {
                    ReShuffleIn(P1Deck, P1Discard);

                    if (P1Deck.m_Cards.Count <= 3)
                    {
                        GameWin(true);
                        return;
                    }
                }
                if (P2Deck.m_Cards.Count < 1)
                {
                    ReShuffleIn(P2Deck, P2Discard);

                    if (P2Deck.m_Cards.Count <= 3)
                    {
                        GameWin(false);
                        return;
                    }
                }

                Card c1 = P1Deck.TakeFromTop();
                Card c2 = P2Deck.TakeFromTop();

                P1War.GiveCard(c1);
                P2War.GiveCard(c2);

                c1.Flip();
                c2.Flip();
                RoundWinCheck(c1, c2);
            }
        }
        catch (NullReferenceException)
        {
            UpdatePlayerCardCounts();
        }
    }