示例#1
0
        public static void StartGame()
        {
            FirstBlock = GenerateBlock();
            FirstBlock.Prepare();
            NextBlock = GenerateBlock();
            NextBlock.SetBlockType();
            UpdateMap();

            while (true)
            {
                timeStart.Start();
                if ((int)timeStart.ElapsedMilliseconds > timeToEnd)//co 0,5 sek generuje nowy klocek
                {
                    if (!FirstBlock.IsSomethingUnder())
                    {
                        Thread.Sleep(timeToEnd);
                        FirstBlock.Drop();
                        action = true;
                        timeStart.Reset();
                    }
                    else
                    {
                        if (map[generateLocation[0], generateLocation[1]] == 2)
                        {
                            //Game Over
                            return;
                        }
                        isCombo      = false;
                        ShiftCounter = 0;
                        numberOfLineClearInOneRow = ClearLine();
                        AssignBlock(FirstBlock, NextBlock);
                        FirstBlock.Prepare();
                        NextBlock = GenerateBlock();
                        NextBlock.SetBlockType();

                        action = true;
                        //FirstBlock = GenerateBlock();
                        //FirstBlock.Prepare();
                        if (isCombo)
                        {
                            comboLvl++;
                        }
                        if (!isCombo)
                        {
                            comboLvl = 0;
                        }
                    }
                }
                ClickEvent(FirstBlock);
                if (action)
                {
                    UpdateMap();
                    action = false;
                }
                if (comboLvl != 0)
                {
                    point += numberOfLineClearInOneRow * 100 * comboLvl;
                }
                else
                {
                    point += numberOfLineClearInOneRow * 100;
                }
                numberOfLineClearInOneRow = 0;
            }
        }