Осталось доделать логику(TODO)
This commit is contained in:
parent
b44b322dbd
commit
1333c85ae3
84
Traktor/Traktor/AbstractMap.cs
Normal file
84
Traktor/Traktor/AbstractMap.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Traktor
|
||||
{
|
||||
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)
|
||||
{
|
||||
// TODO проверка, что объект может переместится в требуемом направлении
|
||||
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);
|
||||
// TODO првоерка, что объект не "накладывается" на закрытые участки
|
||||
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);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
//Направление перемещения
|
||||
internal enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
|
2
Traktor/Traktor/DrawField.Designer.cs
generated
2
Traktor/Traktor/DrawField.Designer.cs
generated
@ -152,6 +152,7 @@
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(113, 272);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(110, 22);
|
||||
@ -182,7 +183,6 @@
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
216
Traktor/Traktor/FormMap.Designer.cs
generated
Normal file
216
Traktor/Traktor/FormMap.Designer.cs
generated
Normal file
@ -0,0 +1,216 @@
|
||||
namespace Traktor
|
||||
{
|
||||
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.pictureBoxTraktor = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonLEFT = new System.Windows.Forms.Button();
|
||||
this.buttonRIGHT = new System.Windows.Forms.Button();
|
||||
this.buttonDOWN = new System.Windows.Forms.Button();
|
||||
this.buttonUP = new System.Windows.Forms.Button();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelector = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTraktor)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxTraktor
|
||||
//
|
||||
this.pictureBoxTraktor.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxTraktor.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxTraktor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.pictureBoxTraktor.Name = "pictureBoxTraktor";
|
||||
this.pictureBoxTraktor.Size = new System.Drawing.Size(700, 316);
|
||||
this.pictureBoxTraktor.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxTraktor.TabIndex = 0;
|
||||
this.pictureBoxTraktor.TabStop = false;
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 316);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 12, 0);
|
||||
this.statusStrip.Size = new System.Drawing.Size(700, 22);
|
||||
this.statusStrip.TabIndex = 1;
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(65, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость: ";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес: ";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(75, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет кузова:";
|
||||
//
|
||||
// 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(25, 272);
|
||||
this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonLEFT
|
||||
//
|
||||
this.buttonLEFT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLEFT.BackgroundImage = global::Traktor.Properties.Resources.arrowLeft;
|
||||
this.buttonLEFT.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLEFT.Location = new System.Drawing.Point(589, 271);
|
||||
this.buttonLEFT.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonLEFT.Name = "buttonLEFT";
|
||||
this.buttonLEFT.Size = new System.Drawing.Size(26, 22);
|
||||
this.buttonLEFT.TabIndex = 3;
|
||||
this.buttonLEFT.UseVisualStyleBackColor = true;
|
||||
this.buttonLEFT.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::Traktor.Properties.Resources.arrowRight;
|
||||
this.buttonRIGHT.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRIGHT.Location = new System.Drawing.Point(652, 271);
|
||||
this.buttonRIGHT.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRIGHT.Name = "buttonRIGHT";
|
||||
this.buttonRIGHT.Size = new System.Drawing.Size(26, 22);
|
||||
this.buttonRIGHT.TabIndex = 4;
|
||||
this.buttonRIGHT.UseVisualStyleBackColor = true;
|
||||
this.buttonRIGHT.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::Traktor.Properties.Resources.arrowDown;
|
||||
this.buttonDOWN.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDOWN.Location = new System.Drawing.Point(620, 284);
|
||||
this.buttonDOWN.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDOWN.Name = "buttonDOWN";
|
||||
this.buttonDOWN.Size = new System.Drawing.Size(26, 22);
|
||||
this.buttonDOWN.TabIndex = 5;
|
||||
this.buttonDOWN.UseVisualStyleBackColor = true;
|
||||
this.buttonDOWN.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::Traktor.Properties.Resources.arrowUp;
|
||||
this.buttonUP.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUP.Location = new System.Drawing.Point(620, 257);
|
||||
this.buttonUP.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUP.Name = "buttonUP";
|
||||
this.buttonUP.Size = new System.Drawing.Size(26, 22);
|
||||
this.buttonUP.TabIndex = 6;
|
||||
this.buttonUP.UseVisualStyleBackColor = true;
|
||||
this.buttonUP.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateModif.Location = new System.Drawing.Point(113, 272);
|
||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||
this.buttonCreateModif.Size = new System.Drawing.Size(110, 22);
|
||||
this.buttonCreateModif.TabIndex = 7;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
|
||||
//
|
||||
// comboBoxSelector
|
||||
//
|
||||
this.comboBoxSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelector.FormattingEnabled = true;
|
||||
this.comboBoxSelector.Items.AddRange(new object[] {
|
||||
"Простая карта"});
|
||||
this.comboBoxSelector.Location = new System.Drawing.Point(12, 12);
|
||||
this.comboBoxSelector.Name = "comboBoxSelector";
|
||||
this.comboBoxSelector.Size = new System.Drawing.Size(121, 23);
|
||||
this.comboBoxSelector.TabIndex = 8;
|
||||
this.comboBoxSelector.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelector_SelectedIndexChanged);
|
||||
//
|
||||
// FormMap
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.comboBoxSelector);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonUP);
|
||||
this.Controls.Add(this.buttonDOWN);
|
||||
this.Controls.Add(this.buttonRIGHT);
|
||||
this.Controls.Add(this.buttonLEFT);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.pictureBoxTraktor);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormMap";
|
||||
this.Text = "Трактор";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTraktor)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxTraktor;
|
||||
private StatusStrip statusStrip;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private Button buttonCreate;
|
||||
private Button buttonLEFT;
|
||||
private Button buttonRIGHT;
|
||||
private Button buttonDOWN;
|
||||
private Button buttonUP;
|
||||
private Button buttonCreateModif;
|
||||
private ComboBox comboBoxSelector;
|
||||
}
|
||||
}
|
85
Traktor/Traktor/FormMap.cs
Normal file
85
Traktor/Traktor/FormMap.cs
Normal file
@ -0,0 +1,85 @@
|
||||
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 Traktor
|
||||
{
|
||||
public partial class FormMap : Form
|
||||
{
|
||||
private AbstractMap _abstractMap;
|
||||
|
||||
public FormMap()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractMap = new SimpleMap();
|
||||
}
|
||||
|
||||
//Заполнение информации по объекту
|
||||
private void SetData(TraktorDraw traktor)
|
||||
{
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {traktor.Traktor.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {traktor.Traktor.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {traktor.Traktor.BodyColor.Name}";
|
||||
pictureBoxTraktor.Image = _abstractMap.CreateMap(pictureBoxTraktor.Width, pictureBoxTraktor.Height,
|
||||
new DrawningObjectTraktor(traktor));
|
||||
}
|
||||
|
||||
//Логика кнопки Создать
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
var car = new TraktorDraw(random.Next(100, 200), random.Next(2500, 5000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.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;
|
||||
}
|
||||
pictureBoxTraktor.Image = _abstractMap?.MoveObject(dir);
|
||||
}
|
||||
|
||||
// Обработка нажатия кнопки "Модификация"
|
||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
var _Traktor = new MultiTraktorDraw(random.Next(100, 200), random.Next(2500, 5000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
SetData(_Traktor);
|
||||
}
|
||||
|
||||
private void ComboBoxSelector_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelector.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
_abstractMap = new SimpleMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
Traktor/Traktor/FormMap.resx
Normal file
63
Traktor/Traktor/FormMap.resx
Normal 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="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -11,7 +11,7 @@ namespace Traktor
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new DrawField());
|
||||
Application.Run(new FormMap());
|
||||
}
|
||||
}
|
||||
}
|
49
Traktor/Traktor/SimpleMap.cs
Normal file
49
Traktor/Traktor/SimpleMap.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Traktor
|
||||
{
|
||||
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…
x
Reference in New Issue
Block a user