Compare commits

..

No commits in common. "lab2" and "master" have entirely different histories.
lab2 ... master

25 changed files with 50 additions and 1438 deletions

View File

@ -1,165 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal abstract class AbstractMap
{
private IDrawingObject _drawingObject = null;
protected int[,] _map = null;
protected int _width;
protected int _height;
protected float _size_x;
protected float _size_y;
protected readonly Random _random = new();
protected readonly int _freeRoad = 0;
protected readonly int _barrier = 1;
public Bitmap CreateMap(int width, int height, IDrawingObject drawingObject)
{
_width = width;
_height = height;
_drawingObject = drawingObject;
GenerateMap();
while (!SetObjectOnMap())
{
GenerateMap();
}
return DrawMapWithObject();
}
public Bitmap MoveObject(Direction direction)
{
bool isFree = true;
int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
int locomotiveWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
int locomotiveHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
switch (direction)
{
// вправо
case Direction.Right:
for (int i = locomotiveWidth; i <= locomotiveWidth + (int)(_drawingObject.Step / _size_x); i++)
{
for (int j = startPosY; j <= locomotiveHeight; j++)
{
if (_map[i, j] == _barrier)
{
isFree = false;
break;
}
}
}
break;
//влево
case Direction.Left:
for (int i = startPosX; i >= (int)(_drawingObject.Step / _size_x); i--)
{
for (int j = startPosY; j <= locomotiveHeight; j++)
{
if (_map[i, j] == _barrier)
{
isFree = false;
break;
}
}
}
break;
//вверх
case Direction.Up:
for (int i = startPosX; i <= locomotiveWidth; i++)
{
for (int j = startPosY; j >= (int)(_drawingObject.Step / _size_y); j--)
{
if (_map[i, j] == _barrier)
{
isFree = false;
break;
}
}
}
break;
//вниз
case Direction.Down:
for (int i = startPosX; i <= locomotiveWidth; i++)
{
for (int j = locomotiveHeight; j <= locomotiveHeight + (int)(_drawingObject.Step / _size_y); j++)
{
if (_map[i, j] == _barrier)
{
isFree = false;
break;
}
}
}
break;
}
if (isFree)
{
_drawingObject.MoveObject(direction);
}
return DrawMapWithObject();
}
private bool SetObjectOnMap()
{
if (_drawingObject == null || _map == null)
{
return false;
}
int x = _random.Next(0, 10);
int y = _random.Next(0, 10);
_drawingObject.SetObject(x, y, _width, _height);
// TODO првоерка, что объект не "накладывается" на закрытые участки
_drawingObject.SetObject(x, y, _width, _height);
int startPosX = (int)(_drawingObject.GetCurrentPosition().Left / _size_x);
int startPosY = (int)(_drawingObject.GetCurrentPosition().Right / _size_y);
int locomotiveWidth = (int)(_drawingObject.GetCurrentPosition().Top / _size_x);
int locomotiveHeight = (int)(_drawingObject.GetCurrentPosition().Bottom / _size_y);
for (int i = startPosX; i <= locomotiveWidth; i++)
{
for (int j = startPosY; j <= locomotiveHeight; j++)
{
if (_map[i, j] == _barrier)
{
return false;
}
}
}
return true;
}
private Bitmap DrawMapWithObject()
{
Bitmap bmp = new Bitmap(_width, _height);
if (_drawingObject == null || _map == null)
{
return bmp;
}
Graphics gr = Graphics.FromImage(bmp);
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
if (_map[i, j] == _freeRoad)
{
DrawRoadPart(gr, i, j);
}
else if (_map[i, j] == _barrier)
{
DrawBarrierPart(gr, i, j);
}
}
}
_drawingObject.DrawingObject(gr);
return bmp;
}
protected abstract void GenerateMap();
protected abstract void DrawRoadPart(Graphics g, int i, int j);
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal enum Direction
{
None = 0,
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -1,193 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class DrawingLocomotive
{
public EntityLocomotive Locomotive { get; protected set; }
protected float _startPosX;
protected float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
private readonly int _locomotiveWidth = 80;
private readonly int _locomotiveHeight = 50;
public void SetPosition(int x, int y, int width, int height)
{
//Сделать проверки (все параметры больше 0 и координаты не выходят за границы полей)
//x
if ((x < 0 || (x + _locomotiveWidth > width)) || (y < 0 || (y + _locomotiveHeight > height)))
{
_startPosX = 0;
_startPosY = 0;
_pictureWidth = width;
_pictureHeight = height;
}
else
{
_startPosX = x;
_startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
}
public void checkMove()
{
if (_startPosX < 0)
{
_startPosX = 0;
}
if (_startPosY < 0)
{
_startPosY = 0;
}
}
public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
return;
}
switch (direction)
{
case Direction.Right:
if (_startPosX + _locomotiveWidth + Locomotive.Step < _pictureWidth)
{
_startPosX += Locomotive.Step;
}
break;
case Direction.Left:
if (_startPosX - _locomotiveWidth - Locomotive.Step < _pictureWidth)
{
_startPosX -= Locomotive.Step;
}
break;
case Direction.Up:
if (_startPosY - _locomotiveHeight - Locomotive.Step < _pictureHeight)
{
_startPosY -= Locomotive.Step;
}
break;
case Direction.Down:
if (_startPosY + _locomotiveHeight + Locomotive.Step < _pictureHeight)
{
_startPosY += Locomotive.Step;
}
break;
}
checkMove();
}
public DrawingLocomotive(int speed, float weight, Color bodyColor)
{
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
}
protected DrawingLocomotive(int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight) :
this(speed, weight, bodyColor)
{
_locomotiveWidth = locomotiveWidth;
_locomotiveHeight = locomotiveHeight;
}
public virtual void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
Pen pen = new(Color.Black);
PointF point1 = new PointF(_startPosX + 20, _startPosY);
PointF point2 = new PointF(_startPosX + 140, _startPosY);
PointF point3 = new PointF(_startPosX + 150, _startPosY + 20);
PointF point4 = new PointF(_startPosX + 150, _startPosY + 40);
PointF point5 = new PointF(_startPosX + 160, _startPosY + 50);
PointF point6 = new PointF(_startPosX + 140, _startPosY + 40);
PointF point7 = new PointF(_startPosX + 20, _startPosY + 40);
PointF point8 = new PointF(_startPosX + 10, _startPosY + 50);
PointF point9 = new PointF(_startPosX + 10, _startPosY + 20);
PointF[] curvePoints =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7,
point8,
point9
};
//кузов покрас
Brush br = new SolidBrush(Locomotive?.BodyColor ?? Color.Orange);
g.FillPolygon(br, curvePoints);
//кузов контур
g.DrawPolygon(pen, curvePoints);
//колёса
Brush brBlack = new SolidBrush(Color.Black);
g.FillEllipse(brBlack, _startPosX + 10, _startPosY + 40, 20, 20);
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 40, 20, 20);
g.FillEllipse(brBlack, _startPosX + 40, _startPosY + 40, 20, 20);
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 40, 20, 20);
g.FillEllipse(brBlack, _startPosX + 90, _startPosY + 40, 20, 20);
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, 20);
g.FillEllipse(brBlack, _startPosX + 120, _startPosY + 40, 20, 20);
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 40, 20, 20);
Brush brBlue = new SolidBrush(Color.Blue);
//window
g.FillRectangle(brBlue, _startPosX + 110, _startPosY + 5, 20, 20);
g.DrawRectangle(pen, _startPosX + 110, _startPosY + 5, 20, 20);
}
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _locomotiveWidth || _pictureHeight <= _locomotiveHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _locomotiveWidth > _pictureWidth)
{
_startPosX = _pictureWidth.Value - _locomotiveWidth;
}
if (_startPosY + _locomotiveHeight > _pictureHeight)
{
_startPosY = _pictureHeight.Value - _locomotiveHeight;
}
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _locomotiveWidth, _startPosY + _locomotiveHeight);
}
}
}

