Esempio n. 1
0
        private void CheckLinesToClear()
        {
            if (!LinesToClear.Any())
            {
                for (int row = 0; row < TowerData.GetLength(0); row++)
                {
                    bool isCleared = true;

                    for (int col = 0; col < TowerData.GetLength(1); col++)
                    {
                        if (TowerData[row, col] == BlockValue.Empty || TowerData[row, col] == BlockValue.Cleared)
                        {
                            isCleared = false;
                            continue;
                        }
                    }

                    if (isCleared)
                    {
                        LinesToClear.Add(row);
                        ClearState = ClearState.Mark;
                    }
                }

                MarkLinesForClear();
            }
        }
Esempio n. 2
0
    public List <int> ForceDown()
    {
        if (forzarBajada)
        {
            if (this.DoesFitIn(indexCurrentPiece, indexCurrentRotation, currentX, currentY + 1))
            {
                currentY++;
            }
            else
            {
                //clavar la pieza en el lugar
                for (int x = 0; x < 4; x++)
                {
                    for (int y = 0; y < 4; y++)
                    {
                        if (tetromino[indexCurrentPiece][Rotate(x, y, indexCurrentRotation)] != '.')
                        {
                            char letra = 'A';
                            letra += (char)indexCurrentPiece;
                            field[currentX + x, currentY + y] = letra;
                        }
                    }
                }
                //fijarse si no hay algun tetris
                for (int y = 0; y < 4; y++)
                {
                    if (currentY + y < fieldHeight - 1)
                    {
                        bool IsALine = true;
                        for (int x = 1; x < fieldWidth - 1; x++)
                        {
                            if (field[x, currentY + y] == ' ')
                            {
                                IsALine = false;
                                break;
                            }
                        }

                        //si hay una linea cmabiarla a === y despues eliminarlas xd
                        if (IsALine)
                        {
                            for (int x = 1; x < fieldWidth - 1; x++)
                            {
                                field[x, currentY + y] = '=';
                            }
                            LinesToClear.Add(currentY + y);
                        }
                    }
                }
                //elegir nueva pieza
                indexCurrentPiece    = random.Next(0, 7);
                indexCurrentRotation = 0;
                currentX             = fieldWidth / 2;
                currentY             = 0;
                //y si la pieza no entra EN LA PANTALLA
                gameOver = (!this.DoesFitIn(indexCurrentPiece, indexCurrentRotation, currentX, currentY));
            }
        }
        return(LinesToClear);
    }