Добавлен класс DrawingPlaneEqutables
This commit is contained in:
parent
405fef33f9
commit
13de54b639
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectStormtrooper
|
||||
{
|
||||
public class DrawingPlaneEqutables : IEqualityComparer<DrawingPlane>
|
||||
{
|
||||
public bool Equals(DrawingPlane? x, DrawingPlane? y)
|
||||
{
|
||||
if (x == null || x.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
}
|
||||
if (y == null || y.EntityPlane == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
}
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityPlane.Speed != y.EntityPlane.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityPlane.Weight != y.EntityPlane.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x.EntityPlane.BodyColor != y.EntityPlane.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (x is DrawingStormtrooper && y is DrawingStormtrooper)
|
||||
{
|
||||
var xStormtrooper = (x.EntityPlane as EntityStormtrooper);
|
||||
var yStormtrooper = (y.EntityPlane as EntityStormtrooper);
|
||||
if (xStormtrooper?.AdditionalColor != yStormtrooper?.AdditionalColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (xStormtrooper?.Bombs != yStormtrooper?.Bombs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (xStormtrooper?.Rockets != yStormtrooper?.Rockets)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode([DisallowNull] DrawingPlane obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user