public void Update() { while (true) { int dropTime = (int)this.dropTimer.ElapsedMilliseconds; if (dropTime > this.dropRate) { this.dropTimer.Restart(); this.shape.Drop(); } if (this.shape.GetIsDropped() == true) { this.shape = this.nextShape; this.nextShape = SetNewFigure(); ShowNextBlock(); this.shape.Spawn(); } for (int j = 0; j < GameField.GetWidth(); j++) { if (GameField.GetDroppedShapeLocationGrid()[0, j] == 1) { return; } } Move(); ClearLine(); } }
private void ClearLine() { int combo = 0; for (int i = 0; i < GameField.GetHeight(); i++) { int j; for (j = 0; j < GameField.GetWidth(); j++) { if (GameField.GetDroppedShapeLocationGrid()[i, j] == 0) { break; } } if (j == GameField.GetWidth()) { linesPicked++; combo++; ShowLineBlock(); for (j = 0; j < GameField.GetWidth(); j++) { GameField.GetDroppedShapeLocationGrid()[i, j] = 0; } int[,] newDroppedShapeLocationGrid = new int[GameField.GetHeight(), GameField.GetWidth()]; for (int k = 1; k < i; k++) { for (int l = 0; l < GameField.GetWidth(); l++) { newDroppedShapeLocationGrid[k + 1, l] = GameField.GetDroppedShapeLocationGrid()[k, l]; } } for (int k = 1; k < i; k++) { for (int l = 0; l < GameField.GetWidth(); l++) { GameField.GetDroppedShapeLocationGrid()[k, l] = 0; } } for (int k = 0; k < GameField.GetHeight(); k++) { for (int l = 0; l < GameField.GetWidth(); l++) { if (newDroppedShapeLocationGrid[k, l] == 1) { GameField.GetDroppedShapeLocationGrid()[k, l] = 1; } } } GameField.DrawShape(this.shape); if (combo == 1) { this.player.SetScore(this.player.GetScore() + 100); } else if (combo == 2) { this.player.SetScore(this.player.GetScore() + 300); } else if (combo == 3) { this.player.SetScore(this.player.GetScore() + 700); } else if (combo > 3) { this.player.SetScore(this.player.GetScore() + 1500); } ShowScoreBlock(); if (linesPicked < 5) { level = 1; } else if (linesPicked < 10) { level = 2; } else if (linesPicked < 15) { level = 3; } else if (linesPicked < 25) { level = 4; } else if (linesPicked < 35) { level = 5; } else if (linesPicked < 50) { level = 6; } else if (linesPicked < 70) { level = 7; } else if (linesPicked < 90) { level = 8; } else if (linesPicked < 110) { level = 9; } else if (linesPicked < 150) { level = 10; } ShowPlayerStat(); } } dropRate = 300 - 22 * level; }