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