public void PrepareBoard(int boardSizeX, int boardSizeY) { Console.CursorVisible = false; BoardSizeX = boardSizeX; BoardSizeY = boardSizeY; Point upperLeftCorner = new Point(0, 0, '+'); corneres.Add(upperLeftCorner); Point upperRightCorner = new Point(BoardSizeX + 1, 0, '+'); corneres.Add(upperRightCorner); Point lowerLeftCorner = new Point(0, boardSizeY + 1, '+'); corneres.Add(lowerLeftCorner); Point lowerRightCorner = new Point(boardSizeX + 1, boardSizeY + 1, '+'); corneres.Add(lowerRightCorner); upper = new HorizontalLine(1, boardSizeX, 0, '-'); borders.Add(upper); lower = new HorizontalLine(1, boardSizeX, boardSizeY + 1, '-'); borders.Add(lower); left = new VerticalLine(1, boardSizeY, 0, '|'); borders.Add(left); right = new VerticalLine(1, boardSizeY, boardSizeX + 1, '|'); borders.Add(right); drawAll += DrawBoard; drawAll += CheckIfHitWithWalls; drawAll += DrawHero; drawAll += DrawMines; }
static void Main(string[] args) { var drawCircle = new DrawCircle(); var drawSquare = new DrawSquare(); var draw = new DrawFigure(drawCircle); draw.Draw(); var draw1 = new DrawFigure(drawSquare); draw1.Draw(); }
public void MouseMove(PictureBox sheet, IBrush brush, MouseEventArgs e) { figure.Createdotlist(x1, y1, x2, y2); if (cursorActive == true) { Canva.GetCanva.LoadFromCache(); x2 = e.X; y2 = e.Y; DrawFigure drawer = new DrawFigure(figure, brush); drawer.Draw(); Canva.GetCanva.WriteToPictureBox(sheet); } }
// Ctor. public GameManager(string[] settings, DrawBoard drawBoardDelegate, DrawFigure drawFigureDelegate, GameOverMessage gameOverMessageDelegate, UpdateTimeLimit updateTimeLimitDelegate, DrawBFLimits DrawBFLimitsDelegate) { // Set variables boardSize = int.Parse(settings[0]); stripeLengthToWin = int.Parse(settings[1]); player1Type = (PlayerType)(int.Parse(settings[2])); player2Type = (PlayerType)(int.Parse(settings[3])); deDrawBoard = drawBoardDelegate; deDrawFigure = drawFigureDelegate; deGameOver = gameOverMessageDelegate; deUpdateTimeLimit = updateTimeLimitDelegate; deDrawBFLimits = DrawBFLimitsDelegate; timeLimit = new TimeSpan(0, 0, int.Parse(settings[4])); }
public bool Draw(string userChoice, char[] menuItems) { DrawFigure drawFigure = null; char[] arr = userChoice.ToCharArray(); if (arr.Length < 1 || arr.Length > 4) { return(false); } foreach (char c in arr) { if (!menuItems.Contains(c)) { return(false); } switch (c) { case '1': drawFigure += DrawPoint; break; case '2': drawFigure += DrawHorizontalLine; break; case '3': drawFigure += DrawVerticalLine; break; case '4': try { ClearBoard(); } catch (NullReferenceException e) { } return(true); default: return(false); } } drawFigure(this); return(true); }
public MainForm() { InitializeComponent(); comboBoxFigure.Items.AddRange(new object[] { curveLine, straightLine, rectangle, ellipse }); comboBoxFigure.SelectedIndex = 0; pen = new Pen(labelColorImage.BackColor, (float)numericUpDownWidth.Value); g = panelPainting.CreateGraphics(); DoubleBuffered = true; //Умен. мерцания. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //Сглаживание. pen.StartCap = pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; //Круглое завершение отрезков. figure = DrawCurveLine; }
/// <summary> /// Если меняем фигуру. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxFigure_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxFigure.SelectedItem.ToString() == curveLine) { figure = DrawCurveLine; } else if (comboBoxFigure.SelectedItem.ToString() == straightLine) { figure = DrawStraightLine; } else if (comboBoxFigure.SelectedItem.ToString() == rectangle) { figure = DrawRectangle; } else if (comboBoxFigure.SelectedItem.ToString() == ellipse) { figure = DrawEllipse; } }
/// <summary> /// Main game method /// </summary> public void Run() { bool drawnDot = false, drawnHLine = false, drawnVLine = false, drawnCurve = false; DrawFigure draw = delegate(IBoard board) { }; string inputString = string.Empty; while (inputString.ToLower() != this.gameSettings.ExitCode.ToLower()) { this.inputOutputComponent.Clear(); this.board.Draw(); draw(this.board); this.inputOutputComponent.CursorPosition(0, this.board.BoardSizeY + 1); this.inputOutputComponent.WriteOutputLine(this.phraseProvider.GetPhrase("Welcome")); this.inputOutputComponent.WriteOutputLine(this.phraseProvider.GetPhrase("Exit") + this.gameSettings.ExitCode); inputString = this.inputOutputComponent.ReadInputLine(); switch (inputString) { case "1": draw = (drawnDot == false) ? draw + this.figureProvider.Dot : draw - this.figureProvider.Dot; drawnDot = !drawnDot; break; case "2": draw = (drawnHLine == false) ? draw + this.figureProvider.HorizontalLine : draw - this.figureProvider.HorizontalLine; drawnHLine = !drawnHLine; break; case "3": draw = (drawnVLine == false) ? draw + this.figureProvider.VerticalLine : draw - this.figureProvider.VerticalLine; drawnVLine = !drawnVLine; break; case "4": draw = (drawnCurve == false) ? draw + this.figureProvider.Rectangle : draw - this.figureProvider.Rectangle; drawnCurve = !drawnCurve; break; case "5": this.SetBoardLengthSize(); break; case "6": this.SetBoardWidthSize(); break; default: break; } } this.inputOutputComponent.WriteOutputLine(this.phraseProvider.GetPhrase("End")); this.inputOutputComponent.ReadInputKey(); }