Example #1
0
 private void OnFigureLanding()
 {
     IncreaseScore(10);
     fallingFigure         = Tetromino.CreateFigure(NextFallingFigureType, FallingFigureSpawnPosition);
     NextFallingFigureType = Tetromino.GetRandomType();
     holdButtonAlredyUse   = false;
     if (FigureLanded != null)
     {
         FigureLanded.Invoke(this, new EventArgs());
     }
 }
Example #2
0
        public void DrawNextFigureContainer(Graphics graphics, Vector position)
        {
            var nextFigureRect = new Rectangle((Point)position, new Size(Block.Size * 5, Block.Size * 5));

            graphics.DrawString("NEXT", new Font(FontFamily.GenericMonospace, 30), Brushes.White, (Point) new Vector(nextFigureRect.X - 4, nextFigureRect.Y - Block.Size * 2));
            graphics.FillRectangle(new SolidBrush(FieldsBackGroundColor), nextFigureRect);
            graphics.DrawRectangle(Pens.White, nextFigureRect);
            foreach (var block in Tetromino.CreateFigure(Model.NextFallingFigureType, new Vector(nextFigureRect.X + Block.Size * 2, nextFigureRect.Y + Block.Size * 2)).Blocks)
            {
                DrawBlock(graphics, Brushes.Aqua, new Vector(block.Position.X, block.Position.Y), new Size(Block.Size, Block.Size));
            }
        }
Example #3
0
        public void DrawHoldFigureContainer(Graphics graphics, Vector position)
        {
            var holdFigureRect = new Rectangle((Point)position, new Size(Block.Size * 5, Block.Size * 5));

            graphics.DrawString("HOLD", new Font(FontFamily.GenericMonospace, 30), Brushes.White, (Point) new Vector(holdFigureRect.X - 4, holdFigureRect.Y - Block.Size * 2));
            graphics.FillRectangle(new SolidBrush(FieldsBackGroundColor), holdFigureRect);
            graphics.DrawRectangle(Pens.White, holdFigureRect);
            if (Model.HoldedFallingFigureType != null)
            {
                foreach (var block in Tetromino.CreateFigure(Model.HoldedFallingFigureType.Value, new Vector(holdFigureRect.X + Block.Size * 2, holdFigureRect.Y + Block.Size * 2)).Blocks)
                {
                    DrawBlock(graphics, Brushes.Orange, new Vector(block.Position.X, block.Position.Y), new Size(Block.Size, Block.Size));
                }
            }
        }
Example #4
0
 private void HoldFallingFigure()
 {
     if (HoldedFallingFigureType != null)
     {
         var temp = fallingFigure.Type;
         fallingFigure           = Tetromino.CreateFigure(HoldedFallingFigureType.Value, FallingFigureSpawnPosition);
         HoldedFallingFigureType = temp;
     }
     else
     {
         HoldedFallingFigureType = fallingFigure.Type;
         fallingFigure           = Tetromino.CreateFigure(NextFallingFigureType, FallingFigureSpawnPosition);
     }
     NextFallingFigureType = Tetromino.GetRandomType();
     holdButtonAlredyUse   = true;
 }