lab 1 complicate is done
This commit is contained in:
parent
df69837593
commit
6c4b3a3447
@ -13,6 +13,7 @@ namespace ProjectTank
|
|||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityTank? _EntityTank { get; private set; }
|
public EntityTank? _EntityTank { get; private set; }
|
||||||
|
public DrawningWheelers? DrawningWheelersVariation;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -48,7 +49,7 @@ namespace ProjectTank
|
|||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
/// <returns>true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах</returns>
|
/// <returns>true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах</returns>
|
||||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
bool gun, bool machineGun, int width, int height)
|
bool gun, bool machineGun, int width, int height, int _numWheelers)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
@ -58,7 +59,9 @@ namespace ProjectTank
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_EntityTank = new EntityTank();
|
_EntityTank = new EntityTank();
|
||||||
_EntityTank.Init(speed, weight, gun, machineGun, bodyColor, additionalColor);
|
_EntityTank.Init(speed, weight, gun, machineGun, bodyColor, additionalColor, _numWheelers);
|
||||||
|
DrawningWheelersVariation = new DrawningWheelers();
|
||||||
|
DrawningWheelersVariation.SomeProperty = _numWheelers;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -132,7 +135,6 @@ namespace ProjectTank
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
Pen penGray = new(Color.Gray, 4);
|
|
||||||
Brush grayColorBrush = new SolidBrush(Color.Gray);
|
Brush grayColorBrush = new SolidBrush(Color.Gray);
|
||||||
Brush blackColorBrush = new SolidBrush(Color.Black);
|
Brush blackColorBrush = new SolidBrush(Color.Black);
|
||||||
Brush additionalBrush = new SolidBrush(_EntityTank.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(_EntityTank.AdditionalColor);
|
||||||
@ -142,14 +144,11 @@ namespace ProjectTank
|
|||||||
// гусеницы
|
// гусеницы
|
||||||
g.DrawEllipse(pen, _startPosX+14, _startPosY+44, 151, 31);
|
g.DrawEllipse(pen, _startPosX+14, _startPosY+44, 151, 31);
|
||||||
g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
|
g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
|
||||||
g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
|
|
||||||
g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
|
//катки
|
||||||
g.DrawEllipse(penGray, _startPosX + 44, _startPosY + 59, 10, 10);
|
DrawningWheelersVariation.Draw(_startPosX, _startPosY, g);
|
||||||
g.DrawEllipse(penGray, _startPosX + 124, _startPosY + 59, 10, 10);
|
|
||||||
g.DrawEllipse(penGray, _startPosX + 64, _startPosY + 61, 10, 10);
|
// Кузов
|
||||||
g.DrawEllipse(penGray, _startPosX + 104, _startPosY + 61, 10, 10);
|
|
||||||
g.DrawEllipse(penGray, _startPosX + 84, _startPosY + 62, 10, 10);
|
|
||||||
// Кузов
|
|
||||||
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 34, 141, 21);
|
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 34, 141, 21);
|
||||||
g.FillRectangle(bodyBrush, _startPosX+20, _startPosY+35, 140, 20);
|
g.FillRectangle(bodyBrush, _startPosX+20, _startPosY+35, 140, 20);
|
||||||
|
|
||||||
|
67
ProjectTank/ProjectTank/DrawningWheelers.cs
Normal file
67
ProjectTank/ProjectTank/DrawningWheelers.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
public class DrawningWheelers
|
||||||
|
{
|
||||||
|
private WheelersDirection numWheelers;
|
||||||
|
|
||||||
|
public int? SomeProperty
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
numWheelers = WheelersDirection.FourthWheelers;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
numWheelers = WheelersDirection.FifthWheelers;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
numWheelers = WheelersDirection.SixthWheelers;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
numWheelers = WheelersDirection.FourthWheelers;
|
||||||
|
MessageBox.Show("Неверное количество катков!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Draw(int _startPosX, int _startPosY, Graphics g)
|
||||||
|
{
|
||||||
|
Pen penGray = new(Color.Gray, 4);
|
||||||
|
if (numWheelers == WheelersDirection.FourthWheelers)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 64, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 104, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
|
||||||
|
}
|
||||||
|
if (numWheelers == WheelersDirection.FifthWheelers)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 54, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 84, _startPosY + 61, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 114, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
|
||||||
|
}
|
||||||
|
if (numWheelers == WheelersDirection.SixthWheelers)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 24, _startPosY + 54, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 48, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 72, _startPosY + 61, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 96, _startPosY + 61, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 120, _startPosY + 59, 10, 10);
|
||||||
|
g.DrawEllipse(penGray, _startPosX + 144, _startPosY + 54, 10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,7 @@ namespace ProjectTank
|
|||||||
/// Дополнительный цвет (для опциональных элементов)
|
/// Дополнительный цвет (для опциональных элементов)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
|
public int NumWheelers { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Расчет шага по карте
|
/// Расчет шага по карте
|
||||||
@ -54,7 +55,7 @@ namespace ProjectTank
|
|||||||
/// <param name="machineGun">Признак наличия пулемета</param>
|
/// <param name="machineGun">Признак наличия пулемета</param>
|
||||||
///
|
///
|
||||||
public void Init(int speed, double weight, bool gun,
|
public void Init(int speed, double weight, bool gun,
|
||||||
bool machineGun, Color bodyColor, Color additionalColor)
|
bool machineGun, Color bodyColor, Color additionalColor, int numWheelers)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
@ -62,6 +63,7 @@ namespace ProjectTank
|
|||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Gun = gun;
|
Gun = gun;
|
||||||
MachineGun = machineGun;
|
MachineGun = machineGun;
|
||||||
|
NumWheelers= numWheelers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace ProjectTank
|
|||||||
_drawningTank.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
_drawningTank.Init(random.Next(100, 300), random.Next(1000, 3000), 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)),
|
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)),
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
pictureBoxTanks.Width, pictureBoxTanks.Height);
|
pictureBoxTanks.Width, pictureBoxTanks.Height, random.Next(4, 7));
|
||||||
_drawningTank.SetPosition(random.Next(0, 100), random.Next(0, 100));
|
_drawningTank.SetPosition(random.Next(0, 100), random.Next(0, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
24
ProjectTank/ProjectTank/WheelersDirection.cs
Normal file
24
ProjectTank/ProjectTank/WheelersDirection.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectTank
|
||||||
|
{
|
||||||
|
public enum WheelersDirection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Четыре катка
|
||||||
|
/// </summary>
|
||||||
|
FourthWheelers,
|
||||||
|
/// <summary>
|
||||||
|
/// Пять катков
|
||||||
|
/// </summary>
|
||||||
|
FifthWheelers,
|
||||||
|
/// <summary>
|
||||||
|
/// Шесть катков
|
||||||
|
/// </summary>
|
||||||
|
SixthWheelers
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user