예제 #1
0
        public Field(FormTetris formTetris)
        {
            form = formTetris;

            ClearField();

            cellStates = new CellStates[MyGraphics.COLUMNS_COUNT, MyGraphics.ROWS_COUNT];
            cellColor  = new FigureColors[MyGraphics.COLUMNS_COUNT, MyGraphics.ROWS_COUNT];

            neighborsList = new List <Figure.NeighboringCells>();
            fullRowsList  = new List <int>();

            GenerateFigureParameters();

            figure = Figure.CreateFigure(figureName);
            MyGraphics.DrawFigure(figure, form.splitContainer1.Panel2);

            GenerateFigureParameters();

            PrintFigureOnPlNextFigure();

            gameOver = false;
            score    = 0;
            form.LblCurrentScore.Text = "Очки: " + score;

            SetEvents();
            form.LblCurrentScore.Visible = true;

            form.timer1.Start();
        }
예제 #2
0
        /// <summary>
        /// Падение
        /// </summary>
        public void Fall()
        {
            if (!figure.CanFall())
            {
                FreezeFigure();

                int[] coordinatesForDel = CheckFilling().ToArray();

                if (coordinatesForDel.Length > 0)
                {
                    for (int i = 0; i < coordinatesForDel.Length; i++)
                    {
                        ChangeCoordinates(coordinatesForDel[i]);
                        IncreaseScore?.Invoke(Events.DeleteRows);
                    }

                    MyGraphics.ClearCells(form.splitContainer1.Panel2);
                    MyGraphics.DrawCells(form.splitContainer1.Panel2);
                    neighborsList.Clear();
                }
                else
                {
                    IncreaseScore?.Invoke(Events.Fall);
                }

                figure = Figure.CreateFigure(figureName);

                CheckEndGame();
            }
            else
            {
                MyGraphics.EraseFigure(figure, form.splitContainer1.Panel2);
                figure.Fall();
                MyGraphics.DrawCells(neighborsList, form.splitContainer1.Panel2);
                MyGraphics.DrawFigure(figure, form.splitContainer1.Panel2);

                neighborsList = figure.CheckNeighboringCells();
            }
        }