View File

@ -1,59 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class DrawingMonorailLocomotive : DrawingLocomotive
{
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="dopColor">Дополнительный цвет</param>
/// <param name="monorail">Признак наличия магнитного рельса</param>
/// <param name="dopCabin">Признак наличия второй кабины сзади</param>
public DrawingMonorailLocomotive(int speed, float weight, Color bodyColor,
Color dopColor, bool monorail, bool dopCabin) :
base(speed, weight, bodyColor, 110,60)
{
Locomotive = new EntityMonorailLocomotive(speed, weight, bodyColor, dopColor, monorail, dopCabin);
}
public override void DrawTransport(Graphics g)
{
if (Locomotive is not EntityMonorailLocomotive monorailLocomotive)
{
return;
}
Pen pen = new(Color.Black);
Brush dopBrush = new SolidBrush(monorailLocomotive.DopColor);
base.DrawTransport(g);
if (monorailLocomotive.DopCabin)
{
Brush brBlue = new SolidBrush(Color.Blue);
// задняя кабина
g.FillRectangle(brBlue, _startPosX + 25, _startPosY + 5, 20, 20);
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 5, 20, 20);
}
if (monorailLocomotive.Monorail)
{
Brush brBlack = new SolidBrush(Color.Black);
//монорельса
g.FillRectangle(brBlack, _startPosX + 10, _startPosY + 45, 130, 20);
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 45, 130, 20);
}
}
}
}

