74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ship
|
|
{
|
|
internal class DrawingObject : IDrawingObject
|
|
{
|
|
private DrawingShip _ship = null;
|
|
|
|
public DrawingObject(DrawingShip ship)
|
|
{
|
|
_ship = ship;
|
|
}
|
|
|
|
public float Step => _ship?.Ship?.Step ?? 0;
|
|
|
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
{
|
|
return _ship?.GetCurrentPosition() ?? default;
|
|
}
|
|
|
|
public void MoveObject(Direction direction)
|
|
{
|
|
_ship?.MoveTransport(direction);
|
|
}
|
|
|
|
public void SetObject(int x, int y, int width, int height)
|
|
{
|
|
_ship.SetPosition(x, y, width, height);
|
|
}
|
|
|
|
void IDrawingObject.DrawningObject(Graphics g)
|
|
{
|
|
_ship.DrawTransport(g);
|
|
}
|
|
|
|
public string GetInfo() => _ship?.GetDataForSave();
|
|
|
|
public static IDrawingObject Create(string data) => new DrawingObject(data.CreateDrawingShip());
|
|
|
|
public bool Equals(IDrawingObject? other)
|
|
{
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
var otherCar = other as DrawingObject;
|
|
if (otherCar == null)
|
|
{
|
|
return false;
|
|
}
|
|
var car = _ship.Ship;
|
|
var otherCarCar = otherCar._ship.Ship;
|
|
if (car.Speed != otherCarCar.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (car.Weight != otherCarCar.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (car.BodyColor != otherCarCar.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
// TODO доделать проверки в случае продвинутого объекта
|
|
return true;
|
|
}
|
|
}
|
|
}
|