Первый шаг готов
This commit is contained in:
parent
a66e4d604a
commit
8aa272b0cb
@ -40,5 +40,63 @@ namespace Artilleries
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class SetArtilleriesGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
public int Count => _places.Count;
|
||||
@ -36,6 +36,11 @@ namespace Artilleries
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_places.Contains(artillery))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_places.Insert(position, artillery);
|
||||
|
||||
return position;
|
||||
|
Loading…
Reference in New Issue
Block a user