ISE_22.Aparyan.Bulldozer.Base Lab03 #3
@ -1,6 +1,4 @@
|
|||||||
|
namespace ProjectBulldozer
|
||||||
|
|
||||||
namespace ProjectBulldozer
|
|
||||||
{
|
{
|
||||||
public enum DirectionType
|
public enum DirectionType
|
||||||
{
|
{
|
||||||
|
@ -11,9 +11,7 @@ namespace ProjectBulldozer.Drawning
|
|||||||
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, horns, seifBatteries);
|
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, horns, seifBatteries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Otval { get; private set; }
|
public object Otval { get; private set; }
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityTractor is not EntityBulldozer Bulldozer)
|
if (EntityTractor is not EntityBulldozer Bulldozer)
|
||||||
@ -22,48 +20,28 @@ namespace ProjectBulldozer.Drawning
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
|
|
||||||
|
|
||||||
Brush blackBrush = new SolidBrush(Color.Black);
|
Brush blackBrush = new SolidBrush(Color.Black);
|
||||||
Brush windows = new SolidBrush(Color.LightBlue);
|
Brush windows = new SolidBrush(Color.LightBlue);
|
||||||
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
|
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
|
||||||
|
|
||||||
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
||||||
|
|
||||||
Brush grayBrush = new SolidBrush(Color.Gray);
|
Brush grayBrush = new SolidBrush(Color.Gray);
|
||||||
|
|
||||||
//otval
|
//otval
|
||||||
Point[] Otval =
|
Point[] Otval =
|
||||||
{
|
{
|
||||||
new Point(_startPosX + 118, _startPosY + 50),
|
new Point(_startPosX + 118, _startPosY + 50),
|
||||||
new Point(_startPosX + 148, _startPosY + 111),
|
new Point(_startPosX + 148, _startPosY + 111),
|
||||||
new Point(_startPosX+ 118, _startPosY + 111),
|
new Point(_startPosX+ 118, _startPosY + 111),
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
g.FillPolygon(additionalColor, Otval);
|
g.FillPolygon(additionalColor, Otval);
|
||||||
g.DrawPolygon(pen, Otval);
|
g.DrawPolygon(pen, Otval);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//гусеницы
|
//гусеницы
|
||||||
Brush gg = new SolidBrush(Color.LightGray);
|
Brush gg = new SolidBrush(Color.LightGray);
|
||||||
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Point[] Ttt =
|
Point[] Ttt =
|
||||||
{
|
{
|
||||||
|
|
||||||
new Point(_startPosX + 16, _startPosY + 79),
|
new Point(_startPosX + 16, _startPosY + 79),
|
||||||
new Point(_startPosX + 16, _startPosY + 120),
|
new Point(_startPosX + 16, _startPosY + 120),
|
||||||
new Point(_startPosX, _startPosY + 48),
|
new Point(_startPosX, _startPosY + 48),
|
||||||
@ -71,9 +49,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
};
|
};
|
||||||
g.FillPolygon(blackBrush, Ttt);
|
g.FillPolygon(blackBrush, Ttt);
|
||||||
g.DrawPolygon(pen, Ttt);
|
g.DrawPolygon(pen, Ttt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Bulldozer.SeifBatteries)
|
if (Bulldozer.SeifBatteries)
|
||||||
{
|
{
|
||||||
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
||||||
|
@ -1,31 +1,21 @@
|
|||||||
|
using ProjectBulldozer.Entities;
|
||||||
using Bulldozer;
|
|
||||||
using ProjectBulldozer.Entities;
|
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
|
|
||||||
namespace ProjectBulldozer.Drawning
|
namespace ProjectBulldozer.Drawning
|
||||||
{
|
{
|
||||||
public class DrawingTractor
|
public class DrawingTractor
|
||||||
{
|
{
|
||||||
public EntityTractor? EntityTractor { get; protected set; }
|
public EntityTractor? EntityTractor { get; protected set; }
|
||||||
|
|
||||||
protected int _pictureWidth;
|
protected int _pictureWidth;
|
||||||
|
|
||||||
protected int _pictureHeight;
|
protected int _pictureHeight;
|
||||||
|
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
|
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
|
|
||||||
protected readonly int _tractWidth = 120;
|
protected readonly int _tractWidth = 120;
|
||||||
|
|
||||||
protected readonly int _tractHeight = 110;
|
protected readonly int _tractHeight = 110;
|
||||||
public int GetPosX => _startPosX;
|
public int GetPosX => _startPosX;
|
||||||
public int GetPosY => _startPosY;
|
public int GetPosY => _startPosY;
|
||||||
public int GetWidth => _tractWidth;
|
public int GetWidth => _tractWidth;
|
||||||
public int GetHeight => _tractHeight;
|
public int GetHeight => _tractHeight;
|
||||||
|
|
||||||
public IMoveableObject GetMoveableObject => new DrawingObjectTractor(this);
|
public IMoveableObject GetMoveableObject => new DrawingObjectTractor(this);
|
||||||
public DrawingTractor(int speed, double weight, Color bodyColor, int width, int heigth)
|
public DrawingTractor(int speed, double weight, Color bodyColor, int width, int heigth)
|
||||||
{
|
{
|
||||||
@ -37,7 +27,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_pictureHeight = heigth;
|
_pictureHeight = heigth;
|
||||||
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DrawingTractor(int speed, double weight, Color bodyColor, int width,
|
protected DrawingTractor(int speed, double weight, Color bodyColor, int width,
|
||||||
int height, int tractWidth, int tractHeight)
|
int height, int tractWidth, int tractHeight)
|
||||||
{
|
{
|
||||||
@ -51,7 +40,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_tractHeight = tractHeight;
|
_tractHeight = tractHeight;
|
||||||
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Установка позиции
|
//Установка позиции
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
@ -107,44 +95,26 @@ namespace ProjectBulldozer.Drawning
|
|||||||
{
|
{
|
||||||
if (EntityTractor == null) return;
|
if (EntityTractor == null) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush brownBrush = new SolidBrush(Color.Brown);
|
Brush brownBrush = new SolidBrush(Color.Brown);
|
||||||
Brush windows = new SolidBrush(Color.LightYellow);
|
Brush windows = new SolidBrush(Color.LightYellow);
|
||||||
Brush bodyColor = new SolidBrush(EntityTractor.BodyColor);
|
Brush bodyColor = new SolidBrush(EntityTractor.BodyColor);
|
||||||
|
|
||||||
Brush grayBrush = new SolidBrush(Color.Gray);
|
Brush grayBrush = new SolidBrush(Color.Gray);
|
||||||
|
|
||||||
//основное тело
|
//основное тело
|
||||||
g.FillRectangle(bodyColor, _startPosX + 18, _startPosY + 42, 99, 56);
|
g.FillRectangle(bodyColor, _startPosX + 18, _startPosY + 42, 99, 56);
|
||||||
g.DrawRectangle(pen, _startPosX + 18, _startPosY + 42, 99, 56);
|
g.DrawRectangle(pen, _startPosX + 18, _startPosY + 42, 99, 56);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//кабина водителя
|
//кабина водителя
|
||||||
g.FillRectangle(windows, _startPosX + 18, _startPosY + 4 , 37, 37);
|
g.FillRectangle(windows, _startPosX + 18, _startPosY + 4 , 37, 37);
|
||||||
g.DrawRectangle(pen, _startPosX + 18, _startPosY +4 , 37, 37);
|
g.DrawRectangle(pen, _startPosX + 18, _startPosY +4 , 37, 37);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//колеса
|
//колеса
|
||||||
|
|
||||||
g.FillEllipse(grayBrush, _startPosX + 19, _startPosY + 76, 45, 45);
|
g.FillEllipse(grayBrush, _startPosX + 19, _startPosY + 76, 45, 45);
|
||||||
g.DrawEllipse(pen, _startPosX + 19, _startPosY + 76, 45, 45);
|
g.DrawEllipse(pen, _startPosX + 19, _startPosY + 76, 45, 45);
|
||||||
|
|
||||||
|
|
||||||
g.FillEllipse(grayBrush, _startPosX + 80, _startPosY + 87, 33, 33);
|
g.FillEllipse(grayBrush, _startPosX + 80, _startPosY + 87, 33, 33);
|
||||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 87, 33, 33);
|
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 87, 33, 33);
|
||||||
|
|
||||||
|
|
||||||
//выхлопная труба
|
//выхлопная труба
|
||||||
g.FillRectangle(brownBrush, _startPosX + 88, _startPosY+ 6, 14, 35);
|
g.FillRectangle(brownBrush, _startPosX + 88, _startPosY+ 6, 14, 35);
|
||||||
g.DrawRectangle(pen, _startPosX + 88, _startPosY + 6, 14, 35);
|
g.DrawRectangle(pen, _startPosX + 88, _startPosY + 6, 14, 35);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMove(DirectionType direction)
|
public bool CanMove(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityTractor == null)
|
if (EntityTractor == null)
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectBulldozer.Entities
|
namespace ProjectBulldozer.Entities
|
||||||
{
|
{
|
||||||
public class EntityBulldozer : EntityTractor
|
public class EntityBulldozer : EntityTractor
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace ProjectBulldozer.Entities
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectBulldozer.Entities
|
|
||||||
{
|
{
|
||||||
public class EntityTractor
|
public class EntityTractor
|
||||||
{
|
{
|
||||||
|
22
ProjectBulldozer/FormBulldozer.Designer.cs
generated
22
ProjectBulldozer/FormBulldozer.Designer.cs
generated
@ -1,16 +1,9 @@
|
|||||||
namespace Bulldozer
|
|
||||||
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
partial class FormBulldozer
|
partial class FormBulldozer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
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)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
@ -19,13 +12,7 @@
|
|||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#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()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
pictureBoxBulldozer = new PictureBox();
|
pictureBoxBulldozer = new PictureBox();
|
||||||
@ -188,9 +175,12 @@
|
|||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxBulldozer;
|
private PictureBox pictureBoxBulldozer;
|
||||||
private Button buttonCreateBulldozer;
|
private Button buttonCreateBulldozer;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
|
@ -2,24 +2,19 @@ using ProjectBulldozer;
|
|||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.Generics;
|
using ProjectBulldozer.Generics;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
public partial class FormBulldozer : Form
|
public partial class FormBulldozer : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
private DrawingTractor? _drawingTractor;
|
private DrawingTractor? _drawingTractor;
|
||||||
|
|
||||||
private AbstractStrategy? _abstractStrategy;
|
private AbstractStrategy? _abstractStrategy;
|
||||||
public DrawingTractor? SelectedTractor { get; private set; }
|
public DrawingTractor? SelectedTractor { get; private set; }
|
||||||
|
|
||||||
public FormBulldozer()
|
public FormBulldozer()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
SelectedTractor = null;
|
SelectedTractor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
if (_drawingTractor == null)
|
if (_drawingTractor == null)
|
||||||
@ -31,34 +26,26 @@ namespace Bulldozer
|
|||||||
_drawingTractor.DrawTransport(gr);
|
_drawingTractor.DrawTransport(gr);
|
||||||
pictureBoxBulldozer.Image = bmp;
|
pictureBoxBulldozer.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateBulldozer_Click(object sender, EventArgs e)
|
private void buttonCreateBulldozer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
|
||||||
ColorDialog colorDialog = new ColorDialog();
|
ColorDialog colorDialog = new ColorDialog();
|
||||||
|
|
||||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
color = colorDialog.Color;
|
color = colorDialog.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
|
||||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
dopColor = colorDialog.Color;
|
dopColor = colorDialog.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
_drawingTractor = new DrawingBulldozer(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
|
_drawingTractor = new DrawingBulldozer(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
||||||
_drawingTractor.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingTractor.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateTractor_Click(object sender, EventArgs e)
|
private void buttonCreateTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
@ -73,7 +60,6 @@ namespace Bulldozer
|
|||||||
_drawingTractor.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100));
|
_drawingTractor.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonMove_Click(object sender, EventArgs e)
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawingTractor == null)
|
if (_drawingTractor == null)
|
||||||
@ -98,7 +84,6 @@ namespace Bulldozer
|
|||||||
}
|
}
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonStep_Click(object sender, EventArgs e)
|
private void buttonStep_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawingTractor == null)
|
if (_drawingTractor == null)
|
||||||
@ -133,16 +118,10 @@ namespace Bulldozer
|
|||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSelect_Tractor_Click(object sender, EventArgs e)
|
private void ButtonSelect_Tractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectedTractor = _drawingTractor;
|
SelectedTractor = _drawingTractor;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,15 +2,7 @@
|
|||||||
{
|
{
|
||||||
partial class FormTractorCollections
|
partial class FormTractorCollections
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
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)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
@ -21,11 +13,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#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()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
Instruments = new Panel();
|
Instruments = new Panel();
|
||||||
@ -124,9 +111,11 @@
|
|||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
private void pictureBoxCollections_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Panel Instruments;
|
private Panel Instruments;
|
||||||
private Button ButtonRefreshCollection;
|
private Button ButtonRefreshCollection;
|
||||||
private Button ButtonRemoveTractor;
|
private Button ButtonRemoveTractor;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.Generics;
|
using ProjectBulldozer.Generics;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectBulldozer
|
namespace ProjectBulldozer
|
||||||
{
|
{
|
||||||
public partial class FormTractorCollections : Form
|
public partial class FormTractorCollections : Form
|
||||||
@ -14,7 +13,6 @@ namespace ProjectBulldozer
|
|||||||
_Tractors = new TractorGenericCollection<DrawingTractor, DrawingObjectTractor>(pictureBoxCollections.Width,
|
_Tractors = new TractorGenericCollection<DrawingTractor, DrawingObjectTractor>(pictureBoxCollections.Width,
|
||||||
pictureBoxCollections.Height);
|
pictureBoxCollections.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_Tractors == null) return;
|
if (_Tractors == null) return;
|
||||||
@ -33,7 +31,6 @@ namespace ProjectBulldozer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
@ -51,15 +48,9 @@ namespace ProjectBulldozer
|
|||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBoxCollections_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,6 @@ namespace ProjectBulldozer.Generics
|
|||||||
}
|
}
|
||||||
return collect._collection.Insert(tract);
|
return collect._collection.Insert(tract);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool operator -(TractorGenericCollection<T, U> collect, int
|
public static bool operator -(TractorGenericCollection<T, U> collect, int
|
||||||
pos)
|
pos)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
namespace ProjectBulldozer.Generics
|
||||||
|
|
||||||
namespace ProjectBulldozer.Generics
|
|
||||||
{
|
{
|
||||||
internal class SetGeneric<T> where T : class
|
internal class SetGeneric<T> where T : class
|
||||||
{
|
{
|
||||||
@ -10,13 +8,11 @@ namespace ProjectBulldozer.Generics
|
|||||||
{
|
{
|
||||||
_places = new T[count];
|
_places = new T[count];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
public int Insert(T tract)
|
public int Insert(T tract)
|
||||||
{
|
{
|
||||||
return Insert(tract, 0);
|
return Insert(tract, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T tract, int position)
|
public int Insert(T tract, int position)
|
||||||
{
|
{
|
||||||
int NoEmpty = 0, temp = 0;
|
int NoEmpty = 0, temp = 0;
|
||||||
@ -44,16 +40,11 @@ namespace ProjectBulldozer.Generics
|
|||||||
_places[position] = tract;
|
_places[position] = tract;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
|
||||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент //
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
|
||||||
if (position >= Count || position < 0)
|
if (position >= Count || position < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Абстрактный класс стратегии
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractStrategy
|
public abstract class AbstractStrategy
|
||||||
{
|
{
|
||||||
private IMoveableObject? _moveableObject;
|
private IMoveableObject? _moveableObject;
|
||||||
@ -13,7 +10,6 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
protected int FieldWidth { get; private set; }
|
protected int FieldWidth { get; private set; }
|
||||||
protected int FieldHeight { get; private set; }
|
protected int FieldHeight { get; private set; }
|
||||||
public Status GetStatus() { return _state; }
|
public Status GetStatus() { return _state; }
|
||||||
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||||
{
|
{
|
||||||
if (moveableObject == null)
|
if (moveableObject == null)
|
||||||
@ -40,18 +36,12 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
}
|
}
|
||||||
MoveToTarget();
|
MoveToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||||
|
|
||||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||||
|
|
||||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||||
|
|
||||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||||
|
|
||||||
/// Параметры объекта
|
/// Параметры объекта
|
||||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||||
|
|
||||||
protected int? GetStep()
|
protected int? GetStep()
|
||||||
{
|
{
|
||||||
if (_state != Status.InProgress)
|
if (_state != Status.InProgress)
|
||||||
@ -61,9 +51,7 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
return _moveableObject?.GetStep;
|
return _moveableObject?.GetStep;
|
||||||
}
|
}
|
||||||
protected abstract void MoveToTarget();
|
protected abstract void MoveToTarget();
|
||||||
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
protected abstract bool IsTargetDestinaion();
|
||||||
|
|
||||||
private bool MoveTo(DirectionType directionType)
|
private bool MoveTo(DirectionType directionType)
|
||||||
{
|
{
|
||||||
if (_state != Status.InProgress)
|
if (_state != Status.InProgress)
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.Drawning;
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
{
|
{
|
||||||
public class DrawingObjectTractor : IMoveableObject
|
public class DrawingObjectTractor : IMoveableObject
|
||||||
{
|
{
|
||||||
private readonly DrawingTractor? _drawningTractor = null;
|
private readonly DrawingTractor? _drawningTractor = null;
|
||||||
|
|
||||||
public DrawingObjectTractor(DrawingTractor drawningTractor)
|
public DrawingObjectTractor(DrawingTractor drawningTractor)
|
||||||
{
|
{
|
||||||
_drawningTractor = drawningTractor;
|
_drawningTractor = drawningTractor;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using Bulldozer;
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
|
||||||
{
|
{
|
||||||
public interface IMoveableObject
|
public interface IMoveableObject
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
|
||||||
{
|
{
|
||||||
public class MoveToCenter : AbstractStrategy
|
public class MoveToCenter : AbstractStrategy
|
||||||
{
|
{
|
||||||
@ -13,7 +11,6 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
+ GetStep() >= FieldWidth / 2 && objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
+ GetStep() >= FieldWidth / 2 && objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
protected override void MoveToTarget()
|
||||||
{
|
{
|
||||||
var objParams = GetObjectParameters;
|
var objParams = GetObjectParameters;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
|
||||||
{
|
{
|
||||||
public class MoveToRightCorner : AbstractStrategy
|
public class MoveToRightCorner : AbstractStrategy
|
||||||
{
|
{
|
||||||
@ -11,12 +9,10 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
|
|
||||||
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
|
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
protected override void MoveToTarget()
|
||||||
{
|
{
|
||||||
var objParams = GetObjectParameters;
|
var objParams = GetObjectParameters;
|
||||||
if (objParams == null) return;
|
if (objParams == null) return;
|
||||||
|
|
||||||
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
|
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
|
||||||
if (objParams.DownBorder < FieldHeight - GetStep()) MoveDown();
|
if (objParams.DownBorder < FieldHeight - GetStep()) MoveDown();
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||||
/// Середина объекта по вертикали
|
/// Середина объекта по вертикали
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
public int ObjectMiddleVertical => _y + _height / 2;
|
||||||
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
public ObjectParameters(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
_x = x;
|
_x = x;
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
using ProjectBulldozer;
|
using ProjectBulldozer;
|
||||||
|
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
https://aka.ms/applicationconfiguration.
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormTractorCollections());
|
Application.Run(new FormTractorCollections());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user