comlete
This commit is contained in:
parent
ca8768f67f
commit
bd60416bcb
@ -8,8 +8,8 @@ namespace Stormtrooper
|
||||
{
|
||||
internal class DrawningObjectStormtrooper : IDrawningObject
|
||||
{
|
||||
private DrowningStormtrooper _stormtrooper = null;
|
||||
public DrawningObjectStormtrooper(DrowningStormtrooper stormtrooper)
|
||||
private DrawningStormtrooper _stormtrooper = null;
|
||||
public DrawningObjectStormtrooper(DrawningStormtrooper stormtrooper)
|
||||
{
|
||||
_stormtrooper = stormtrooper;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper
|
||||
{
|
||||
public class DrowningStormtrooper
|
||||
public class DrawningStormtrooper
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
@ -42,11 +42,11 @@ namespace Stormtrooper
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
public DrowningStormtrooper(int speed, float weight, Color bodyColor)
|
||||
public DrawningStormtrooper(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Stormtrooper = new EntityStormtrooper(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrowningStormtrooper(int speed, float weight, Color bodyColor, int StormtrooperWidth, int StormtrooperHeight) :
|
||||
protected DrawningStormtrooper(int speed, float weight, Color bodyColor, int StormtrooperWidth, int StormtrooperHeight) :
|
||||
this(speed, weight, bodyColor)
|
||||
{
|
||||
_stormtrooperWidth = StormtrooperWidth;
|
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper
|
||||
{
|
||||
internal class DrowningSuperStormtrooper : DrowningStormtrooper
|
||||
internal class DrawningSuperStormtrooper : DrawningStormtrooper
|
||||
{
|
||||
public DrowningSuperStormtrooper(int speed, float weight, Color bodyColor, Color dopColor, bool bombs, bool rockets, bool sportLine) : base(speed, weight, bodyColor, 90, 120)
|
||||
public DrawningSuperStormtrooper(int speed, float weight, Color bodyColor, Color dopColor, bool bombs, bool rockets, bool sportLine) : base(speed, weight, bodyColor, 90, 120)
|
||||
{
|
||||
Stormtrooper = new EntitySuperStormtrooper(speed, weight, bodyColor, dopColor, bombs, rockets, sportLine);
|
||||
}
|
||||
@ -19,7 +19,7 @@ namespace Stormtrooper
|
||||
return;
|
||||
}
|
||||
|
||||
Brush redBrush = new SolidBrush(Color.Red);
|
||||
Brush redBrush = new SolidBrush(superStormtrooper.BodyColor);
|
||||
Brush dopBrush = new SolidBrush(superStormtrooper.DopColor);
|
||||
|
||||
if (superStormtrooper.Bombs)
|
@ -35,13 +35,12 @@
|
||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||
this.textBoxNewMap = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxSelector = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveStormtrooper = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddStormtrooper = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
@ -60,7 +59,6 @@
|
||||
this.groupBox1.Controls.Add(this.buttonRemoveStormtrooper);
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox1.Controls.Add(this.buttonAddStormtrooper);
|
||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(637, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
@ -75,7 +73,7 @@
|
||||
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||
this.groupBoxMaps.Controls.Add(this.textBoxNewMap);
|
||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelector);
|
||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMaps.Location = new System.Drawing.Point(23, 26);
|
||||
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||
this.groupBoxMaps.Size = new System.Drawing.Size(203, 290);
|
||||
@ -120,18 +118,15 @@
|
||||
this.textBoxNewMap.Size = new System.Drawing.Size(179, 27);
|
||||
this.textBoxNewMap.TabIndex = 1;
|
||||
//
|
||||
// comboBoxSelector
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelector.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Собственная карта"});
|
||||
this.comboBoxSelector.Location = new System.Drawing.Point(18, 59);
|
||||
this.comboBoxSelector.Name = "comboBoxSelector";
|
||||
this.comboBoxSelector.Size = new System.Drawing.Size(179, 28);
|
||||
this.comboBoxSelector.TabIndex = 0;
|
||||
this.comboBoxSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelector_SelectedIndexChanged);
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(18, 59);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(179, 28);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelector_SelectedIndexChanged);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
@ -181,8 +176,6 @@
|
||||
this.buttonAddStormtrooper.Text = "Добавить";
|
||||
this.buttonAddStormtrooper.UseVisualStyleBackColor = true;
|
||||
this.buttonAddStormtrooper.Click += new System.EventHandler(this.ButtonAddStormtrooper_Click);
|
||||
//
|
||||
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
@ -271,7 +264,6 @@
|
||||
private Button buttonRemoveStormtrooper;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button buttonAddStormtrooper;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
@ -282,6 +274,6 @@
|
||||
private Button buttonDeleteMap;
|
||||
private Button buttonAddMap;
|
||||
private TextBox textBoxNewMap;
|
||||
private ComboBox comboBoxSelector;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
}
|
||||
}
|
@ -68,18 +68,18 @@ namespace Stormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddStormtrooper_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormStormtrooper form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectStormtrooper stormtrooper = new(form.SelectedStormtrooper);
|
||||
if (_mapCarsCollectionGeneric + stormtrooper != -1)
|
||||
DrawningObjectStormtrooper car = new(form.SelectedStormtrooper);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + car != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -124,11 +124,11 @@ namespace Stormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
@ -137,11 +137,11 @@ namespace Stormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapCarsCollectionGeneric.ShowOnMap();
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
@ -150,7 +150,8 @@ namespace Stormtrooper
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapCarsCollectionGeneric == null)
|
||||
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -172,7 +173,8 @@ namespace Stormtrooper
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBox.Image = _mapCarsCollectionGeneric.MoveObject(dir);
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ??
|
||||
string.Empty].MoveObject(dir);
|
||||
}
|
||||
|
||||
private void buttonAddMap_Click(object sender, EventArgs e)
|
||||
@ -213,5 +215,7 @@ namespace Stormtrooper
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ namespace Stormtrooper
|
||||
public partial class FormStormtrooper : Form
|
||||
{
|
||||
|
||||
private DrowningStormtrooper _stormtrooper;
|
||||
private DrawningStormtrooper _stormtrooper;
|
||||
|
||||
public DrowningStormtrooper SelectedStormtrooper { get; private set; }
|
||||
public DrawningStormtrooper SelectedStormtrooper { get; private set; }
|
||||
|
||||
public FormStormtrooper()
|
||||
{
|
||||
@ -46,8 +46,15 @@ namespace Stormtrooper
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_stormtrooper = new DrowningStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
||||
rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_stormtrooper = new DrawningStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
color);
|
||||
_stormtrooper.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||
pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||
SetData();
|
||||
@ -70,7 +77,7 @@ namespace Stormtrooper
|
||||
{
|
||||
dopColor = dialogDop.Color;
|
||||
}
|
||||
_stormtrooper = new DrowningSuperStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
_stormtrooper = new DrawningSuperStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
color, dopColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,
|
||||
2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
|
@ -161,17 +161,17 @@ namespace Stormtrooper
|
||||
/// <param name="g"></param>
|
||||
private void DrawCars(Graphics g)
|
||||
{
|
||||
int x = 5;
|
||||
int x = (_pictureWidth / _placeSizeWidth) * _placeSizeWidth - _placeSizeWidth;
|
||||
int y = 5;
|
||||
foreach (var boat in _setStormtroopers.GetStormtroopers())
|
||||
{
|
||||
boat?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
||||
boat?.DrawningObject(g);
|
||||
x += _placeSizeWidth;
|
||||
if (x + _placeSizeWidth > _pictureWidth)
|
||||
x -= _placeSizeWidth;
|
||||
if (x < 0)
|
||||
{
|
||||
y += _placeSizeHeight;
|
||||
x = 5;
|
||||
x = (_pictureWidth / _placeSizeWidth) * _placeSizeWidth - _placeSizeWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Stormtrooper
|
||||
/// <summary>
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Red);
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Blue);
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
@ -41,11 +41,15 @@ namespace Stormtrooper
|
||||
}
|
||||
while (counter < 10)
|
||||
{
|
||||
int x = _random.Next(0, _map.GetLength(0));
|
||||
int y = _random.Next(0, _map.GetLength(1));
|
||||
int x = _random.Next(2, _map.GetLength(0));
|
||||
int y = _random.Next(2, _map.GetLength(1));
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y] = _barrier;
|
||||
_map[x - 1, y] = _barrier;
|
||||
_map[x, y - 1] = _barrier;
|
||||
_map[x - 1, y - 1] = _barrier;
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user