88 lines
2.7 KiB
C#
88 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Airbus
|
|
{
|
|
internal class DrawningObjectAirplane : IDrawningObject
|
|
{
|
|
private DrawningAirplane _airplane = null;
|
|
|
|
public DrawningObjectAirplane(DrawningAirplane airplane)
|
|
{
|
|
_airplane = airplane;
|
|
}
|
|
public DrawningAirplane GetAirplane => _airplane;
|
|
public float Step => _airplane?.airplane?.Step ?? 0;
|
|
public void DrawningObject(Graphics g)
|
|
{
|
|
_airplane?.DrawTransport(g);
|
|
}
|
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
|
{
|
|
return _airplane?.GetCurrentPosition() ?? default;
|
|
}
|
|
public void MoveObject(Direction direction)
|
|
{
|
|
_airplane?.MoveTransport(direction);
|
|
}
|
|
public void SetObject(int x, int y, int width, int height)
|
|
{
|
|
_airplane?.SetPosition(x, y, width, height);
|
|
}
|
|
|
|
public string GetInfo() => _airplane?.GetDataForSave();
|
|
public static IDrawningObject Create(string data) => new DrawningObjectAirplane(data.CreateDrawningAirplane());
|
|
|
|
public bool Equals(IDrawningObject? other)
|
|
{
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
var otherAirplane = other as DrawningObjectAirplane;
|
|
if (otherAirplane == null)
|
|
{
|
|
return false;
|
|
}
|
|
var airplane = _airplane.airplane;
|
|
var otherAirplaneAirplane = otherAirplane._airplane.airplane;
|
|
if (airplane.GetType() != otherAirplaneAirplane.GetType())
|
|
{
|
|
return false;
|
|
}
|
|
if (airplane.Speed != otherAirplaneAirplane.Speed)
|
|
{
|
|
return false;
|
|
}
|
|
if (airplane.Weight != otherAirplaneAirplane.Weight)
|
|
{
|
|
return false;
|
|
}
|
|
if (airplane.BodyColor != otherAirplaneAirplane.BodyColor)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (airplane is EntityAirbus airbus && otherAirplaneAirplane is EntityAirbus otherAirbus)
|
|
{
|
|
if (airbus.DopColor != otherAirbus.DopColor)
|
|
{
|
|
return false;
|
|
}
|
|
if (airbus.Engine != otherAirbus.Engine)
|
|
{
|
|
return false;
|
|
}
|
|
if (airbus.Compartment != otherAirbus.Compartment)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|