/// <summary> /// Handle the prebuilding of the deck /// </summary> /// <param name="data">The urls for the loading of images</param> /// <param name="cardSizeX">size of the cards horizontal</param> /// <param name="cardSizeY">size of the cards vertical</param> public void Run(string[] data, int cardSizeX, int cardSizeY) { int sizeX = int.Parse(data[0]); int sizeY = int.Parse(data[1]); cards = new Card[sizeX, sizeY]; // init back card Card.BackImage = new BitmapImage(new Uri("assets/images/background_card.png", UriKind.RelativeOrAbsolute)); int dataCount = 2; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { // unpack data string[] dataPack = data[dataCount].Split(';'); // get url and id string imageUrl = dataPack[0]; int id = int.Parse(dataPack[1]); // create image BitmapImage image = ImageGetter.GetImageFromWeb(imageUrl, cardSizeX); // create card cards[x, y] = new Card(id, new Size(cardSizeX, cardSizeY), new Point(0, 0), image); // next data pack dataCount++; } } Build(cards, sizeX, sizeY, cardSizeX, cardSizeY, 10); }
public Board(byte i_Rows, byte i_Cols) { m_Rows = i_Rows; m_Cols = i_Cols; m_Matrix = new Card[m_Rows, m_Cols]; BoardBuilder.BuildBoard(this); }
public Board(int i_height, int i_width) { r_Height = i_height; r_Width = i_width; r_Matrix = new Card[i_height, i_width]; this.MakeNewGameBoard(); }
static CardStructures() { Cards = new Card[13, 4]; for (int c = 0; c < 4; c++) { for (int i = 0; i < 13; i++) { Cards[i, c] = new Card() { Rank = i, Suit = c }; } } var hands = new List <Hand>(); foreach (var c1 in Cards) { foreach (var c2 in Cards) { if (c1.CompareTo(c2) < 0) { hands.Add(new Hand(c1, c2)); } } } Hands = hands.ToArray(); }
public void Init(CardModel model) { cardAry = new Card[3, 3]; MakeCardPool(); // InitCards(); }
public void startup() { GridBox gb1 = new GridBox(panel); GridBox gb2 = new GridBox(panel2); Debug.Log(PhotonNetwork.player.ID); if (PhotonNetwork.player.ID == 2) { Debug.Log("I Am player 2"); playersTurn = false; oPlayerCastArea.Add(gb2); playerCastArea.Add(gb1); } else { playersTurn = true; oPlayerCastArea.Add(gb1); playerCastArea.Add(gb2); } PhotonView view = PhotonView.Find(6); gridMatrix = new Card[20, 12]; }
public Grid(Form1 form, int size, bool showUpwards) { this.form = form; this.counter = new Counter(); this.showUpwards = showUpwards; if (size == Grid.SMALL) { this.size = Grid.SMALL; form.Size = new Size(400, 400); cardsList = new List <Card>(); cards = new Card[4, 4]; } else if (size == Grid.LARGE) { this.size = Grid.LARGE; form.Size = new Size(650, 650); cardsList = new List <Card>(); cards = new Card[8, 8]; } LoadBitmaps(); InitCards(); if (showUpwards) { ShowAll(); } }
public Grid(Form1 form, int size, bool showUpwards) { this.form = form; this.counter = new Counter(); this.showUpwards = showUpwards; if (size == Grid.SMALL) { this.size = Grid.SMALL; form.Size = new Size(400, 400); cardsList = new List<Card>(); cards = new Card[4,4]; } else if (size == Grid.LARGE) { this.size = Grid.LARGE; form.Size = new Size(650, 650); cardsList = new List<Card>(); cards = new Card[8, 8]; } LoadBitmaps(); InitCards(); if (showUpwards) { ShowAll(); } }
private bool BoardHasPairsOfCards(Card[,] inputBoard) { Dictionary <int, int> cardTypeCountPair = new Dictionary <int, int>(); foreach (var card in inputBoard) { if (!cardTypeCountPair.ContainsValue(card.CardNumber)) { cardTypeCountPair.Add(card.CardNumber, 1); } else { ++cardTypeCountPair[card.CardNumber]; } } foreach (var cardCount in cardTypeCountPair.Values) { if (cardCount % 2 != 0) { return(false); } } return(true); }
public GameBoard(int i_NumberOfRows, int i_NumberOfColumns) { this.m_NumberOfExposedPairs = 0; this.m_CardTemporaryExposedByPlayer = null; this.r_GameBoard = new Card[i_NumberOfRows, i_NumberOfColumns]; this.initGameBoard(); }
public Board(Headquarter p1HQ, Headquarter p2HQ) { unitsOnBoard = new Card[3, 5]; squadsOnBoard = new Squad[5]; unitsOnBoard[2, 0] = p1HQ; unitsOnBoard[0, 4] = p2HQ; }
/*FUNCTION: PrintDeck() * PARAMS: Card[,]deck (a 2D array of values from the class Card) * RETURNS: None * CLASS SCOPE EFFECT: None (doesn't change any values of other variables) * CALLED FUNCTION: None * * Description: Print the shuffled cards in the shuffledDeck array from Shuffle() using a for loop. On printing, the masterOrderedDeck Card elements isUsed value is reset to false to prepare them for any more possible shuffles. * The shuffledDeck Card elements are also copied over to the shuffledCards one dimensional array (again, this is done so that it is easier to access the shuffled cards during gameplay, by using a single index instead of having to pass two indexes) */ public static void PrintDeck(Card[,] deck) { //declare and initialize a count variable to track the card number int cardCount = 0; Console.WriteLine("The current shuffled deck."); Console.WriteLine("-------------------------------------"); for (int row = 0; row < 4; row++) { for (int column = 0; column < 13; column++) { masterOrderedDeck[row, column].isUsed = false; //reset the masterOrderedDeck Card elements back to false //if the card rank is an Ace, Jack, Queen, or King, display the string name for them if ((deck[row, column].rank == Rank.Queen) || (deck[row, column].rank == Rank.King) || (deck[row, column].rank == Rank.Jack)) { Console.WriteLine(cardCount + "| [" + row + "]" + "[" + column + "]: \tSuit: " + deck[row, column].suit + ",\tRank: " + deck[row, column].rank + " \tValue: 10"); } else if ((deck[row, column].rank == Rank.Ace)) { Console.WriteLine(cardCount + "| [" + row + "]" + "[" + column + "]: \tSuit: " + deck[row, column].suit + ",\tRank: " + deck[row, column].rank + " \tValue: 1"); } //otherwise, display the numberic value of the card else { Console.WriteLine(cardCount + "| [" + row + "]" + "[" + column + "]: \tSuit: " + deck[row, column].suit + ",\tRank: " + deck[row, column].rank + " \tValue: " + (int)deck[row, column].rank); } shuffledCards[cardCount] = deck[row, column]; //copy the shuffled cards to the shuffledCards one dimensional array cardCount++; } } Console.WriteLine("-------------------------------------"); }
public Board(int i_Height, int i_Width) { m_Width = i_Width; m_Height = i_Height; m_GameBoard = new Card[i_Height, i_Width]; initBoard(); }
public Player(Card[] cardsDealt, bool isDealer, Card[,] allCardsDealt, int wallet) { cards = cardsDealt; this.isDealer = isDealer; this.cardsDealt = allCardsDealt; this.wallet = wallet; }
public BoardMemento(Card[,] cards, Card firstUpCard = null) { this.col = cards.GetLength(0); this.row = cards.GetLength(1); this.cards = cards.Cast <Card>().ToArray(); this.firstUpCard = firstUpCard; }
//Card[,] cardArray ={{ac,ad,ah,AS }, // {twoC,twoD,twoH,twoS }, // {jc,jd,jh,js}, // {qc,qd,qh,qs }, // {kc,kd,kh,ks } }; #endregion #region Methods public void CreateCards() { //Card[,] cardArray = new Card[4, 3]; //Card ac = new Card("a", "c"); //Card ad = new Card("a", "d"); //Card ah = new Card("a", "h"); //Card AS = new Card("a", "s"); //Card twoC = new Card("2", "c"); //Card twoD = new Card("2", "d"); //Card twoH = new Card("2", "h"); //Card twoS = new Card("2", "s"); //Card jc = new Card("j", "c"); //Card jd = new Card("j", "d"); //Card jh = new Card("j", "h"); //Card js = new Card("j", "s"); //Card qc = new Card("q", "c"); //Card qd = new Card("q", "d"); //Card qh = new Card("q", "h"); //Card qs = new Card("q", "s"); //Card kc = new Card("k", "c"); //Card kd = new Card("k", "d"); //Card kh = new Card("k", "h"); //Card ks = new Card("k", "s"); Card[,] cardArray = { { ac, ad, ah, AS }, { twoC, twoD, twoH, twoS }, { jc, jd, jh, js }, { qc, qd, qh, qs }, { kc, kd, kh, ks } }; }
public static Card[,] GetShuffledCards(int num) { _deck = new Card[num, num]; int pairsOfCards = (num * num) / 2; int counter = 1; bool isUpToMiddle = true; for (int x = 0; x < num; x++) { for (int y = 0; y < num; y++) { if (counter <= pairsOfCards && isUpToMiddle) { _deck[x, y] = new Card(counter++); if (_deck[x, y].Value.Equals(pairsOfCards)) { isUpToMiddle = false; } } else { _deck[x, y] = new Card(--counter); } } } _deck.Shuffle(); return(_deck); }
public Board(int i_Rows, int i_Cols) { m_CardsBoard = new Card[i_Rows, i_Cols]; m_LeftCardsNumber = i_Cols * i_Rows; this.r_FoundPositions = new Tuple <int, int> [i_Rows * i_Cols]; this.createGameBoard(i_Rows, i_Cols); this.r_RandPosition = new Random(); }
public Map(int x, int y, ICardContext cardContext, int width, int height) { this.mapX = x; this.mapY = y; this.width = width; this.height = height; this.mapCard = new Card[this.width, this.height]; }
// Note the casting from int to enum type public Deck() { cards = new Card[RankCount, SuitCount]; for (int r = 0; r < RankCount; r++) for (int s = 0; s < SuitCount; s++) cards[r, s] = new Card((SuitValue)s, (RankValue)r); }
public Deck(Random rand) { cards = new Card[NRANKS, NSUITS]; for (int i = 0; i < length; i++) { } }
private void Awake() { SwipeDetector.OnSwipe += HandlePlayerSwipe; //SwipeDetector.OnPreSwipe += HandlePlayerPotentialSwipe; KeyboardDetector.OnInput += HandlePlayerInputFromKeyboard; activeCards = new Card[MAX_GRID_WIDTH, MAX_GRID_HEIGHT]; }
static Card[] HandfromArray(Card[,] hands, int slot) { Card[] tempHand = new Card[2]; for (int i = 0; i < 2; i++) { tempHand[i] = hands[slot, i]; } return(tempHand); }
public Dealer(int playerNumber) { cardsDealt = new Card[playerNumber, 6]; //asks if the player wants a card //plays his hand //Decides who won or not }
public Board(int i_Row, int i_Col) { m_Row = i_Row; m_Col = i_Col; m_MaxPairCards = (i_Row * i_Col) / 2; m_NumOfExposedPairCards = 0; m_GameBoard = new Card[i_Row, i_Col]; createBoardValues(); }
public Deck(Random rand) { cards = new Card[NRANKS, NSUITS]; for (int i = 0; i < length; i++) { } }
private readonly Card[,] playerCards; // We are keeping local information about cards to prevent cheating from players (e.g. playing card that they don't own) #endregion Fields #region Constructors public DealManager(GameManager game) { this.game = game; this.cardDeck = new Queue<Card>(CardsHelper.GetFullCardDeck()); Debug.Assert(this.cardDeck != null && this.cardDeck.Count == 32, "The card deck is not complete!"); this.playerCards = new Card[4, 8]; // 4 players, 8 cards for each player }
static void PrintHandFromArray(Card[,] hands, Int32 slot = 0) { string[] tempHand = new string[2]; Console.WriteLine("Your hand:"); for (int i = 0; i < 2; i++) { tempHand[i] = CardToName(hands[slot, i]); } Console.WriteLine(tempHand[0] + " and " + tempHand[1]); }
public Card[] Hand(int playerNum, Card[,] hands) { Card[] tempHand = new Card[2]; for (int i = 0; i < 2; i++) { tempHand[i] = hands[playerNum - 1, i]; } return(tempHand); }
private CardFlyweight() { cards = new Card[Suite.Values().Length, Value.Values().Length]; for (int i = 0; i < Suite.Values().Length; i++) { for (int j = 0; j < Value.Values().Length; j++) { cards[i, j] = new Card(Value.Values()[j], Suite.Values()[i]); } } }
public void StartGame() { do { Console.Write("Choose the size of the game board (Must be even) "); } while (!int.TryParse(Console.ReadLine(), out _size) || _size % 2 != 0); _cards = Deck.GetShuffledCards(_size); StartGameLoop(); }
void Awake() { if (Application.platform == RuntimePlatform.Android) { btControl = BluetoothControl.Instance; BluetoothControl.Server.ServerObject = this.gameObject.name; } globalScore = SaveStatus.Load(); cards = new Card[rows, columns]; current_x = 0; current_y = 0; }
public CardGame(int cardCountX, int cardCountY) { if (cardCountX * cardCountY % 2 != 0) { throw new InvalidOperationException( "Total card count has to be an even number " + "otherwise there'll be a pair lacking a card"); } cards = new Card[cardCountX, cardCountY]; StartNewSession(); }
// Note the casting from int to enum type public Deck() { cards = new Card[RankCount, SuitCount]; for (int r = 0; r < RankCount; r++) { for (int s = 0; s < SuitCount; s++) { cards[r, s] = new Card((SuitValue)s, (RankValue)r); } } } // end constructor
public Deck() { //Populate deck with card instances deck = new Card[suitCount, valueCount]; for (int suits = 0; suits < suitCount; suits++) { for (int values = 0; values < valueCount; values++) { deck[suits, values] = new Card(suits, values, 0, values); } } }
// TODO: Reset everything for a brand new use public void Start() { nicks = mgr.LobbyScreen.Nicks; scores = new int[nicks.Length]; pubCards = new Card[nicks.Length, 5]; }
public void InitCards() { PositionX = 0; PositionY = 0; matches = 0; // Create a list of the Card face Ids to draw from // elements are stored in matching pairs (1,1,2,2,3,3,etc.) List<int> Ids = new List<int>(); for(int i=0; i<(_totalCards/2); i++) { Ids.Add(i); Ids.Add(i); } // Create a jagged array grid to hold the Card instances: cards = new Card[_rows, _columns]; // Loop through the grid and create a new Card instance for each element: for (int i = 0; i < _rows; i++) { for (int j = 0; j < _columns; j++) { // Randomly pick a face Id from the list: int randomId = someNum.Next(Ids.Count); // Create the Card instance: cards[i,j] = new Card(i,j, Ids[randomId]); // Remove the face Id from the list to keep other cards from choosing it: Ids.RemoveAt(randomId); } } }
/// <summary> /// Builds all game objects for the given level. /// </summary> /// <param name="currentLevel">The current level.</param> /// <param name="scene">The scene to which to add all objects.</param> internal async Task BuildFirstScreenAsync(LevelData currentLevel, Scene scene) { m_scene = scene; m_currentLevel = currentLevel; int tilesX = currentLevel.Tilemap.TilesX; int tilesY = currentLevel.Tilemap.TilesY; float tileDistX = Constants.TILE_DISTANCE_X; float tileDistY = -Constants.TILE_DISTANCE_Y; Vector3 midPoint = new Vector3((tilesX - 1) * tileDistX / 2f, 0f, ((tilesY - 1) * tileDistY / 2f)); m_cardMapOnScreen = new Card[tilesX, tilesY]; m_cardPairsOnScreen = new List<CardPairLogic>(); ScreenData currentScreen = currentLevel.Screens[0]; m_actScreenIndex = 0; await scene.ManipulateSceneAsync((manipulator) => { // Build background and define level-wide resources manipulator.BuildBackground(currentLevel.MainTextures.BackgroundTextureLink); m_resBackgroundMaterial1 = manipulator.AddSimpleColoredMaterial( currentLevel.MainTextures.Tile1TextureLink); m_resBackgroundMaterial2 = manipulator.AddSimpleColoredMaterial( currentLevel.MainTextures.Tile2TextureLink); // Build the current screen BuildScreen(manipulator, currentScreen); // Add all logic components to the scene manipulator.Add(new PairUncoverLogic()); manipulator.Add(new VideoPlayLogic()); manipulator.Add(new BackgroundMusicLogic(currentLevel)); manipulator.Add(new EndGameLogic(currentLevel)); manipulator.Add(this); }); Messenger.BeginPublish<MainMemoryScreenEnteredMessage>(); }
void Start() { base.Start (); nextGame = buttonResponse.LOAD_AWARDS_SCENE; cardObject = new GameObject[width, height]; cardScript = new Card[width, height]; setUpGame (); click_state = clickState.DEFAULT; }
/// <summary> /// Initiating the 2 dimentional array of buttons with a blank image. /// </summary> private void initiateButtonsArray(){ try{ // Allocate the array of cards, which contains the properties. buttonsArray = new Card[SIZE, SIZE]; // Instantiate with white properties. for (int i = 0; i < SIZE; i++){ for (int j = 0; j < SIZE; j++){ buttonsArray[i, j] = new Card( "blank", "white", 0); } } // Initialize the button outerImage = new Card("blank", "white", 0); outerButton = FindViewById<ImageButton>(Resource.Id.outerImgBtn); outerButton.SetImageResource(Resource.Drawable.blank); // Allocate the two dimensional array of image buttons. gameImgButtons = new ImageButton[SIZE, SIZE]; // Initialize Image buttons array. for (int i = 0; i < SIZE; i++){ for (int j = 0; j < SIZE; j++){ gameImgButtons[i, j] = new ImageButton(this); } } // Set all images with the blank image. for (int i = 0; i < SIZE; i++){ for (int j = 0; j < SIZE; j++){ gameImgButtons[i, j].SetImageResource(Resource.Drawable.blank); } } } catch (Exception){ showMessage("Something went wrong in game initialization"); } }
/// <summary> /// C'tor. /// </summary> /// <param name="arrayOfButtons"></param> /// <param name="newSize"></param> public GameRules(Card[,] arrayOfButtons,ImageButton[,] arrayOfImgs,int newSize) { gameBoard = arrayOfButtons; gameImages = arrayOfImgs; SIZE = newSize; }