public Factory(Game m, int ndx) { model = m; Index = ndx; SuspendLayout(); BackgroundImageLayout = ImageLayout.Zoom; BackgroundImage = Properties.Resources.factory; Name = "Factory" + Index; Size = new Size(240, 240); buttons = new TileButton[4]; for (int i = 0; i < 4; ++i) { buttons[i] = new TileButton(); Controls.Add(buttons[i]); int x = (i % 2 == 0) ? FIRST_POSITION : SECOND_POSITION; int y = (i < 2) ? FIRST_POSITION : SECOND_POSITION; buttons[i].Location = new Point(x, y); buttons[i].Click += new EventHandler(model.PickTiles); } ResumeLayout(); }
private void UpdateCenter(bool tiles = true) { pnlCenterArea.SuspendLayout(); // Sort tiles centerArea.Sort(); // Calculate appropriate size (in tiles) based on tile count int size = (int)Math.Ceiling(Math.Sqrt(centerArea.Count)); int pixels = 67 * size; pnlCenterArea.Size = new Size(pixels, pixels); if (tiles) { pnlCenterArea.Controls.Clear(); // Create new tiles and buttons foreach (Color tile in centerArea) { TileButton tileButton = new TileButton(tile); tileButton.MinimumSize = tileButton.Size; tileButton.Click += new EventHandler(PickTiles); pnlCenterArea.Controls.Add(tileButton); } } int winSize = ClientSize.Width; pnlCenterArea.Scale(new SizeF(winSize / oldSize, winSize / oldSize)); int loc = winSize / 2 - pnlCenterArea.Size.Width / 2; pnlCenterArea.Location = new Point(loc, loc); pnlCenterArea.ResumeLayout(); }
internal void PickTiles(object sender, EventArgs e) { int factory = -1; TileButton btn = (TileButton)sender; if (btn.Parent.GetType() == typeof(Factory)) { factory = ((Factory)btn.Parent).Index; } Color color = (Color)btn.TileColor; TileCollection picked; // TODO the actual move stuff if (factory < 0) { picked = centerArea.removeTilesOfColor(color); if (centerArea.Contains(Color.WHITE)) { picked.AddRange(centerArea.removeTilesOfColor(Color.WHITE)); } } else { picked = factories[factory].removeTilesOfColor(color); centerArea.AddRange(factories[factory]); factories[factory].Clear(); } UpdateTiles(); playerBoards[curPlayer].setSelectedTiles(picked); //if (netGame) //{ // connection.InvokeAsync("SendPick", curPlayer, factory, color); //} }