コード例 #1
0
ファイル: GameController.cs プロジェクト: KoTDusic/KoTetris
        private void GenerateFigure()
        {
            IFigure figure = null;

            switch (RandomHelper.Next(0, 6))
            {
            //квадрат
            case 0:
            {
                figure = new FigureI();
                break;
            }

            case 1:
            {
                figure = new FigureJ();
                break;
            }

            case 2:
            {
                figure = new FigureL();
                break;
            }

            case 3:
            {
                figure = new FigureO();
                break;
            }

            case 4:
            {
                figure = new FigureS();
                break;
            }

            case 5:
            {
                figure = new FigureT();
                break;
            }

            case 6:
            {
                figure = new FigureZ();
                break;
            }
            }

            foreach (var pixel in figure.GetGeometry())
            {
                if (_gameField[pixel.X, pixel.Y] != BlockType.Air)
                {
                    StopGame();
                }

                _gameField[pixel.X, pixel.Y] = BlockType.FallingBlock;
            }
        }
コード例 #2
0
ファイル: Tetris.cs プロジェクト: yosha28/TetrisForm
        public IFigure AssortyFigure()
        {
            Random  round     = new Random();
            int     num       = round.Next(1, 5);
            IFigure setFigure = null;
            int     form      = round.Next(1, 8);

            switch (form)
            {
            case 1: setFigure = new FigureJ(); break;

            case 2: setFigure = new FigureL(); break;

            case 3: setFigure = new FigureO(); break;

            case 4: setFigure = new FigureI(); break;

            case 5: setFigure = new FigureT(); break;

            case 6: setFigure = new FigureS(); break;

            case 7: setFigure = new FigureZ(); break;
            }
            setFigure.number = num;
            return(setFigure);
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: kotstreet/tetrisDemo
    /// <summary>
    /// initialize figure list with all figure types
    /// </summary>
    private static void InitializeFigureList()
    {
        //create new figures
        var s = new FigureS();
        var z = new FigureZ();
        var i = new FigureI();
        var o = new FigureO();
        var t = new FigureT();
        var l = new FigureL();
        var j = new FigureJ();

        //create general list
        Figures = new List <Figure>()
        {
            s, z, i, o, l, j, t
        };
    }