예제 #1
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();
            }
        }