Created classes: ObjectsParam and Interface class
This commit is contained in:
parent
9bd4a33db6
commit
9f2f1b0686
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ElectricLocomotive;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
|
||||
namespace ProjectElectricLocomotive.MovementStrategy
|
||||
{
|
||||
internal interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
|
||||
int GetStep { get; }
|
||||
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectElectricLocomotive.MovementStrategy
|
||||
{
|
||||
internal class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
|
||||
/// Левая граница
|
||||
public int LeftBorder => _x;
|
||||
|
||||
/// Верхняя граница
|
||||
public int TopBorder => _y;
|
||||
|
||||
/// Правая граница
|
||||
public int RightBorder => _x + _width;
|
||||
|
||||
/// Нижняя граница
|
||||
public int DownBorder => _y + _height;
|
||||
|
||||
/// Середина объекта по горизонтали
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
|
||||
/// Середина объекта по вертикали
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user