private void rollButtonClicked(object sender, EventArgs e) { Button clickedButton = sender as Button; int indexOf_1 = clickedButton.Tag.ToString().IndexOf("1"); TextBox textBoxToDisable = indexOf_1 != -1 ? txtName1 : txtName2; PictureBox diceImageBoxToManipulate = indexOf_1 != -1 ? diceImageBox1 : diceImageBox2; int indexOfThrownDice = indexOf_1 != -1 ? 0 : 1; int diceNumber = new Random().Next(1, 7); UIRenderingAssistant.PlaceDiceImageWithinPictureBox(new int[] { diceNumber }, new PictureBox[] { diceImageBoxToManipulate }); clickedButton.Enabled = false; textBoxToDisable.Enabled = false; rolledDices[indexOfThrownDice] = diceNumber; if (rolledDices[0] != 0 && rolledDices[1] != 0) { if (!isStateResetForAnotherRoll()) { displayGameForm(); } } }
private void renderGameState(bool hasToRenderTriangles) { if (hasToRenderTriangles) { UIRenderingAssistant.PopulateTriangles_WithCheckerImages(triangles, gameState, checkerImageHolders.GetEnumerator()); } UIRenderingAssistant.RenderTextualData(textualEssentials, gameState); }
private void initializeTriangles() { Size triangleSize = new Size(57, 276); triangles = new List <Triangle>(); for (int i = 0; i < 26; i++) { Triangle t = i < 24 ? new Triangle(i, triangleSize) : new Triangle(23 - i, triangleSize); t.Click += trianlgeClicked; triangles.Add(t); } UIRenderingAssistant.PopulateGameBoard_WithTriangles(boardImageBox, triangles); }
private void rollBtn_Click(object sender, EventArgs e) { gameEngine.RollDices(); if (gameState.InfoMessage != null) { MessageBox.Show(nestPlayerNameWithinInfoMessage()); } if (gameState.PlayingColor != 'N') { int[] rolledDices = new int[] { gameState.RolledDices[0], gameState.RolledDices[1] }; PictureBox[] diceImageHolders = new PictureBox[] { diceImageHolder1, diceImageHolder2 }; UIRenderingAssistant.PlaceDiceImageWithinPictureBox(rolledDices, diceImageHolders); lockOrOpenControls(); } renderGameState(false); }