Compare commits

...

6 Commits

9 changed files with 139 additions and 6 deletions

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class AbstractStrategy
{
}
}

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AirBomber;
namespace AirBomber namespace AirBomber
{ {
@ -16,9 +17,8 @@ namespace AirBomber
/// <param name="weight">Вес</param> /// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param> /// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param> /// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bodyKit">Признак наличия обвеса</param> /// <param name="bombs">Признак наличия обвеса</param>
/// <param name="wing">Признак наличия антикрыла</param> /// <param name="fuelTanks">Признак наличия антикрыла</param>
/// <param name="sportLine">Признак наличия гоночной полосы</param>
/// <param name="width">Ширина картинки</param> /// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param> /// <param name="height">Высота картинки</param>
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
@ -28,17 +28,18 @@ namespace AirBomber
{ {
if (EntityAirPlane != null) if (EntityAirPlane != null)
{ {
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks); EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, bombsColor, fuelTanks);
} }
} }
public override void DrawPlane(Graphics g) public override void DrawPlane(Graphics g)
{ {
if (EntityAirPlane is not EntityAirPlane airBomber) if (EntityAirPlane is not EntityAirBomber airBomber)
{ {
return; return;
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor); Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
Brush bombsColor = new SolidBrush(airBomber.BombsColor);
base.DrawPlane(g); base.DrawPlane(g);
// обвесы // обвесы
if (airBomber.Bombs) if (airBomber.Bombs)

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AirBomber;
namespace AirBomber namespace AirBomber
{ {
@ -214,6 +215,75 @@ namespace AirBomber
} }
); );
} }
/// <summary>
/// Координата X объекта
/// </summary>
public int GetPosX => _startPosX;
/// <summary>
/// Координата Y объекта
/// </summary>
public int GetPosY => _startPosY;
/// <summary>
/// Ширина объекта
/// </summary>
public int GetWidth => _airPlaneWidth;
/// <summary>
/// Высота объекта
/// </summary>
public int GetHeight => _airPlaneHeight;
/// <summary>
/// Проверка, что объект может переместится по указанному направлению
/// </summary>
/// <param name="direction">Направление</param>
/// <returns>true - можно переместится по указанному направлению</returns>
public bool CanMove(DirectionType direction)
{
if (EntityAirPlane == null)
{
return false;
}
return direction switch
{
//влево
DirectionType.Left => _startPosX - EntityAirPlane.Step > 0,
//вверх
DirectionType.Up => _startPosY - EntityAirPlane.Step > 0,
// вправо
DirectionType.Right => false,// TODO: Продумать логику
//вниз
DirectionType.Down => false,// TODO: Продумать логику
_ => false,
};
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MovePlane(DirectionType direction)
{
if (!CanMove(direction) || EntityAirPlane == null)
{
return;
}
switch (direction)
{
//влево
case DirectionType.Left:
_startPosX -= (int)EntityAirPlane.Step;
break;
//вверх
case DirectionType.Up:
_startPosY -= (int)EntityAirPlane.Step;
break;
// вправо
case DirectionType.Right:
_startPosX += (int)EntityAirPlane.Step;
break;
//вниз
case DirectionType.Down:
_startPosY += (int)EntityAirPlane.Step;
break;
}
}
} }
} }

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class DrawningObjectAirPlane
{
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AirBomber;
namespace AirBomber namespace AirBomber
{ {

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AirBomber;
namespace AirBomber namespace AirBomber
{ {

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal interface IMoveableObject
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class ObjectParameters
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class Status
{
}
}