реализация IEquatable для AbstractMap
This commit is contained in:
parent
f866ee1024
commit
1bec916bb1
@ -1,6 +1,6 @@
|
||||
namespace Locomotives
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле от интерфейса прорисовки
|
||||
@ -60,7 +60,7 @@
|
||||
/// <returns></returns>
|
||||
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 @@
|
||||
/// <param name="i"></param>
|
||||
/// <param name="j"></param>
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
/// <summary>
|
||||
/// Реализация сравнения
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user