View File

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class DrawingObjectLocomotive : IDrawingObject
{
private DrawingLocomotive _locomotive = null;
public DrawingObjectLocomotive(DrawingLocomotive locomotive)
{
_locomotive = locomotive;
}
public float Step => _locomotive?.Locomotive?.Step ?? 0;
public (float Left, float Right, float Top, float Bottom)
GetCurrentPosition()
{
return _locomotive?.GetCurrentPosition() ?? default;
}
public void MoveObject(Direction direction)
{
_locomotive?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_locomotive.SetPosition(x, y, width, height);
}
void IDrawingObject.DrawingObject(Graphics g)
{
_locomotive.DrawTransport(g);
}
}
}

View File

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class EntityLocomotive
{
public int Speed { get; private set; }
public float Weight { get; private set; }
public Color BodyColor { get; private set; }
public float Step => Speed * 100 / Weight;
public EntityLocomotive(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class EntityMonorailLocomotive : EntityLocomotive
{
public Color DopColor { get; private set; }
public bool Monorail { get; private set; }
public bool DopCabin { get; private set; }
public EntityMonorailLocomotive(int speed, float weight, Color bodyColor,
Color dopColor, bool monorail, bool dopCabin) :
base(speed,weight,bodyColor)
{
DopColor = dopColor;
Monorail = monorail;
DopCabin = dopCabin;
}
}
}

39
Monorail/Monorail/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,39 @@
namespace Monorail
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -0,0 +1,10 @@
namespace Monorail
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -117,17 +117,4 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@ -1,176 +0,0 @@
namespace Monorail
{
partial class FormLocomotive
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
pictureBoxLocomotive = new PictureBox();
statusStrip = new StatusStrip();
toolStripStatusLabelSpeed = new ToolStripStatusLabel();
toolStripStatusLabelWeight = new ToolStripStatusLabel();
toolStripStatusLabelBodyColor = new ToolStripStatusLabel();
buttonCreate = new Button();
buttonUp = new Button();
buttonLeft = new Button();
buttonRight = new Button();
buttonDown = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
statusStrip.SuspendLayout();
SuspendLayout();
//
// pictureBoxLocomotive
//
pictureBoxLocomotive.Dock = DockStyle.Fill;
pictureBoxLocomotive.Location = new Point(0, 0);
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
pictureBoxLocomotive.Size = new Size(800, 428);
pictureBoxLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxLocomotive.TabIndex = 0;
pictureBoxLocomotive.TabStop = false;
pictureBoxLocomotive.Resize += PictureBoxLocomotive_Resize;
//
// statusStrip
//
statusStrip.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelSpeed, toolStripStatusLabelWeight, toolStripStatusLabelBodyColor });
statusStrip.Location = new Point(0, 428);
statusStrip.Name = "statusStrip";
statusStrip.Size = new Size(800, 22);
statusStrip.TabIndex = 1;
//
// toolStripStatusLabelSpeed
//
toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
toolStripStatusLabelSpeed.Size = new Size(62, 17);
toolStripStatusLabelSpeed.Text = "Скорость:";
//
// toolStripStatusLabelWeight
//
toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
toolStripStatusLabelWeight.Size = new Size(29, 17);
toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
toolStripStatusLabelBodyColor.Size = new Size(36, 17);
toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 390);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(75, 23);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(722, 350);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(30, 30);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(686, 386);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(30, 30);
buttonLeft.TabIndex = 4;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(758, 386);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(30, 30);
buttonRight.TabIndex = 5;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(722, 386);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(30, 30);
buttonDown.TabIndex = 6;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// FormLocomotive
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
Controls.Add(buttonUp);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxLocomotive);
Controls.Add(statusStrip);
Name = "FormLocomotive";
Text = "Локомотив";
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
statusStrip.ResumeLayout(false);
statusStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private PictureBox pictureBoxLocomotive;
private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button buttonUp;
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
}
}

