Предсозранение

This commit is contained in:
Данила Селяев 2022-09-25 22:51:54 +04:00
parent b9ca34ea50
commit 1875b078de
9 changed files with 520 additions and 53 deletions

View File

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Locomative
{
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();
while (!SetObjectOnMap())
{
GenerateMap();
}
return DrawMapWithObject();
}
public Bitmap MoveObject(Direction direction)
{
//to do проверка что обьект может передвинуться в указанном направлении
if (true)
{
_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);
//to do порверка что обьект не накладывается на закрытые участки
return true;
}
private Bitmap DrawMapWithObject()
{
Bitmap bmp = new(_width, _height);
if(_drawningObject ==null || bmp == 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)
{
DrawRailPart(gr, i, j);
}
else if (_map[i, j] == _barrier)
{
DrawBarrielPart(gr, i, j);
}
}
}
_drawningObject.DrawningObject(gr);
return bmp;
}
protected abstract void GenerateMap();
protected abstract void DrawRailPart(Graphics g, int i, int j);
protected abstract void DrawBarrielPart(Graphics g, int i, int j);
}
}

View File

@ -19,62 +19,44 @@ namespace Locomative
{
return;
}
//кисти
Pen pen = new(Color.Black);
Brush brWhite = new SolidBrush(Color.White);
Brush bodyBrush = new SolidBrush(fastLocomative.BodyColor);
Brush dopBrush = new SolidBrush(fastLocomative.DopColor);
Brush brBlack = new SolidBrush(Color.Black);
if (fastLocomative.BodyKit)
{
//кисти
Brush brGray = new SolidBrush(Color.Gray);
Brush brBlack = new SolidBrush(Color.Black);
//Платформа поезда
g.FillRectangle(brBlack, _startPosX, _startPosY, 90, 40);
//котёл
g.FillRectangle(dopBrush, _startPosX + 30, _startPosY + 10, 60, 20);
g.DrawLine(pen, _startPosX + 30, _startPosY + 10, _startPosX + 70, _startPosY + 10);
g.DrawLine(pen, _startPosX + 70, _startPosY + 10, _startPosX + 70, _startPosY + 30);
g.DrawLine(pen, _startPosX + 70, _startPosY + 30, _startPosX + 30, _startPosY + 30);
g.DrawLine(pen, _startPosX + 30, _startPosY + 30, _startPosX + 30, _startPosY + 10);
//крыша поезда
g.FillRectangle(bodyBrush, _startPosX - 2, _startPosY - 2, 34, 44);
g.DrawLine(pen, _startPosX - 2, _startPosY - 2, _startPosX + 32, _startPosY - 2);
g.DrawLine(pen, _startPosX + 32, _startPosY - 2, _startPosX + 32, _startPosY + 42);
g.DrawLine(pen, _startPosX + 32, _startPosY + 42, _startPosX - 2, _startPosY + 42);
g.DrawLine(pen, _startPosX - 2, _startPosY + 42, _startPosX - 2, _startPosY - 2);
//трубы
g.FillEllipse(brGray, _startPosX + 36, _startPosY + 16, 8, 8);
g.FillEllipse(brBlack, _startPosX + 35, _startPosY + 15, 10, 10);
g.FillEllipse(brGray, _startPosX + 56, _startPosY + 16, 8, 8);
g.FillEllipse(brBlack, _startPosX + 55, _startPosY + 15, 10, 10);
g.FillEllipse(brGray, _startPosX + 70, _startPosY + 10, 20, 20);
g.FillEllipse(brBlack, _startPosX + 73, _startPosY + 13, 14, 14);
//бампер
Point point1 = new Point(Convert.ToInt32(_startPosX + 90), Convert.ToInt32(_startPosY));
Point point2 = new Point(Convert.ToInt32(_startPosX + 110), Convert.ToInt32(_startPosY + 20));
Point point3 = new Point(Convert.ToInt32(_startPosX + 90), Convert.ToInt32(_startPosY + 40));
Point[] points = { point1, point2, point3 };
g.FillPolygon(brGray, points);
//поезд
g.FillRectangle(brWhite, _startPosX, _startPosY, 120, 40);
g.DrawRectangle(pen, _startPosX, _startPosY, 120, 40);
//окно
g.FillRectangle(bodyBrush, _startPosX+90, _startPosY+5, 20, 30);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 5, 20, 30);
//верхние края
g.DrawLine(pen, _startPosX, _startPosY + 5, _startPosX + 90, _startPosY + 5);
g.DrawLine(pen, _startPosX, _startPosY + 35, _startPosX + 90, _startPosY + 35);
//отверстие под рельсы
Point point1 = new Point(Convert.ToInt32(_startPosX + 120), Convert.ToInt32(_startPosY + 4));
Point point2 = new Point(Convert.ToInt32(_startPosX + 115), Convert.ToInt32(_startPosY + 8));
Point point3 = new Point(Convert.ToInt32(_startPosX + 115), Convert.ToInt32(_startPosY + 32));
Point point4 = new Point(Convert.ToInt32(_startPosX + 120), Convert.ToInt32(_startPosY + 36));
Point[] points = { point1, point2, point3, point4 };
g.FillPolygon(brBlack, points);
}
//ракетная труба сзади
if (fastLocomative.RocketToobe)
//вторая кабина
if (fastLocomative.Room)
{
g.FillRectangle(brWhite, _startPosX-125, _startPosY, 120, 40);
g.DrawRectangle(pen, _startPosX-125, _startPosY, 120, 40);
g.DrawRectangle(pen, _startPosX-5, _startPosY+18, 5, 4);
}
//Гребешок
if (fastLocomative.Wing)
{
Brush brGray = new SolidBrush(Color.Black);
g.FillRectangle(brGray, _startPosX-20, _startPosY, 20, 40);
}
//бамперы слева и справа
if (fastLocomative.RocketToobe)
{
//слева
g.DrawLine(pen, _startPosX, _startPosY-5, _startPosX + 80, _startPosY-5);
g.DrawLine(pen, _startPosX+10, _startPosY - 5, _startPosX+10, _startPosY -2);
g.DrawLine(pen, _startPosX+70, _startPosY - 5, _startPosX + 70, _startPosY);
//справа
g.DrawLine(pen, _startPosX, _startPosY+45, _startPosX + 80, _startPosY+45);
g.DrawLine(pen, _startPosX + 10, _startPosY + 45, _startPosX + 10, _startPosY + 42);
g.DrawLine(pen, _startPosX + 70, _startPosY + 45, _startPosX + 70, _startPosY + 40);
}
}
}
}

