Ejemplo n.º 1
0
        public bool Update()
        {
            if (!GameOver)
            {
                if (current == null)
                {
                    current = new Tetromino(this);
                    List <Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                    Tetromino.Shapes        newShape   = shapeNames[r.Next(shapeNames.Count)];
                    current.Spawn(newShape, 3, 0, r.Next(4));
                }
                else
                {
                    bool done = current.MoveDown();
                    if (done)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            for (int j = 0; j < Width; j++)
                            {
                                if (Grid[j, i] != Color.Transparent)
                                {
                                    GameOver = true;
                                    break;
                                }
                            }
                            if (GameOver)
                            {
                                break;
                            }
                        }

                        ClearFullLines();

                        current = new Tetromino(this);
                        List <Tetromino.Shapes> shapeNames = Tetromino.Structures.Keys.ToList();
                        Tetromino.Shapes        newShape   = shapeNames[r.Next(shapeNames.Count)];
                        current.Spawn(newShape, 3, 0, r.Next(4));
                    }
                }
            }
            return(GameOver);
        }