Ejemplo n.º 1
0
        //установки  по умолчанию
        public void resetGame()
        {
            timer.Interval = timerSlow;
            cell           = new int[mX, mY];
            cellBuffer     = new int[mX, mY];
            brushCells();
            arrayCopy(ref cellBuffer, cell);
            xfig      = 0;
            yfig      = 0;
            generate  = false;
            activeKey = false;
            game      = false;
            Random r = new Random();

            soundPlayer = new fSounds();
            nextFigure  = r.Next(0, 7);
            point       = 0;
            level       = 1;
            timerSlow   = 700;

            if (saveProcess.ifSave(ref options))
            {
                saved = true;
            }
            else
            {
                saved = false;
            }

            options = new saveProcess.saveOptions();
            if (timer.Enabled)
            {
                остановитьИгруToolStripMenuItem.Enabled = true;
                паузаToolStripMenuItem.Enabled          = true;
            }
            else
            {
                остановитьИгруToolStripMenuItem.Enabled = false;
                паузаToolStripMenuItem.Enabled          = false;
            }
        }
Ejemplo n.º 2
0
        //меню, сохранить игру
        private void сохранитьИгруToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!saved)
            {
                options.coords = new WiHd(mX, mY);
                options.cells  = cellBuffer;
                options.x      = xfig;
                options.y      = yfig;
                options.level  = level;
                options.point  = point;
                options.timer  = timer.Interval;
                options.fc     = getFigureColor();
                options.nfc    = getNextFigureColor();
                saveProcess.saveToFile(options);
                сохранитьИгруToolStripMenuItem.Text = Resources.restore_game;
                toolStripButton5.Text = Resources.restore_game;
                очиститьСохранениеToolStripMenuItem.Visible = true;
                toolStripButton6.Visible = true;
                saved = true;
            }
            else
            {
                saveProcess.saveOptions s = new saveProcess.saveOptions();
                if (saveProcess.ifSave(ref s))
                {
                    // resetGame();
                    defaultOptions(s.coords.eX, s.coords.eY);
                    game      = true;
                    generate  = true;
                    activeKey = true;
                    Focus();
                    timer.Enabled  = true;
                    mX             = s.coords.eX;
                    mY             = s.coords.eY;
                    cellBuffer     = s.cells;
                    xfig           = s.x;
                    yfig           = s.y;
                    saved          = true;
                    point          = s.point;
                    level          = s.level;
                    nextFigure     = s.nextFigure;
                    timer.Interval = s.timer;
                    timerSlow      = s.timer;
                    generateFigure(s.figure, ref figure, ref coords, ref s.fc);
                    label1.Visible = false;
                    остановитьИгруToolStripMenuItem.Enabled = true;
                    паузаToolStripMenuItem.Enabled          = true;

                    int[,] nFig = new int[3, 3];
                    WiHd c = new WiHd(0, 0);

                    generateFigure(s.nextFigure, ref nFig, ref c, ref s.nfc);

                    arrayCopy(ref cell, cellBuffer);
                    drawNextFigure(nFig, c);
                    drawCells();
                }
                else
                {
                    очиститьСохранениеToolStripMenuItem_Click(null, null);
                }
            }
        }