diff --git a/Locomotives/Locomotives/AbstractMap.cs b/Locomotives/Locomotives/AbstractMap.cs index 2708099..0aff92b 100644 --- a/Locomotives/Locomotives/AbstractMap.cs +++ b/Locomotives/Locomotives/AbstractMap.cs @@ -1,6 +1,6 @@ namespace Locomotives { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { /// /// Поле от интерфейса прорисовки @@ -60,7 +60,7 @@ /// public (int Top, int Bottom, int Left, int Right) GetObjectCoordinates() { - return + return ( (int)(_drawningObject.GetCurrentPosition().Top / _size_y), (int)(_drawningObject.GetCurrentPosition().Bottom / _size_y), @@ -239,5 +239,35 @@ /// /// protected abstract void DrawBarrierPart(Graphics g, int i, int j); + /// + /// Реализация сравнения + /// + /// + /// + public bool Equals(AbstractMap? other) + { + if (other == null) + { + return false; + } + if (_map.GetLength(0) == other._map.GetLength(0) && _map.GetLength(1) == other._map.GetLength(1)) + { + for (int i = 0; i < _map.GetLength(0); i++) + { + for (int j = 0; j < _map.GetLength(1); j++) + { + if (_map[i, j] != other._map[i, j]) + { + return false; + } + } + } + } + else + { + return false; + } + return true; + } } }