private bool IsPortalEntrance(XY spacePosition, XY endpoint, XY portalLocation)
        {
            var connectPointX = endpoint.X - portalLocation.X + 1;
            var connectPointY = endpoint.Y - portalLocation.Y + 1;

            return(spacePosition.Equals(new XY(connectPointX, connectPointY)));
        }
Esempio n. 2
0
        public void Equals_AreSameObject_ReturnsTrue()
        {
            var first = new XY(1, 1);

            var res = first.Equals(first);

            Assert.That(res, Is.True);
        }
Esempio n. 3
0
        public void Equals_WhenCalled_Returns(int firstX, int firstY, int secondX, int secondY, bool expResult)
        {
            var first  = new XY(firstX, firstY);
            var second = new XY(secondX, secondY);

            var res = first.Equals(second);

            Assert.That(res, Is.EqualTo(expResult));
        }
        private bool IsPortalConnection(int x, int y)
        {
            var spacePosition = new XY(x % 3, y % 3);

            foreach (var portal in _layer.Portals.Where(z => z.Location.Equals(GetSpaceCoordinates(x, y))))
            {
                if (spacePosition.Equals(new XY(1, 1)) ||
                    IsPortalEntrance(spacePosition, portal.Obj.Endpoint1, portal.Location) ||
                    IsPortalEntrance(spacePosition, portal.Obj.Endpoint2, portal.Location))
                {
                    return(true);
                }
            }
            return(false);
        }