Пример #1
0
        public void CanNotAccessTileSetupEdges(EnvironmentTile tileChange)
        {
            // in this case, the directions are reversed
            bool swapDirections = true;

            if (tileChange.TileCanAccess(Direction.North))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _topLeftOffset);
                offsetPoint(ref pointB, _topRightOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.NorthTile, swapDirections);
            }
            else
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _topLeftOffset);
                RemoveEdgeFromCollections(offset, tileChange, true);
            }
            if (tileChange.TileCanAccess(Direction.West))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _bottomLeftOffset);
                offsetPoint(ref pointB, _topLeftOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.WestTile, swapDirections);
            }
            else
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _bottomLeftOffset);
                RemoveEdgeFromCollections(offset, tileChange, true);
            }
            if (tileChange.TileCanAccess(Direction.East))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _topRightOffset);
                offsetPoint(ref pointB, _bottomRightOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.EastTile, swapDirections);
            }
            else
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _topRightOffset);
                RemoveEdgeFromCollections(offset, tileChange, true);
            }
            if (tileChange.TileCanAccess(Direction.South))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _bottomRightOffset);
                offsetPoint(ref pointB, _bottomLeftOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.SouthTile, swapDirections);
            }
            else
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _bottomRightOffset);
                RemoveEdgeFromCollections(offset, tileChange, true);
            }
        }
Пример #2
0
        public void CanAccessTileSetupEdges(EnvironmentTile tileChange, bool botherRemoving)
        {
            bool swapDirections = false;

            if (!tileChange.TileCanAccess(Direction.North))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _topLeftOffset);
                offsetPoint(ref pointB, _topRightOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.NorthTile, swapDirections);
            }
            else if (botherRemoving)
            {
                Point offset = tileChange.Position;
                // comes from the top right, this tile on the left normal
                offsetPoint(ref offset, _topRightOffset);
                RemoveEdgeFromCollections(offset, tileChange, false);
            }
            if (!tileChange.TileCanAccess(Direction.West))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _bottomLeftOffset);
                offsetPoint(ref pointB, _topLeftOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.WestTile, swapDirections);
            }
            else if (botherRemoving)
            {
                Point offset = tileChange.Position;
                // we want to remove the edge starting at top left
                // with this tile on the left normal
                offsetPoint(ref offset, _topLeftOffset);
                RemoveEdgeFromCollections(offset, tileChange, false);
            }
            if (!tileChange.TileCanAccess(Direction.East))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _topRightOffset);
                offsetPoint(ref pointB, _bottomRightOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.EastTile, swapDirections);
            }
            else if (botherRemoving)
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _bottomRightOffset);
                RemoveEdgeFromCollections(offset, tileChange, false);
            }
            if (!tileChange.TileCanAccess(Direction.South))
            {
                Point pointA = tileChange.Position;
                Point pointB = tileChange.Position;
                offsetPoint(ref pointA, _bottomRightOffset);
                offsetPoint(ref pointB, _bottomLeftOffset);
                CreateEdge(pointA, pointB, tileChange, tileChange.SouthTile, swapDirections);
            }
            else if (botherRemoving)
            {
                Point offset = tileChange.Position;
                offsetPoint(ref offset, _bottomLeftOffset);
                RemoveEdgeFromCollections(offset, tileChange, false);
            }
        }