View File

@ -31,11 +31,11 @@ namespace Locomative
if (width < 120 || height < 50) return;
if (x > width - _locoWidth)
{
x = rnd1.Next(10, width - _locoWidth - 1);
x = rnd1.Next(120, width - _locoWidth - 1);
}
if( y > height- _locoHeight)
{
y = rnd1.Next(10, height - _locoHeight - 1);
y = rnd1.Next(120, height - _locoHeight - 1);
}
_startPosX = x;
_startPosY = y;

View File

@ -11,14 +11,14 @@ namespace Locomative
public Color DopColor { get; private set; }
public bool Wing { get; private set; }
public bool BodyKit { get; private set; }
public bool RocketToobe { get; private set; }
public EntityFastLocomative(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool rockettoobe) :
public bool Room { get; private set; }
public EntityFastLocomative(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool room) :
base(speed, weight, bodyColor)
{
DopColor = dopColor;
BodyKit = bodyKit;
Wing = wing;
RocketToobe = rockettoobe;
Room = room;
}
}
}

204
Locomative/Locomative/FormMap.Designer.cs generated Normal file
View File

@ -0,0 +1,204 @@
namespace Locomative
{
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.buttonСreate = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.pictureBoxLocomative = 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.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.ButtonFastCreate = new System.Windows.Forms.Button();
this.comboBoxSelectirMap = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomative)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// buttonСreate
//
this.buttonСreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonСreate.Location = new System.Drawing.Point(12, 393);
this.buttonСreate.Name = "buttonСreate";
this.buttonСreate.Size = new System.Drawing.Size(75, 23);
this.buttonСreate.TabIndex = 0;
this.buttonСreate.Text = "Создание";
this.buttonСreate.UseVisualStyleBackColor = true;
this.buttonСreate.Click += new System.EventHandler(this.buttonСreate_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = global::Locomative.Properties.Resources.arrow_down;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(711, 381);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(35, 35);
this.buttonDown.TabIndex = 1;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
//
// pictureBoxLocomative
//
this.pictureBoxLocomative.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxLocomative.Location = new System.Drawing.Point(0, 0);
this.pictureBoxLocomative.Name = "pictureBoxLocomative";
this.pictureBoxLocomative.Size = new System.Drawing.Size(800, 428);
this.pictureBoxLocomative.TabIndex = 2;
this.pictureBoxLocomative.TabStop = false;
this.pictureBoxLocomative.Click += new System.EventHandler(this.pictureBoxLocomative_Click);
this.pictureBoxLocomative.Resize += new System.EventHandler(this.PictureBoxResize);
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelColor});
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
this.statusStrip1.TabIndex = 3;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(55, 17);
this.toolStripStatusLabelSpeed.Text = "Скорость";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(24, 17);
this.toolStripStatusLabelWeight.Text = "Вес";
//
// toolStripStatusLabelColor
//
this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
this.toolStripStatusLabelColor.Size = new System.Drawing.Size(33, 17);
this.toolStripStatusLabelColor.Text = "Цвет";
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::Locomative.Properties.Resources.arrow_left;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(670, 381);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
this.buttonLeft.TabIndex = 4;
this.buttonLeft.UseVisualStyleBackColor = true;
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.BackgroundImage = global::Locomative.Properties.Resources.arrow_right;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(752, 381);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(35, 35);
this.buttonRight.TabIndex = 5;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::Locomative.Properties.Resources.arrow_up;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(711, 340);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(35, 35);
this.buttonUp.TabIndex = 6;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
//
// ButtonFastCreate
//
this.ButtonFastCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ButtonFastCreate.Location = new System.Drawing.Point(101, 393);
this.ButtonFastCreate.Name = "ButtonFastCreate";
this.ButtonFastCreate.Size = new System.Drawing.Size(97, 23);
this.ButtonFastCreate.TabIndex = 7;
this.ButtonFastCreate.Text = "Модификация";
this.ButtonFastCreate.UseVisualStyleBackColor = true;
this.ButtonFastCreate.Click += new System.EventHandler(this.ButtonFastCreate_Click);
//
// comboBoxSelectirMap
//
this.comboBoxSelectirMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectirMap.FormattingEnabled = true;
this.comboBoxSelectirMap.Location = new System.Drawing.Point(12, 12);
this.comboBoxSelectirMap.Name = "comboBoxSelectirMap";
this.comboBoxSelectirMap.Size = new System.Drawing.Size(103, 21);
this.comboBoxSelectirMap.TabIndex = 8;
//
// FormMap
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.comboBoxSelectirMap);
this.Controls.Add(this.ButtonFastCreate);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonСreate);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.pictureBoxLocomative);
this.Controls.Add(this.statusStrip1);
this.Name = "FormMap";
this.Text = "FormMap";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomative)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonСreate;
private Button buttonDown;
private PictureBox pictureBoxLocomative;
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelColor;
private Button buttonLeft;
private Button buttonRight;
private Button buttonUp;
private Button ButtonFastCreate;
private ComboBox comboBoxSelectirMap;
}
}

