using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Artilleries { internal class DrawingObjectArtillery : IDrawingObject { private DrawingArtillery _artillery = null; public DrawingArtillery Artillery => _artillery; public DrawingObjectArtillery(DrawingArtillery artillery) { _artillery = artillery; } public float Step => _artillery?.Artillery?.Step ?? 0; public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() { return _artillery?.GetCurrentPosition() ?? default; } public void MoveObject(Direction direction) { _artillery?.MoveTransport(direction); } public void SetObject(int x, int y, int width, int height) { _artillery.SetPosition(x, y, width, height); } public void DrawingObject(Graphics g) { _artillery.DrawTransport(g); } public string GetInfo() => _artillery?.GetDateForSave(); public static IDrawingObject Create(string data) => new DrawingObjectArtillery(data.CreateDrawingArtillery()); public bool Equals(IDrawingObject? other) { if (other == null) { return false; } var otherArtillery = other as DrawingObjectArtillery; if (otherArtillery == null) { return false; } var artillery = _artillery.Artillery; var otherArtilleryArtillery = otherArtillery._artillery.Artillery; if (artillery.GetType() != otherArtilleryArtillery.GetType()) { return false; } if (artillery.Speed != otherArtilleryArtillery.Speed) { return false; } if (artillery.Weight != otherArtilleryArtillery.Weight) { return false; } if (artillery.BodyColor != otherArtilleryArtillery.BodyColor) { return false; } if (artillery is EntityAdvancedArtillery advanced && otherArtilleryArtillery is EntityAdvancedArtillery otherAdvanced) { if (advanced.DopColor != otherAdvanced.DopColor) { return false; } if (advanced.Weapon != otherAdvanced.Weapon) { return false; } if (advanced.SalvoBattery != otherAdvanced.SalvoBattery) { return false; } } return true; } } }