private void OnGameOver() { GameIsOver = true; if (GameOver != null) { GameOver.Invoke(this, new GameOverEventArgs() { Message = "You lose!", Score = Score, LinesScore = LinesScore }); } }
/// <summary> /// Shows the Form that the Game is Over and Opens up the High Score Submit Form /// </summary> private void SetHighScores() { if (_formAlreadyUp == false) { _formAlreadyUp = true; using (HighScoresSubmit hss = new HighScoresSubmit(_totalScore, _totalLevel, _numberOfLinesCleared)) hss.ShowDialog(); GameOver?.Invoke(); _themeSong.Stop(); } }
public void CheckBlock() { if (FallingBlock != null) { dynamic overlapBlock = false; for (var row = 0; row <= 3; row++) { for (var column = 0; column <= 3; column++) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); if (Cells[pt.ToString()].Fixed) { overlapBlock = true; break; } } } if (overlapBlock) { break; } } if (overlapBlock) { GameOver?.Invoke(this, new EventArgs()); } else { dynamic fixBlock = false; for (var column = 0; column <= 3; column++) { for (var row = 3; row >= 0; row += -1) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); if (pt.Row.Equals(Rows - 1) || Cells[new CellPoint(pt.Row + 1, pt.Column).ToString()].Fixed) { fixBlock = true; } break; } } if (fixBlock) { break; } } if (fixBlock) { for (var row = 0; row <= 3; row++) { for (var column = 0; column <= 3; column++) { if (FallingBlock.FilledCell(column, row)) { var pt = BlockToBoard(new CellPoint(row, column)); Cells[pt.ToString()].Fixed = true; Cells[pt.ToString()].Color = FallingBlock.Color; } } } FallingBlock = null; CheckFullRows(); } } } }