81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Catamaran
|
|
{
|
|
internal class DrawingObjectBoat : IDrawingObject
|
|
{
|
|
private DrawingBoat _catamaran = null;
|
|
public DrawingObjectBoat(DrawingBoat catamaran)
|
|
{
|
|
_catamaran = catamaran;
|
|
}
|
|
public DrawingBoat GetBoat => _catamaran;
|
|
public float Step => _catamaran?.Catamaran?.Step ?? 0;
|
|
public (float Left, float Right, float Top, float Bottom)
|
|
GetCurrentPosition()
|
|
{
|
|
return _catamaran?.GetCurrentPosition() ?? default;
|
|
}
|
|
|
|
public bool Equals(IDrawingObject other)
|
|
{
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
var otherBoat = other as DrawingObjectBoat;
|
|
if (otherBoat == null)
|
|
{
|
|
return false;
|
|
}
|
|
var boat = _catamaran.Catamaran;
|
|
var otherBoatBoat = otherBoat._catamaran.Catamaran;
|
|
if (boat.Speed != otherBoatBoat.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (boat.Weight != otherBoatBoat.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (boat.BodyColor != otherBoatBoat.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//доделать проверки в случае продвинутого объекта
|
|
|
|
var catamaran = boat as EntityCatamaran;
|
|
var otherCatamaran = otherBoatBoat as EntityCatamaran;
|
|
|
|
if (catamaran == null && otherCatamaran == null) return true;
|
|
if (catamaran == null || otherCatamaran == null) return false;
|
|
if (catamaran.DopColor != otherCatamaran.DopColor) return false;
|
|
if (catamaran.Sail != otherCatamaran.Sail) return false;
|
|
if (catamaran.Floats != otherCatamaran.Floats) return false;
|
|
|
|
return true;
|
|
}
|
|
public void MoveObject(Direction direction)
|
|
{
|
|
_catamaran?.MoveTransport(direction);
|
|
}
|
|
public void SetObject(int x, int y, int width, int height)
|
|
{
|
|
_catamaran?.SetPosition(x, y, width, height);
|
|
}
|
|
public void DrawingObject(Graphics g)
|
|
{
|
|
_catamaran?.DrawTransport(g);
|
|
}
|
|
public string GetInfo() => _catamaran?.GetDataForSave();
|
|
public static IDrawingObject Create(string data) => new DrawingObjectBoat(data.CreateDrawingBoat());
|
|
|
|
}
|
|
}
|