private GameObject WallFromDirection(Walls wallScript, WallDirections wallDirection) { if (!wallScript) { return(null); } switch (wallDirection) { case WallDirections.North: return(wallScript.wallN); case WallDirections.East: return(wallScript.wallE); case WallDirections.South: return(wallScript.wallS); case WallDirections.West: return(wallScript.wallW); default: return(null); } }
private Glyph CalculateAdjacencyGlyph(Vector3 myLoc) { WallSquare north = Map.GetSafeSquare(myLoc + Vector3.North) as WallSquare; WallSquare south = Map.GetSafeSquare(myLoc + Vector3.South) as WallSquare; WallSquare east = Map.GetSafeSquare(myLoc + Vector3.East) as WallSquare; WallSquare west = Map.GetSafeSquare(myLoc + Vector3.West) as WallSquare; WallDirections hash = WallDirections.None; hash |= (north == null) ? WallDirections.None : WallDirections.North; hash |= (south == null) ? WallDirections.None : WallDirections.South; hash |= (east == null) ? WallDirections.None : WallDirections.East; hash |= (west == null) ? WallDirections.None : WallDirections.West; if (glyphs == null) { SetupGlyphs(); } if (!glyphs.ContainsKey(hash)) { Console.WriteLine("WHAT!"); } return(glyphs[hash]); }
public void FuseWallsInLine(GameObject inputWall) { WallDirections wallDirection = WallObjectToDirection(inputWall); if (wallDirection != WallDirections.None) { Transform neighbourTransform; Walls currentWallsPiece = null; GameObject targetWall = null; bool isNorthOrSouth; int wallLength = 1; isNorthOrSouth = (wallDirection == WallDirections.North || wallDirection == WallDirections.South); neighbourTransform = isNorthOrSouth ? neighbourE : neighbourS; if (neighbourTransform) { currentWallsPiece = neighbourTransform.GetComponent <Walls>(); targetWall = WallFromDirection(currentWallsPiece, wallDirection); } while (currentWallsPiece && targetWall) { wallLength++; Destroy(targetWall); if (isNorthOrSouth && currentWallsPiece.neighbourE) { currentWallsPiece = currentWallsPiece.neighbourE.GetComponent <Walls>(); } else if (!isNorthOrSouth && currentWallsPiece.neighbourS) { currentWallsPiece = currentWallsPiece.neighbourS.GetComponent <Walls>(); } else { currentWallsPiece = null; } targetWall = WallFromDirection(currentWallsPiece, wallDirection); } if (wallLength > 1) { FixFusedWall(inputWall, wallLength, isNorthOrSouth); } inputWall.transform.parent = transform.parent; } }