/// <summary> /// Trigger the event for all event handlers /// </summary> /// <param name="numberTile"></param> public void OnCorrectGuessEvent(NumberTile numberTile) { if (eventHandlers != null) { eventHandlers(numberTile); } }
// sound effects #endregion #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="contentManager">the content manager</param> /// <param name="center">the center of the board</param> /// <param name="sideLength">the side length for the board</param> /// <param name="correctNumber">the correct number</param> public NumberBoard(ContentManager contentManager, Vector2 center, int sideLength, int correctNumber, CorrectGuessEventHandler handleCorrectGuessEvent) { // Increment 2: load content for the board and create draw rectangle LoadContent(contentManager); drawRectangle = new Rectangle( (int)center.X - sideLength / 2, (int)center.Y - sideLength / 2, sideLength, sideLength); // Increment 2: calculate side length for number tiles tileSideLength = (sideLength - (NumColumns + 1) * BorderSize) / NumColumns; // Increments 3 and 5: initialize array of number tiles for (int i = 0; i < NumRows; i++) { for (int j = 0; j < NumColumns; j++) { tiles[i, j] = new NumberTile(contentManager, CalculateTileCenter(i, j), tileSideLength, i * NumColumns + j + 1, correctNumber, handleCorrectGuessEvent); } } }
/// <summary> /// Trigger the correct guess event for the tile /// </summary> /// <param name="numberTile"></param> private void OnCorrectGuessEvent(NumberTile numberTile) { correctGuessEvent.OnCorrectGuessEvent(numberTile); }
private void HandleCorrectGuessEvent(NumberTile numberTile) { StartGame(); }