Логика стратегии MoveToBorder + исправление размеров обоих объектов
This commit is contained in:
parent
68ac0088fd
commit
21f5c7ac1b
@ -24,7 +24,7 @@ namespace AirBomber
|
|||||||
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
|
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
|
||||||
additionalColor, bool bombs, Color bombsColor, bool fuelTanks, int width, int height) :
|
additionalColor, bool bombs, Color bombsColor, bool fuelTanks, int width, int height) :
|
||||||
|
|
||||||
base(speed, weight, bodyColor, width, height, 110, 60)
|
base(speed, weight, bodyColor, width, height, 160, 118)
|
||||||
{
|
{
|
||||||
if (EntityAirPlane != null)
|
if (EntityAirPlane != null)
|
||||||
{
|
{
|
||||||
|
@ -32,11 +32,11 @@ namespace AirBomber
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки самолета
|
/// Ширина прорисовки самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _airPlaneWidth = 100;
|
protected readonly int _airPlaneWidth = 150;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки самолета
|
/// Высота прорисовки самолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _airPlaneHeight = 55;
|
protected readonly int _airPlaneHeight = 118;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
switch
|
switch
|
||||||
{
|
{
|
||||||
0 => new MoveToCenter(),
|
0 => new MoveToCenter(),
|
||||||
//1 => new MoveToBorder(),
|
1 => new MoveToBorder(),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
if (_abstractStrategy == null)
|
if (_abstractStrategy == null)
|
||||||
|
27
AirBomber/AirBomber/MoveToBorder.cs
Normal file
27
AirBomber/AirBomber/MoveToBorder.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
public class MoveToBorder : AbstractStrategy
|
||||||
|
{
|
||||||
|
protected override bool IsTargetDestinaion()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null) return false;
|
||||||
|
|
||||||
|
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void MoveToTarget()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null) return;
|
||||||
|
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user