View File

@ -1,88 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Monorail
{
public partial class FormLocomotive : Form
{
private DrawingLocomotive _locomotive;
public FormLocomotive()
{
InitializeComponent();
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_locomotive = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
SetData();
Draw();
}
private void Draw()
{
Bitmap bmp = new(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Graphics gr = Graphics.FromImage(bmp);
_locomotive?.DrawTransport(gr);
pictureBoxLocomotive.Image = bmp;
}
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <summary>
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
//ïîëó÷àåì èìÿ êíîïêè
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_locomotive?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_locomotive?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_locomotive?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_locomotive?.MoveTransport(Direction.Right);
break;
}
Draw();
}
/// <summary>
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PictureBoxLocomotive_Resize(object sender, EventArgs e)
{
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Draw();
}
private void SetData()
{
Random rnd = new();
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_locomotive.Locomotive.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_locomotive.Locomotive.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_locomotive.Locomotive.BodyColor.Name}";
}
}
}

View File

@ -1,63 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,203 +0,0 @@
namespace Monorail
{
partial class FormMap : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
statusStrip1 = new StatusStrip();
toolStripStatusLabelSpeed = new ToolStripStatusLabel();
toolStripStatusLabelWeight = new ToolStripStatusLabel();
toolStripStatusLabelBodyColor = new ToolStripStatusLabel();
pictureBoxLocomotive = new PictureBox();
buttonCreate = new Button();
buttonCreateModify = new Button();
buttonUp = new Button();
buttonLeft = new Button();
buttonRight = new Button();
buttonDown = new Button();
comboBoxSelectorMap = new ComboBox();
statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
SuspendLayout();
//
// statusStrip1
//
statusStrip1.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelSpeed, toolStripStatusLabelWeight, toolStripStatusLabelBodyColor });
statusStrip1.Location = new Point(0, 428);
statusStrip1.Name = "statusStrip1";
statusStrip1.Size = new Size(800, 22);
statusStrip1.TabIndex = 0;
statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
toolStripStatusLabelSpeed.Size = new Size(62, 17);
toolStripStatusLabelSpeed.Text = "Скорость:";
//
// toolStripStatusLabelWeight
//
toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
toolStripStatusLabelWeight.Size = new Size(29, 17);
toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
toolStripStatusLabelBodyColor.Size = new Size(36, 17);
toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// pictureBoxLocomotive
//
pictureBoxLocomotive.Dock = DockStyle.Fill;
pictureBoxLocomotive.Location = new Point(0, 0);
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
pictureBoxLocomotive.Size = new Size(800, 428);
pictureBoxLocomotive.TabIndex = 1;
pictureBoxLocomotive.TabStop = false;
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 386);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(101, 25);
buttonCreate.TabIndex = 2;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCreateModify
//
buttonCreateModify.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateModify.Location = new Point(138, 386);
buttonCreateModify.Name = "buttonCreateModify";
buttonCreateModify.Size = new Size(139, 25);
buttonCreateModify.TabIndex = 3;
buttonCreateModify.Text = "Модифицировать";
buttonCreateModify.UseVisualStyleBackColor = true;
buttonCreateModify.Click += ButtonCreateModify_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
buttonUp.Location = new Point(722, 350);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(30, 30);
buttonUp.TabIndex = 4;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
buttonLeft.Location = new Point(686, 386);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(30, 30);
buttonLeft.TabIndex = 5;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
buttonRight.Location = new Point(758, 386);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(30, 30);
buttonRight.TabIndex = 6;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
buttonDown.Location = new Point(722, 386);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(30, 30);
buttonDown.TabIndex = 7;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// comboBoxSelectorMap
//
comboBoxSelectorMap.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorMap.FormattingEnabled = true;
comboBoxSelectorMap.Items.AddRange(new object[] { "SimpleMap" });
comboBoxSelectorMap.Location = new Point(12, 12);
comboBoxSelectorMap.Name = "comboBoxSelectorMap";
comboBoxSelectorMap.Size = new Size(121, 23);
comboBoxSelectorMap.TabIndex = 8;
comboBoxSelectorMap.SelectedIndexChanged += ComboBoxSelectorMap_SelectedIndexChanged;
comboBoxSelectorMap.Click += ComboBoxSelectorMap_SelectedIndexChanged;
//
// FormMap
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(comboBoxSelectorMap);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
Controls.Add(buttonUp);
Controls.Add(buttonCreateModify);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxLocomotive);
Controls.Add(statusStrip1);
Name = "FormMap";
Text = "Карта";
statusStrip1.ResumeLayout(false);
statusStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private PictureBox pictureBoxLocomotive;
private Button buttonCreate;
private Button buttonCreateModify;
private Button buttonUp;
private Button buttonLeft;
private Button buttonRight;
private Button buttonDown;
private ComboBox comboBoxSelectorMap;
}
}

