Compare commits
1 Commits
f2a5a88b78
...
master
Author | SHA1 | Date | |
---|---|---|---|
22bf4e7e22 |
@ -1,171 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
internal abstract class AbstractMap
|
|
||||||
{
|
|
||||||
private IDrawningObject _drawningObject = 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, IDrawningObject
|
|
||||||
drawningObject)
|
|
||||||
{
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
_drawningObject = drawningObject;
|
|
||||||
GenerateMap(); // abstract void
|
|
||||||
while (!SetObjectOnMap())
|
|
||||||
{
|
|
||||||
GenerateMap();
|
|
||||||
}
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
// added logic must be checked!
|
|
||||||
bool isFree = true;
|
|
||||||
|
|
||||||
int startPosX = (int)(_drawningObject.GetCurrentPosition().Left / _size_x);
|
|
||||||
int startPosY = (int)(_drawningObject.GetCurrentPosition().Top / _size_y);
|
|
||||||
|
|
||||||
int objectWidth = (int)(_drawningObject.GetCurrentPosition().Right / _size_x);
|
|
||||||
int objectHeight = (int)(_drawningObject.GetCurrentPosition().Bottom / _size_y);
|
|
||||||
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case Direction.Right:
|
|
||||||
for (int i = objectWidth; i <= objectWidth + (int)(_drawningObject.Step / _size_x); i++)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j <= objectHeight; j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Direction.Left:
|
|
||||||
for (int i = startPosX; i >= (int)(_drawningObject.Step / _size_x); i--)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j <= objectHeight; j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Direction.Up:
|
|
||||||
for (int i = startPosX; i <= objectWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = startPosY; j >= (int)(_drawningObject.Step / _size_y); j--)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Direction.Down:
|
|
||||||
for (int i = startPosX; i <= objectWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = objectHeight; j <= objectHeight + (int)(_drawningObject.Step / _size_y); j++)
|
|
||||||
{
|
|
||||||
if (_map[i, j] == _barrier)
|
|
||||||
{
|
|
||||||
isFree = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isFree)
|
|
||||||
{
|
|
||||||
_drawningObject.MoveObject(direction);
|
|
||||||
}
|
|
||||||
return DrawMapWithObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool SetObjectOnMap()
|
|
||||||
{
|
|
||||||
if (_drawningObject == null || _map == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int x = _random.Next(0, 10);
|
|
||||||
int y = _random.Next(0, 10);
|
|
||||||
_drawningObject.SetObject(x, y, _width, _height);
|
|
||||||
|
|
||||||
// added logic must be checked!
|
|
||||||
|
|
||||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
|
||||||
{
|
|
||||||
if (i * _size_x >= x && j * _size_y >= y &&
|
|
||||||
i * _size_x <= x + _drawningObject.GetCurrentPosition().Right &&
|
|
||||||
j * _size_y <= j + _drawningObject.GetCurrentPosition().Bottom)
|
|
||||||
{
|
|
||||||
if (_map[i,j] == _barrier)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Bitmap DrawMapWithObject()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_width, _height);
|
|
||||||
if (_drawningObject == 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_drawningObject.DrawningObject(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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,7 +9,6 @@ namespace Locomotive
|
|||||||
//Направление перемещения
|
//Направление перемещения
|
||||||
internal enum Direction
|
internal enum Direction
|
||||||
{
|
{
|
||||||
None = 0,
|
|
||||||
Up = 1,
|
Up = 1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
Left = 3,
|
Left = 3,
|
||||||
|
@ -10,11 +10,11 @@ namespace Locomotive
|
|||||||
internal class DrawningLocomotive
|
internal class DrawningLocomotive
|
||||||
{
|
{
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
public EntityLocomotive Locomotive { get; protected set; }
|
public EntityLocomotive Locomotive { get; private set; }
|
||||||
/// Левая координата отрисовки локомотива
|
/// Левая координата отрисовки локомотива
|
||||||
protected float _startPosX;
|
private float _startPosX;
|
||||||
/// Верхняя координата отрисовки локомотива
|
/// Верхняя координата отрисовки локомотива
|
||||||
protected float _startPosY;
|
private float _startPosY;
|
||||||
/// Ширина окна отрисовки
|
/// Ширина окна отрисовки
|
||||||
private int? _pictureWidth = null;
|
private int? _pictureWidth = null;
|
||||||
/// Высота окна отрисовки
|
/// Высота окна отрисовки
|
||||||
@ -25,19 +25,11 @@ namespace Locomotive
|
|||||||
private readonly int _locomotiveHeight = 50;
|
private readonly int _locomotiveHeight = 50;
|
||||||
|
|
||||||
/// Инициализация свойств
|
/// Инициализация свойств
|
||||||
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor, EntityLocomotive entity)
|
||||||
{
|
{
|
||||||
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
Locomotive = entity;
|
||||||
|
Locomotive.Init(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Новый конструктор
|
|
||||||
protected DrawningLocomotive (int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight)
|
|
||||||
: this (speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
_locomotiveWidth = locomotiveWidth;
|
|
||||||
_locomotiveHeight = locomotiveHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Установка позиции локомотива
|
/// Установка позиции локомотива
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
@ -98,7 +90,7 @@ namespace Locomotive
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
public void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_startPosX < 0 || _startPosY < 0
|
if (_startPosX < 0 || _startPosY < 0
|
||||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
@ -107,7 +99,7 @@ namespace Locomotive
|
|||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
//тело
|
//тело
|
||||||
g.DrawRectangle(pen, _startPosX , _startPosY, 110 - 10, 50 - 10);
|
g.DrawRectangle(pen, _startPosX , _startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10);
|
||||||
//окна
|
//окна
|
||||||
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10);
|
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 10, _startPosY + 10, 10, 10);
|
||||||
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 30, _startPosY + 10, 10, 10);
|
g.FillRectangle(new SolidBrush(Locomotive?.BodyColor ?? Color.Black), _startPosX + 30, _startPosY + 10, 10, 10);
|
||||||
@ -142,10 +134,5 @@ namespace Locomotive
|
|||||||
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение текущей позиции объекта
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
||||||
{
|
|
||||||
return (_startPosX, _startPosX + _locomotiveWidth, _startPosY, _startPosY + _locomotiveHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
internal class DrawningObjectLocomotive : IDrawningObject
|
|
||||||
{
|
|
||||||
private DrawningLocomotive _locomotive = null;
|
|
||||||
|
|
||||||
public DrawningObjectLocomotive(DrawningLocomotive locomotive)
|
|
||||||
{
|
|
||||||
_locomotive = locomotive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Step => _locomotive?.Locomotive?.Step ?? 0;
|
|
||||||
|
|
||||||
public void DrawningObject(Graphics g)
|
|
||||||
{
|
|
||||||
_locomotive?.DrawTransport(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
internal class DrawningWarmlyLocomotive : DrawningLocomotive
|
|
||||||
{
|
|
||||||
public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, Color extraColor, bool pipe, bool storage)
|
|
||||||
: base(speed, weight, bodyColor, locomotiveWidth: 130, locomotiveHeight: 70)
|
|
||||||
{
|
|
||||||
Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (Locomotive is not EntityWarmlyLocomotive warmlyLocomotive)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush extraBrush = new SolidBrush(warmlyLocomotive.ExtraColor);
|
|
||||||
|
|
||||||
|
|
||||||
if (warmlyLocomotive.FuelStorage)
|
|
||||||
{
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 10, _startPosY, 30, 20);
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 60, _startPosY, 20, 20);
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 60, _startPosY + 10, 30, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (warmlyLocomotive.Pipe)
|
|
||||||
{
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 110, _startPosY + 10, 10, 50);
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 110, _startPosY + 40, 20, 20);
|
|
||||||
g.FillRectangle(extraBrush, _startPosX + 100, _startPosY, 30, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
_startPosY += 20;
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
|
||||||
|
|
||||||
_startPosY -= 20;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
internal class EntityWarmlyLocomotive : EntityLocomotive
|
|
||||||
{
|
|
||||||
//доп. цвет
|
|
||||||
public Color ExtraColor { get; private set; }
|
|
||||||
//признак наличия трубы
|
|
||||||
public bool Pipe { get; private set; }
|
|
||||||
//признак наличия отсека под топливо
|
|
||||||
public bool FuelStorage { get; private set; }
|
|
||||||
|
|
||||||
public EntityWarmlyLocomotive (int speed, float weight, Color bodyColor, Color extraColor, bool pipe, bool fuelStorage)
|
|
||||||
: base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
ExtraColor = extraColor;
|
|
||||||
Pipe = pipe;
|
|
||||||
FuelStorage = fuelStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,7 @@ namespace Locomotive
|
|||||||
/// Шаг перемещения локомотива
|
/// Шаг перемещения локомотива
|
||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
public EntityLocomotive(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
14
Locomotive/Locomotive/FormLocomotive.Designer.cs
generated
14
Locomotive/Locomotive/FormLocomotive.Designer.cs
generated
@ -38,7 +38,6 @@
|
|||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonCreateModified = new System.Windows.Forms.Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -52,6 +51,7 @@
|
|||||||
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
this.pictureBoxLocomotive.TabIndex = 0;
|
this.pictureBoxLocomotive.TabIndex = 0;
|
||||||
this.pictureBoxLocomotive.TabStop = false;
|
this.pictureBoxLocomotive.TabStop = false;
|
||||||
|
|
||||||
this.pictureBoxLocomotive.Resize += new System.EventHandler(this.pictureBoxLocomotive_Resize);
|
this.pictureBoxLocomotive.Resize += new System.EventHandler(this.pictureBoxLocomotive_Resize);
|
||||||
//
|
//
|
||||||
// statusStrip1
|
// statusStrip1
|
||||||
@ -144,22 +144,11 @@
|
|||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonCreateModified
|
|
||||||
//
|
|
||||||
this.buttonCreateModified.Location = new System.Drawing.Point(112, 377);
|
|
||||||
this.buttonCreateModified.Name = "buttonCreateModified";
|
|
||||||
this.buttonCreateModified.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCreateModified.TabIndex = 7;
|
|
||||||
this.buttonCreateModified.Text = "Modified";
|
|
||||||
this.buttonCreateModified.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateModified.Click += new System.EventHandler(this.buttonCreateModified_Click);
|
|
||||||
//
|
|
||||||
// FormLocomotive
|
// FormLocomotive
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(778, 442);
|
this.ClientSize = new System.Drawing.Size(778, 442);
|
||||||
this.Controls.Add(this.buttonCreateModified);
|
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@ -189,6 +178,5 @@
|
|||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonCreateModified;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ namespace Locomotive
|
|||||||
public partial class FormLocomotive : Form
|
public partial class FormLocomotive : Form
|
||||||
{
|
{
|
||||||
private DrawningLocomotive _locomotive;
|
private DrawningLocomotive _locomotive;
|
||||||
|
private EntityLocomotive _entity;
|
||||||
|
|
||||||
public FormLocomotive()
|
public FormLocomotive()
|
||||||
{
|
{
|
||||||
@ -18,19 +19,16 @@ namespace Locomotive
|
|||||||
pictureBoxLocomotive.Image = bmp;
|
pictureBoxLocomotive.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData()
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Speed: {_locomotive.Locomotive.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Weight: {_locomotive.Locomotive.Weight}";
|
|
||||||
toolStripStatusLabelColor.Text = $"Color: {_locomotive.Locomotive.BodyColor.Name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_locomotive = new DrawningLocomotive();
|
||||||
|
_entity = new EntityLocomotive();
|
||||||
|
_locomotive.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), _entity);
|
||||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||||
SetData();
|
toolStripStatusLabelSpeed.Text = $"Speed: {_locomotive.Locomotive.Speed}";
|
||||||
|
toolStripStatusLabelWeight.Text = $"Weight: {_locomotive.Locomotive.Weight}";
|
||||||
|
toolStripStatusLabelColor.Text = $"Color: {_locomotive.Locomotive.BodyColor.Name}";
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,19 +59,5 @@ namespace Locomotive
|
|||||||
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateModified_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
_locomotive = new DrawningWarmlyLocomotive(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)));
|
|
||||||
|
|
||||||
_locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
SetData();
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
207
Locomotive/Locomotive/FormMap.Designer.cs
generated
207
Locomotive/Locomotive/FormMap.Designer.cs
generated
@ -1,207 +0,0 @@
|
|||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
partial class FormMap
|
|
||||||
{
|
|
||||||
/// <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.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
|
|
||||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
|
||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateModified = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxLocomotive
|
|
||||||
//
|
|
||||||
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
|
||||||
this.pictureBoxLocomotive.Size = new System.Drawing.Size(778, 416);
|
|
||||||
this.pictureBoxLocomotive.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.pictureBoxLocomotive.TabIndex = 0;
|
|
||||||
this.pictureBoxLocomotive.TabStop = false;
|
|
||||||
//
|
|
||||||
// statusStrip1
|
|
||||||
//
|
|
||||||
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
|
||||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripStatusLabelSpeed,
|
|
||||||
this.toolStripStatusLabelWeight,
|
|
||||||
this.toolStripStatusLabelColor});
|
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 416);
|
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(778, 26);
|
|
||||||
this.statusStrip1.TabIndex = 1;
|
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(51, 20);
|
|
||||||
this.toolStripStatusLabelSpeed.Text = "Speed";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(56, 20);
|
|
||||||
this.toolStripStatusLabelWeight.Text = "Weight";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelColor
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
|
|
||||||
this.toolStripStatusLabelColor.Size = new System.Drawing.Size(45, 20);
|
|
||||||
this.toolStripStatusLabelColor.Text = "Color";
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(12, 377);
|
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCreate.TabIndex = 2;
|
|
||||||
this.buttonCreate.Text = "Create ";
|
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonUp.BackgroundImage = global::Locomotive.Properties.Resources.up_arrow;
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(680, 320);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
|
||||||
this.buttonUp.TabIndex = 3;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonLeft.BackgroundImage = global::Locomotive.Properties.Resources.left_arrow;
|
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(634, 366);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
|
||||||
this.buttonLeft.TabIndex = 4;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDown.BackgroundImage = global::Locomotive.Properties.Resources.down_arrow;
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(680, 366);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
|
||||||
this.buttonDown.TabIndex = 5;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonRight.BackgroundImage = global::Locomotive.Properties.Resources.right_arrow;
|
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(726, 366);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
|
||||||
this.buttonRight.TabIndex = 6;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonCreateModified
|
|
||||||
//
|
|
||||||
this.buttonCreateModified.Location = new System.Drawing.Point(112, 377);
|
|
||||||
this.buttonCreateModified.Name = "buttonCreateModified";
|
|
||||||
this.buttonCreateModified.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCreateModified.TabIndex = 7;
|
|
||||||
this.buttonCreateModified.Text = "Modified";
|
|
||||||
this.buttonCreateModified.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateModified.Click += new System.EventHandler(this.buttonCreateModified_Click);
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// FormMap
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(778, 442);
|
|
||||||
this.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.Controls.Add(this.buttonCreateModified);
|
|
||||||
this.Controls.Add(this.buttonRight);
|
|
||||||
this.Controls.Add(this.buttonDown);
|
|
||||||
this.Controls.Add(this.buttonLeft);
|
|
||||||
this.Controls.Add(this.buttonUp);
|
|
||||||
this.Controls.Add(this.buttonCreate);
|
|
||||||
this.Controls.Add(this.pictureBoxLocomotive);
|
|
||||||
this.Controls.Add(this.statusStrip1);
|
|
||||||
this.Name = "FormMap";
|
|
||||||
this.Text = "Map";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
|
|
||||||
this.statusStrip1.ResumeLayout(false);
|
|
||||||
this.statusStrip1.PerformLayout();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxLocomotive;
|
|
||||||
private StatusStrip statusStrip1;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelColor;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonCreateModified;
|
|
||||||
private ComboBox comboBoxSelectorMap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +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 Locomotive
|
|
||||||
{
|
|
||||||
public partial class FormMap : Form
|
|
||||||
{
|
|
||||||
private AbstractMap _abstractMap;
|
|
||||||
public FormMap()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Заполнение информации по объекту
|
|
||||||
private void SetData(DrawningLocomotive locomotive)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
|
|
||||||
toolStripStatusLabelColor.Text = $"Цвет: { locomotive.Locomotive.BodyColor.Name}";
|
|
||||||
pictureBoxLocomotive.Image = _abstractMap.CreateMap(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height,
|
|
||||||
new DrawningObjectLocomotive(locomotive));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
SetData(car);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Изменение размеров формы
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Обработка нажатия кнопки "Модификация"
|
|
||||||
private void buttonCreateModified_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrawningWarmlyLocomotive(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(car);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Смена карты
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
|
|
||||||
EventArgs e)
|
|
||||||
{
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
internal interface IDrawningObject
|
|
||||||
{
|
|
||||||
/// Шаг перемещения объекта
|
|
||||||
public float Step { get; }
|
|
||||||
/// Установка позиции объекта
|
|
||||||
void SetObject(int x, int y, int width, int height);
|
|
||||||
/// Изменение направления перемещения объекта
|
|
||||||
void MoveObject(Direction direction);
|
|
||||||
/// Отрисовка объекта
|
|
||||||
void DrawningObject(Graphics g);
|
|
||||||
/// Получение текущей позиции объекта
|
|
||||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace Locomotive
|
|||||||
// 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 FormLocomotive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Locomotive
|
|
||||||
{
|
|
||||||
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 +
|
|
||||||
1), j * (_size_y + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
|
||||||
{
|
|
||||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x +
|
|
||||||
1), j * (_size_y + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user