Compare commits
2 Commits
22c86b7b55
...
481d4571ed
Author | SHA1 | Date | |
---|---|---|---|
481d4571ed | |||
53ab3a7e32 |
@ -14,14 +14,14 @@ namespace ProjectArtilleryUnit.Drawnings
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="helicopterArea">Признак наличия вертолетной площадки</param>
|
||||
/// <param name="gun">Признак наличия шлюпок</param>
|
||||
/// <param name="luke">Признак наличия пушки</param>
|
||||
/// <param name="muzzle">Признак наличия дула</param>
|
||||
/// <param name="gun">Признак наличия ракетной установки</param>
|
||||
/// <param name="luke">Признак наличия люка</param>
|
||||
|
||||
public DrawningMilitaryArtilleryUnit(int speed, double weight, Color bodyColor, Color additionalColor, bool helicopterArea, bool gun, bool luke)
|
||||
public DrawningMilitaryArtilleryUnit(int speed, double weight, Color bodyColor, Color additionalColor, bool muzzle, bool gun, bool luke)
|
||||
: base(150, 50)
|
||||
{
|
||||
EntityArtilleryUnit = new EntityMilitaryArtilleryUnit(speed, weight, bodyColor, additionalColor, helicopterArea, gun, luke);
|
||||
EntityArtilleryUnit = new EntityMilitaryArtilleryUnit(speed, weight, bodyColor, additionalColor, muzzle, gun, luke);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
|
@ -131,24 +131,24 @@ namespace ProjectArtilleryUnit
|
||||
return;
|
||||
}
|
||||
|
||||
DrawningArtilleryUnit? tank = null;
|
||||
DrawningArtilleryUnit? artilleryUnit = null;
|
||||
int counter = 100;
|
||||
while (tank == null)
|
||||
while (artilleryUnit == null)
|
||||
{
|
||||
tank = _company.GetRandomObject();
|
||||
artilleryUnit = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tank == null)
|
||||
if (artilleryUnit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormArtilleryUnit form = new()
|
||||
{
|
||||
SetArtilleryUnit = tank
|
||||
SetArtilleryUnit = artilleryUnit
|
||||
};
|
||||
form.ShowDialog();
|
||||
|
||||
|
@ -10,36 +10,36 @@ namespace ProjectArtilleryUnit.MovementStrategy
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningArtilleryUnit или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningArtilleryUnit? _tank = null;
|
||||
private readonly DrawningArtilleryUnit? _artilleryUnit = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="tank">Объект класса DrawningArtilleryUnit</param>
|
||||
public MoveableArtilleryUnit(DrawningArtilleryUnit tank)
|
||||
/// <param name="artilleryUnit">Объект класса DrawningArtilleryUnit</param>
|
||||
public MoveableArtilleryUnit(DrawningArtilleryUnit artilleryUnit)
|
||||
{
|
||||
_tank = tank;
|
||||
_artilleryUnit = artilleryUnit;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tank == null || _tank.EntityArtilleryUnit == null ||
|
||||
!_tank.GetPosX.HasValue || !_tank.GetPosY.HasValue)
|
||||
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null ||
|
||||
!_artilleryUnit.GetPosX.HasValue || !_artilleryUnit.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_tank.GetPosX.Value,
|
||||
_tank.GetPosY.Value, _tank.GetWidth, _tank.GetHeight);
|
||||
return new ObjectParameters(_artilleryUnit.GetPosX.Value,
|
||||
_artilleryUnit.GetPosY.Value, _artilleryUnit.GetWidth, _artilleryUnit.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_tank?.EntityArtilleryUnit?.Step ?? 0);
|
||||
public int GetStep => (int)(_artilleryUnit?.EntityArtilleryUnit?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_tank == null || _tank.EntityArtilleryUnit == null)
|
||||
if (_artilleryUnit == null || _artilleryUnit.EntityArtilleryUnit == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _tank.MoveTransport(GetDirectionType(direction));
|
||||
return _artilleryUnit.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
/// <summary>
|
||||
/// Конвертация из MovementDirection в DirectionType
|
||||
|
Loading…
Reference in New Issue
Block a user