View File

@ -1,98 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Monorail
{
public partial class FormMap : Form
{
private AbstractMap _abstractMap;
public FormMap()
{
InitializeComponent();
_abstractMap = new SimpleMap();
}
private void SetData(DrawingLocomotive locomotive)
{
toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
pictureBoxLocomotive.Image = _abstractMap.CreateMap(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height,
new DrawingObjectLocomotive(locomotive));
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
var car = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
SetData(car);
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
Direction dir = Direction.None;
switch (name)
{
case "buttonUp":
dir = Direction.Up;
break;
case "buttonDown":
dir = Direction.Down;
break;
case "buttonLeft":
dir = Direction.Left;
break;
case "buttonRight":
dir = Direction.Right;
break;
}
pictureBoxLocomotive.Image = _abstractMap?.MoveObject(dir);
}
/// <summary>
/// Обработка нажатия кнопки "Модификация"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateModify_Click(object sender, EventArgs e)
{
Random rnd = new();
var locomotive = new DrawingMonorailLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData(locomotive);
}
/// <summary>
/// Смена карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorMap.Text)
{
case "Простая карта":
_abstractMap = new SimpleMap();
break;
}
}
}
}

View File

@ -1,63 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal interface IDrawingObject
{
/// <summary>
/// Шаг перемещения объекта
/// </summary>
public float Step { get; }
/// <summary>
/// Установка позиции объекта
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина полотна</param>
/// <param name="height">Высота полотна</param>
void SetObject(int x, int y, int width, int height);
/// <summary>
/// Изменение направления пермещения объекта
/// </summary>
/// <param name="direction">Направление</param>
/// <returns></returns>
void MoveObject(Direction direction);
/// <summary>
/// Отрисовка объекта
/// </summary>
/// <param name="g"></param>
void DrawingObject(Graphics g);
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
}
}

View File

@ -8,19 +8,4 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

@ -11,7 +11,7 @@ namespace Monorail
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormMap()); Application.Run(new Form1());
} }
} }
} }

View File

@ -1,103 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Monorail.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Monorail.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowDown {
get {
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowLeft {
get {
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight {
get {
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowUp {
get {
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

View File

@ -1,48 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Monorail
{
internal class SimpleMap : AbstractMap
{
private readonly Brush barrierColor = new SolidBrush(Color.Black);
private readonly Brush roadColor = new SolidBrush(Color.Gray);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x), j * (_size_y));
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x), j * (_size_y));
}
protected override void GenerateMap()
{
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
while (counter < 50)
{
int x = _random.Next(0, 100);
int y = _random.Next(0, 100);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}