Exemple #1
0
 /// <summary>
 /// Constructor GameManager
 /// </summary>
 public GameManager(Rectangle windowSize)
 {
     partida            = new PartidaDeCuarenta();
     cardSlots          = new CardSlots(windowSize);
     oldMouseState      = new MouseState();
     oldTouchCollection = new TouchCollection();
 }
 public void CreateCardSlots(int numSlots)
 {
     for (var i = 0; i < numSlots; ++i)
     {
         var cardSlot = Instantiate(prefabCardSlot, containerCards);
         CardSlots.Add(cardSlot);
     }
 }
Exemple #3
0
        /// <summary>
        /// Create a new Game
        /// </summary>
        /// <param name="numJugadores">Number of players</param>
        /// <param name="thisPlayer">which player is playing this game</param>
        public void newGame(int numJugadores, int thisPlayer)
        {
            if (numJugadores != 2 && numJugadores != 4)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.numJugadores = numJugadores;
            this.thisPlayer   = thisPlayer;
            if (numJugadores == 2)
            {
                thisTeam = thisPlayer;
            }
            else
            {
                thisTeam = thisPlayer % 2;
            }

            //choose who is goint to deal
            dataPlayer    = rnd.Next(0, numJugadores);
            dataPlayer    = 3;
            playerPlaying = dataPlayer + 1;
            if (playerPlaying >= numJugadores)
            {
                playerPlaying = 0;
            }

            // Begin game (shuffle and deal cards, choose which cards are face up. SIZE IS NOT ASSIGNED, determine if card is on game)
            partida.IniciarPartida(numJugadores, thisPlayer, dataPlayer);

            //assign slots to dealt cards
            int indexPlayer = thisPlayer;

            for (int i = 0; i < numJugadores; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Naipe card = partida.Manos[indexPlayer].NaipesEnGrupo[j];
                    card.CardSize = cardSlots.CardSize;
                    if (i == 1 || i == 3)
                    {
                        card.Rotated = true;
                    }
                    if (numJugadores == 4)
                    {
                        card.SetCenter(cardSlots.PlayerCardPosition[i, j]);
                        card.SlotAssigned = CardSlots.getGroupIndexHand(i, j);
                        cardSlots.UsedPlayerCardPosition[i, j] = true;
                    }
                    else
                    {
                        card.SetCenter(cardSlots.PlayerCardPosition[i * 2, j]);
                        cardSlots.UsedPlayerCardPosition[i * 2, j] = true;
                    }
                }
                indexPlayer++;
                if (indexPlayer >= numJugadores)
                {
                    indexPlayer = 0;
                }
            }

            //asign slots to cards to deal
            foreach (Naipe card in partida.Mazo.NaipesEnGrupo)
            {
                card.CardSize = cardSlots.CardSize;
                card.Rotated  = true;
                card.SetCenter(cardSlots.ToDealCardPosition[0]);
                cardSlots.UsedToDealCardPosition[0] = true;
            }

            //asing size to score cards (perros)
            foreach (Naipe card in partida.Perros.NaipesEnGrupo)
            {
                card.CardSize = cardSlots.CardSize;
            }

            //this is for TESTING
            Naipe card1 = new Naipe(CardRank.Dos, CardPalo.Brillo);

            partida.NaipesEnMesa.NaipesEnGrupo.Add(card1);
            card1.CardSize = cardSlots.CardSize;
            card1.OnGame   = true;
            card1.FaceUp   = true;
            for (int i = 0; i < 10; i++)
            {
                if (!cardSlots.UsedTableCardPosition[i])
                {
                    card1.SetCenter(cardSlots.TableCardPosition[i]);
                    cardSlots.UsedTableCardPosition[i] = true;
                    card1.SlotAssigned = CardSlots.getGroupIndexCardsInTable(i);
                    break;
                }
            }

            Naipe card2 = new Naipe(CardRank.Tres, CardPalo.Brillo);

            partida.NaipesEnMesa.NaipesEnGrupo.Add(card2);
            card2.CardSize = cardSlots.CardSize;
            card2.OnGame   = true;
            card2.FaceUp   = true;
            for (int i = 0; i < 10; i++)
            {
                if (!cardSlots.UsedTableCardPosition[i])
                {
                    card2.SetCenter(cardSlots.TableCardPosition[i]);
                    cardSlots.UsedTableCardPosition[i] = true;
                    card2.SlotAssigned = CardSlots.getGroupIndexCardsInTable(i);
                    break;
                }
            }

            partida.Manos[0].NaipesEnGrupo[0].Rank = CardRank.Cinco;
            //end of TESTING

            gameState = GameState.Playing;
            handState = HandState.NormalPlay;
        }