public void EliminateCutCornersForNodeAtIndex(int x, int y) { PositionedNode nodeAtIndex = TiledNodeAt(x, y); if (nodeAtIndex == null) { return; } PositionedNode nodeAL = TiledNodeAt(x - 1, y + 1); PositionedNode nodeA = TiledNodeAt(x, y + 1); PositionedNode nodeAR = TiledNodeAt(x + 1, y + 1); PositionedNode nodeR = TiledNodeAt(x + 1, y); PositionedNode nodeBR = TiledNodeAt(x + 1, y - 1); PositionedNode nodeB = TiledNodeAt(x, y - 1); PositionedNode nodeBL = TiledNodeAt(x - 1, y - 1); PositionedNode nodeL = TiledNodeAt(x - 1, y); if (nodeAL != null && nodeAtIndex.IsLinkedTo(nodeAL)) { if (nodeA == null || nodeL == null) { nodeAtIndex.BreakLinkBetween(nodeAL); } } if (nodeAR != null && nodeAtIndex.IsLinkedTo(nodeAR)) { if (nodeA == null || nodeR == null) { nodeAtIndex.BreakLinkBetween(nodeAR); } } if (nodeBR != null && nodeAtIndex.IsLinkedTo(nodeBR)) { if (nodeB == null || nodeR == null) { nodeAtIndex.BreakLinkBetween(nodeBR); } } if (nodeBL != null && nodeAtIndex.IsLinkedTo(nodeBL)) { if (nodeB == null || nodeL == null) { nodeAtIndex.BreakLinkBetween(nodeBL); } } }
public void AttachNodeToNodeAtIndex(PositionedNode node, int x, int y) { PositionedNode nodeToLinkTo = TiledNodeAt(x, y); if (nodeToLinkTo != null && !node.IsLinkedTo(nodeToLinkTo)) { node.LinkTo(nodeToLinkTo); } }