2022-11-14 21:25:33 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2022-12-13 01:49:12 +04:00
|
|
|
|
using Tractors;
|
2022-11-14 21:25:33 +04:00
|
|
|
|
|
|
|
|
|
namespace WinFormsApp1
|
|
|
|
|
{
|
|
|
|
|
class DrawningObjectTractor : IDrawningObject
|
|
|
|
|
{
|
|
|
|
|
private TractorDraw _tractor = null;
|
|
|
|
|
|
|
|
|
|
public DrawningObjectTractor(TractorDraw tractor)
|
|
|
|
|
{
|
|
|
|
|
_tractor = tractor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Step => _tractor?.Tractor?.Step ?? 0;
|
|
|
|
|
|
|
|
|
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
|
|
|
{
|
|
|
|
|
return _tractor?.GetCurrentPosition() ?? default;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-13 01:49:12 +04:00
|
|
|
|
public string GetInfo() => _tractor?.GetDataForSave();
|
|
|
|
|
|
|
|
|
|
public static IDrawningObject Create(string data) => new DrawningObjectTractor(data.CreateDrawingTraktor());
|
|
|
|
|
|
2022-11-14 21:25:33 +04:00
|
|
|
|
public void MoveObject(Direction direction)
|
|
|
|
|
{
|
|
|
|
|
_tractor?.MoveTransport(direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetObject(int x, int y, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
_tractor.SetPosition(x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IDrawningObject.DrawningObject(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
_tractor.DrawEntity(g);
|
|
|
|
|
}
|
2022-12-23 01:49:51 +04:00
|
|
|
|
|
|
|
|
|
public bool Equals(IDrawningObject? other)
|
|
|
|
|
{
|
|
|
|
|
if (other is not DrawningObjectTractor otherTraktor)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var entity = _tractor.Tractor;
|
|
|
|
|
var otherEntity = otherTraktor._tractor.Tractor;
|
|
|
|
|
if (entity.GetType() != otherEntity.GetType() ||
|
|
|
|
|
entity.Speed != otherEntity.Speed ||
|
|
|
|
|
entity.Weight != otherEntity.Weight ||
|
|
|
|
|
entity.BodyColor != otherEntity.BodyColor)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (entity is MultiTraktor entityTraktorDOP &&
|
|
|
|
|
otherEntity is MultiTraktor otherEntityTraktorDOP && (
|
|
|
|
|
entityTraktorDOP.dopAhead != otherEntityTraktorDOP.dopAhead ||
|
|
|
|
|
entityTraktorDOP.DopColor != otherEntityTraktorDOP.DopColor ||
|
|
|
|
|
entityTraktorDOP.dopBehind != otherEntityTraktorDOP.dopBehind))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-11-14 21:25:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|