74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace AircraftCarrier
|
||
{
|
||
internal class DrawingObjectWarship : IDrawingObject
|
||
{
|
||
private DrawingWarship _warship = null;
|
||
|
||
public DrawingObjectWarship(DrawingWarship warship)
|
||
{
|
||
_warship = warship;
|
||
}
|
||
public float Step => _warship?.Warship?.Step ?? 0;
|
||
|
||
public DrawingWarship GetWarship => _warship;
|
||
|
||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||
{
|
||
return _warship?.GetCurrentPosition() ?? default;
|
||
}
|
||
|
||
public string GetInfo()
|
||
{
|
||
return _warship?.GetDataForSave();
|
||
}
|
||
|
||
public void MoveObject(Direction direction)
|
||
{
|
||
_warship?.MoveTransport(direction);
|
||
}
|
||
|
||
public void SetObject(int x, int y, int width, int height)
|
||
{
|
||
_warship.SetPosition(x, y, width, height);
|
||
}
|
||
|
||
void IDrawingObject.DrawningObject(Graphics g) => _warship.DrawTransport(g);
|
||
|
||
public static IDrawingObject Create(string data) => new DrawingObjectWarship(data.CreateDrawningWarship());
|
||
|
||
public bool Equals(IDrawingObject? other)
|
||
{
|
||
if (other is not DrawingObjectWarship otherWarship)
|
||
{
|
||
return false;
|
||
}
|
||
var warship = _warship.Warship;
|
||
var otherEntity = otherWarship._warship.Warship;
|
||
if (warship.GetType() != otherEntity.GetType() ||
|
||
warship.Speed != otherEntity.Speed ||
|
||
warship.Weight != otherEntity.Weight ||
|
||
warship.BodyColor != otherEntity.BodyColor)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (warship is EntityAircraftCarrier entityAircraftCarrier &&
|
||
otherEntity is EntityAircraftCarrier otherEntityAircraftCarrier && (
|
||
entityAircraftCarrier.BodyKit != otherEntityAircraftCarrier.BodyKit ||
|
||
entityAircraftCarrier.Сabin != otherEntityAircraftCarrier.Сabin ||
|
||
entityAircraftCarrier.SuperEngine != otherEntityAircraftCarrier.SuperEngine ||
|
||
entityAircraftCarrier.DopColor != otherEntityAircraftCarrier.DopColor))
|
||
{
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
}
|
||
}
|