Лабораторная работа №1 Готовая
This commit is contained in:
parent
87fb777d7f
commit
1e1dae00e3
@ -42,10 +42,10 @@ public class DrawningAntiAircraftGun
|
|||||||
/// <param name="bodyKit">Наличие обвеса</param>
|
/// <param name="bodyKit">Наличие обвеса</param>
|
||||||
/// <param name="tower">Наличие башни</param>
|
/// <param name="tower">Наличие башни</param>
|
||||||
/// <param name="radar">Наличие радара</param>
|
/// <param name="radar">Наличие радара</param>
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tower, bool radar)
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tower, bool radar)
|
||||||
{
|
{
|
||||||
EntityAntiAircraftGun = new EntityAntiAircraftGun();
|
EntityAntiAircraftGun = new EntityAntiAircraftGun();
|
||||||
EntityAntiAircraftGun.Init(speed, weight, bodyColor, additionalColor, bodyKit, tower, radar);
|
EntityAntiAircraftGun.Init(speed, weight, bodyColor, additionalColor, tower, radar);
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
@ -59,8 +59,7 @@ public class DrawningAntiAircraftGun
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool SetPictureSize(int width, int height)
|
public bool SetPictureSize(int width, int height)
|
||||||
{
|
{
|
||||||
// TODO проверка, что объект "влезает" в размеры поля
|
|
||||||
// если влезает, сохраняем границы и корректируем позицию объекта,если она была уже установлена
|
|
||||||
if (width < _drawningGunWidth || height < _drawningGunHeight) { return false; };
|
if (width < _drawningGunWidth || height < _drawningGunHeight) { return false; };
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
@ -93,8 +92,7 @@ public class DrawningAntiAircraftGun
|
|||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
|
||||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -20,10 +20,6 @@ public class EntityAntiAircraftGun
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наличие обвеса
|
|
||||||
/// </summary>
|
|
||||||
public bool BodyKit { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие башни
|
/// Наличие башни
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Tower { get; private set; }
|
public bool Tower { get; private set; }
|
||||||
@ -45,13 +41,12 @@ public class EntityAntiAircraftGun
|
|||||||
/// <param name="bodyKit">Наличие обвеса</param>
|
/// <param name="bodyKit">Наличие обвеса</param>
|
||||||
/// <param name="tower">Наличие башни</param>
|
/// <param name="tower">Наличие башни</param>
|
||||||
/// <param name="radar">Наличие радара</param>
|
/// <param name="radar">Наличие радара</param>
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tower, bool radar)
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tower, bool radar)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
BodyKit = bodyKit;
|
|
||||||
Tower = tower;
|
Tower = tower;
|
||||||
Radar = radar;
|
Radar = radar;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
_drawningAntiAircraftGun = new DrawningAntiAircraftGun();
|
_drawningAntiAircraftGun = new DrawningAntiAircraftGun();
|
||||||
_drawningAntiAircraftGun.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 255),
|
_drawningAntiAircraftGun.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 255),
|
||||||
random.Next(0, 255), random.Next(0, 255)), Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)),
|
random.Next(0, 255), random.Next(0, 255)), Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)),
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
_drawningAntiAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
_drawningAntiAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||||
_drawningAntiAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningAntiAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user