View File

@ -0,0 +1,89 @@
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 Locomative
{
public partial class FormMap : Form
{
private AbstractMap _abstractMap;
public FormMap()
{
InitializeComponent();
_abstractMap = new SimpleMap();
}
public void SetData(DrawningLocomative loco)
{
toolStripStatusLabelColor.Text = $"Цвет:{loco.Locomative.BodyColor.Name}";
toolStripStatusLabelSpeed.Text = $"Скорость:{loco.Locomative.Speed}";
toolStripStatusLabelWeight.Text = $"Вес:{loco.Locomative.Weight}";
}
private void buttonСreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_loco = new DrawningLocomative(rnd.Next(1, 200), rnd.Next(10, 300), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_loco.SetPosition(rnd.Next(10, 300), rnd.Next(10, 300), pictureBoxLocomative.Width, pictureBoxLocomative.Height);
SetData();
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
buttonMove_Click(sender, e, _loco);
}
private void buttonMove_Click(object sender, EventArgs e, DrawningLocomative _loco)
{
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_loco?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_loco?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_loco?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_loco?.MoveTransport(Direction.Right);
break;
}
Draw();
}
private void pictureBoxLocomative_Click(object sender, EventArgs e)
{
}
private void PictureBoxResize(object sender, EventArgs e)
{
_loco?.ChangeBorders(pictureBoxLocomative.Width, pictureBoxLocomative.Height);
Draw();
}
private void ButtonFastCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
/*_loco = new DrawningFastLoco(rnd.Next(1, 200), rnd.Next(100, 300),
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)), Convert.ToBoolean(rnd.Next(0, 2)));*/
_loco = new DrawningFastLoco(rnd.Next(1, 200), rnd.Next(100, 300),
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)),
true, true, true);
SetData();
Draw();
}
}
}

View File

@ -0,0 +1,63 @@
<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

@ -79,7 +79,7 @@ namespace Locomative
_loco = new DrawningFastLoco(rnd.Next(1, 200), rnd.Next(100, 300),
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)), Convert.ToBoolean(rnd.Next(0, 2)));
true, true, true);
SetData();
Draw();
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Locomative
{
internal class SimpleMap : AbstractMap
{
Brush barrielColor = new SolidBrush(Color.Black);
Brush railColor = new SolidBrush(Color.Gray);
protected override void DrawBarrielPart(Graphics g, int i, int j)
{
g.FillRectangle(barrielColor, i * _size_x, j*_size_y, i*(_size_x+1), j*(_size_y+1));
}
protected override void DrawRailPart(Graphics g, int i, int j)
{
g.FillRectangle(barrielColor, 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++;
}
}
}
}
}