PlayCard lastPlay; //The last card in play.

        #endregion

        public GameController(Section p)
            : base(p)
        {
            chat   = new ChatBox(15, BangGame.SCREEN_HEIGHT - 155);
            visual = new TravelingCard[10000];

            deck        = new CardStack(BangGame.SCREEN_WIDTH - 105, 180, true);
            discardPile = new CardStack(BangGame.SCREEN_WIDTH - 105, 280);

            players = new Player[] { new CPU("Calamity Janet", false, new Point(200, 40)), new CPU("Willy the Kid", true, new Point(200, 120)),
                                     new CPU("Black Jack", true, new Point(200, 200)), new CPU("Lucky Duke", true, new Point(200, 280)), new CPU("Rose Doolan", false, new Point(200, 360)),
                                     new CPU("Paul Regret", true, new Point(200, 440)) /*new CPU("El Gringo", true, new Point(200, 540))*/ };

            RestartGame();
        }
        //Used by both constructors to create the object and save space.
        private void CreateObject(int index, CardStack cardStart, CardStack cardFinish, int timeToTravel, CardState newFace, Side startDeckSide, Side finishDeckSide)
        {
            if (cardStart == cardFinish)
            {
                done = true; transferredCard = true; return;
            }
            Card c = null;

            if (index != -1)
            {
                c = cardStart.Remove(index);
            }
            else if (startDeckSide == Side.TopRight)
            {
                c = cardStart.RemoveTop();
            }
            else
            {
                c = cardStart.RemoveBottom();
            }
            finishDeck = cardFinish;
            finish     = cardFinish;
            if (cardStart.Layout == Layout.Deck)
            {
                startVector = cardStart.TopLeft;
            }
            else
            {
                startVector = new Vector2(cardStart.Location.X + (((int)Card.cardSizeX + CardStack.SPACE_BETWEEN_CARDS) * (index > -1 ? cardStart.Size : index)), cardStart.Location.Y);
            }
            current    = startVector;
            time       = timeToTravel;
            face       = newFace;
            finishSide = finishDeckSide;

            if (c != null)
            {
                suit     = c.Suit;
                value    = c.Value;
                cardType = c.CType;

                CalculateMoveAmount();
            }
            else
            {
                done = true; transferredCard = true;
            }
        }
Exemple #3
0
        //Adds given cards to the hand.
        public void Add(CardStack newCards)
        {
            if (newCards == null || newCards.size == 0 || size >= 52)
            {
                return;
            }

            foreach (Card c in newCards.cards)
            {
                if (c != null)
                {
                    cards[size] = c;
                    size++;
                }
            }
        }
 //Best one, offset is how long to wait before actually moving the card and which card index.
 public TravelingCard(CardStack cardStart, int index, CardStack cardFinish, int timeToTravel, CardState newFace, int newOffset)
     : base(CardType.Bang, CardValue.Ace, Suit.Spades)
 {
     if (newOffset < 0)
     {
         newOffset = 0;
     }
     offset = newOffset;
     if (offset > 0)
     {
         started = false;
     }
     if (offset == 0)
     {
         CreateObject(index, cardStart, cardFinish, timeToTravel, newFace, Side.TopRight, Side.TopRight);
     }
     else
     {
         CreateObjectWithOffset(index, cardStart, cardFinish, timeToTravel, newFace, Side.TopRight);
     }
 }
        //Best one, offset is how long to wait before actually moving the card and which card index.
        public TravelingCard(CardStack cardStart, Card actualCard, CardStack cardFinish, int timeToTravel, CardState newFace, int newOffset)
            : base(CardType.Bang, CardValue.Ace, Suit.Spades)
        {
            int index = -1;

            for (int i = 0; i < cardStart.Size; i++)
            {
                if (cardStart[i] == actualCard)
                {
                    index = i; break;
                }
            }

            if (index < 0)
            {
                throw new Exception("The given card was not found in the cardStack.");
            }

            if (newOffset < 0)
            {
                newOffset = 0;
            }
            offset = newOffset;
            if (offset > 0)
            {
                started = false;
            }
            if (offset == 0)
            {
                CreateObject(index, cardStart, cardFinish, timeToTravel, newFace, Side.TopRight, Side.TopRight);
            }
            else
            {
                CreateObjectWithOffset(index, cardStart, cardFinish, timeToTravel, newFace, Side.TopRight);
            }
        }
 //For cards that instantaneously move. (no offset required)
 public TravelingCard(CardStack cardStart, CardStack cardFinish, int timeToTravel, CardState newFace)
     : base(CardType.Bang, CardValue.Ace, Suit.Spades)
 {
     CreateObject(-1, cardStart, cardFinish, timeToTravel, newFace, Side.TopRight, Side.TopRight);
 }