示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!checkLose(masiv))
            {
                if (!f.ElemBelowIs(1) && !f.ElemBelowIs(2))
                {
                    f.moveBelow();
                }
                else //якщо наступне є двійкою або одиничкою
                {
                    f.disableFigure();
                    f = f.makeNewFigure(this);
                }

                if (getWinRowIndex(masiv) != 0)  //якщо фігура зупинилась і є заповнений рядок
                {
                    int ind = getWinRowIndex(masiv);

                    if (ind == masiv.Length / (masiv.GetUpperBound(0)))
                    {
                        for (int i = 0; i < masiv.Length / (masiv.GetUpperBound(0) + 1); i++)
                        {
                            masiv[ind, i] = 0;
                        }
                        setFrame(masiv);
                    }

                    moveRows(masiv, ind);

                    score        += 100;
                    scoreLbl.Text = "SCORE:" + score;
                    if (score % 500 == 0)
                    {
                        timer1.Interval -= 20;
                    }
                }
                setLabelsFromArray(masiv, tableLayoutPanel1);
                printArray(masiv);
            }
            else
            {
                timer1.Enabled = false;
                closeGame();
            }
            //Invalidate();
        }