// creates a passage between the specified cells private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction) { MazePassage passage = Instantiate(passagePrefab) as MazePassage; passage.Initialize(cell, otherCell, direction); passage = Instantiate(passagePrefab) as MazePassage; passage.Initialize(otherCell, cell, direction.GetOpposite()); }
public override void Initialize (MazeCell primary, MazeCell other, MazeDirection direction) { float localX = hinge.localScale.x; float localY = hinge.localScale.y; float localZ = hinge.localScale.z; base.Initialize(primary, other, direction); if (OtherSideOfDoor != null) { isMirrored = true; hinge.localScale = new Vector3(-localX, localY, localZ); Vector3 p = hinge.localPosition; p.x *= -1; hinge.localPosition = p; } for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child != hinge) { child.GetComponent<Renderer>().material = cell.room.settings.wallMaterial; } } }
public override string ToString() { MazeDirection[] directions = new MazeDirection[5] { MazeDirection.None, MazeDirection.Up, MazeDirection.Right, MazeDirection.Down, MazeDirection.Left }; StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("X: {0}", this.X)); sb.AppendLine(string.Format("Y: {0}", this.Y)); sb.AppendLine(string.Format("CanContinueBuild: {0}", this.CanContinueBuild)); sb.AppendLine(string.Format("Built: {0}", this.HasPath)); sb.AppendLine(string.Format("BuildDirections: ")); foreach (MazeDirection direction in directions) { if (this.BuildDirections.Contains(direction)) { sb.Append(string.Format(" {0} ", direction)); } } sb.AppendLine(string.Format("ExploreDirections: ")); foreach (MazeDirection direction in directions) { if (this.ExploreDirections.Contains(direction)) { sb.Append(string.Format(" {0} ", direction)); } } return sb.ToString(); }
void OnControllerColliderHit(ControllerColliderHit hit) { Rigidbody body = hit.collider.attachedRigidbody; MazeCell cell = hit.gameObject.GetComponentInParent<MazeCell>(); if (cell == null) return; if(cell != currentCell) { if(currentCell != null) currentCell.OnPlayerExit(); cell.OnPlayerEnter(); } currentCell = cell; Vector3 transformDirection = new Vector3(Mathf.Round(transform.forward.x), 0f, Mathf.Round(transform.forward.z)); IntVector2 direction = new IntVector2((int) transformDirection.x, (int) transformDirection.z); if(direction.x != 0 && direction.z != 0) { if (Random.Range(0, 1) == 1) direction.x = 0; else direction.z = 0; } MazeDirection mazeDirection = MazeDirections.FromIntVector2(direction); faceDirection = mazeDirection; }
private void Move(MazeDirection direction) { MazeCellEdge edge = currentCell.GetEdge(direction); if (edge is MazePassage) { SetLocation(edge.otherCell); } }
private void Move(MazeDirection direction){ //Debug.Log (currentCell.coordinates.x + ", " + currentCell.coordinates.z); MazeCellEdge edge = currentCell.GetEdge (direction); if (edge is MazePassage) { SetLocation (edge.otherCell); } }
public virtual void Initialize (MazeCell cell, MazeDirection direction = MazeDirection.North) { this.cell = cell; this.direction = direction; transform.parent = cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); }
private void CreateWall(MazeCell cell, MazeCell otherCell, MazeDirection direction){ MazeWall wall = Instantiate (wallFab) as MazeWall; wall.Initialize (cell, otherCell, direction); if(otherCell != null){ wall = Instantiate (wallFab) as MazeWall; wall.Initialize (otherCell, cell, direction.GetOpposite ()); } }
public void Initialize (MazeCell cell, MazeCell otherCell, MazeDirection direction) { this.cell = cell; this.otherCell = otherCell; this.direction = direction; cell.SetEdge(direction, this); transform.parent = cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); }
public void CreateWall(MazeCell cell, MazeCell otherCell, MazeDirection direction) { MazeWall wall = Instantiate(wallprefabs[Random.Range(0, wallprefabs.Length)]) as MazeWall; wall.Initialize(cell, otherCell, direction); if(otherCell != null) { wall = Instantiate(wallprefabs[Random.Range(0, wallprefabs.Length)]) as MazeWall; wall.Initialize(otherCell, cell, direction.GetOpposite()); } }
private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction) { MazePassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab; MazePassage passage = Instantiate(prefab) as MazePassage; passage.Initialize(cell, otherCell, direction); passage = Instantiate(prefab) as MazePassage; if (passage is MazeDoor) { otherCell.Initialize(CreateRoom(cell.room.settingsIndex)); } else { otherCell.Initialize(cell.room); } passage.Initialize(otherCell, cell, direction.GetOpposite()); }
private void CreateAllCellsAndHallwaysBasedOnGraph() { if (transform.localScale != new Vector3(1f, 1f, 1f)) { transform.localScale = new Vector3(1f, 1f, 1f); } MazeDirection[] dirs = new MazeDirection[] { MazeDirection.North, MazeDirection.South, MazeDirection.East, MazeDirection.West }; //a cell will exist at each node for (int i = 0; i < MazeGrid.x; i++) { for (int j = 0; j < MazeGrid.y; j++) { CreateCell(new IntVector2(i, j)); } } //decide whether to place walls or doors in each of the 4 directions around a cell for (int i = 0; i < MazeGrid.x; i++) { for (int j = 0; j < MazeGrid.y; j++) { foreach (var dir in dirs) { IntVector2 move = dir.ToIntVector2(); IntVector2 newCoord = move + new IntVector2(i, j); if (ValidCoordinate(newCoord)) { GraphNode node1 = MazeGrid.grid[i, j]; GraphNode node2 = MazeGrid.grid[newCoord.x, newCoord.z]; //check if edge exists if the new coordinate was valid: if (MazeGrid.GetEdge(node1, node2) == null) { CreateWall(cells[i, j], GetCell(newCoord), dir); } else { CreatePassage(cells[i, j], GetCell(newCoord), dir); } } else { CreateWall(cells[i, j], null, dir); } } } } //loop through edges and create hallways foreach (var e in MazeGrid.edgeList) { CreateHallway(e); } //make the maze bigger or smaller as desired transform.localScale = new Vector3(MazeScale, MazeScale, MazeScale); }
private void Move (MazeDirection direction) { MazeCellEdge edge = currentCell.GetEdge(direction); if (edge is MazePassage) { SetLocation(edge.otherCell); audio.Stop(); audio.PlayOneShot(_Footsteps, 0.5f); } else { audio.Stop(); audio.PlayOneShot(_cantMove[Random.Range(0, _cantMove.Length)], 1f); } }
public override void Initialize(MazeCell primary, MazeCell other, MazeDirection direction) { base.Initialize(primary, other, direction); if (OtherSideOfDoor != null) { hinge.localScale = new Vector3(-1f, 1f, 1f); Vector3 p = hinge.localPosition; p.x = -p.x; hinge.localPosition = p; } for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child != hinge) { child.GetComponent<Renderer>().material = cell.room.settings.wallMaterial; } } }
private void Move1(MazeDirection direction,bool playsound) { MazeCell nextcell = Maze.instance.getLongNextMazeCell(currentCell, direction); directionKeyWating = MazeDirection.None;// khong setRotation(direction); currentDirection = direction; if (nextcell != null) { SetLocation(nextcell); targetCell = nextcell; } if(playsound) { SoundEngine.playLoop(SoundEngine.instance.move); } }
//initialize a directional signpost pointing in direction dir and in a quadrant of the cell not //containing the player located at playerPosition. public void AddSignPost(MazeDirection dir, Vector3 playerPosition) { if (signpostInstance != null) { return; } signpostInstance = Instantiate(signpostPrefab) as DirectionalSignPost; signpostInstance.transform.parent = transform; Vector3 relativePos = playerPosition - transform.localPosition; signpostInstance.transform.localPosition = new Vector3( (relativePos.x <= 0 ? 0.25f : -0.25f), -1.5f, (relativePos.z <= 0 ? 0.25f : -0.25f) ); signpostInstance.transform.localRotation *= dir.ToRotation(); }
private void moveContinue(MazeDirection _direction)// khi dang di chuyen ma co nut nhan { if((currentDirection == MazeDirection.North && _direction == MazeDirection.South ) || (currentDirection == MazeDirection.South && _direction == MazeDirection.North ) || (currentDirection == MazeDirection.East && _direction == MazeDirection.West ) || (currentDirection == MazeDirection.West && _direction == MazeDirection.East ) ) { MazeCell tempCurrentcell = Maze.instance.findCell(transform.position); MazeCell nextcell = currentCell;//.instance.getLongNextMazeCell(currentCell, _direction); // directionKeyWating = MazeDirection.None;// khong setRotation(_direction); if (nextcell != null) { currentCell = tempCurrentcell; SetLocation(nextcell); targetCell = nextcell; } // dung la } }
public void CreateWall (MazeCell cell, MazeCell otherCell, MazeDirection direction) { var randomNumbers = GetRandomNumberForWallPrefab (); WallGeneration (cell, otherCell, direction, randomNumbers); }
private void GeneratePassageSameRoom (MazeCell cell, MazeCell otherCell, MazeDirection direction) { var prefab = maze.passagePrefab; MazePassage passage = Maze.Instantiate(prefab) as MazePassage; passage.Initialize(cell, otherCell, direction); passage = Maze.Instantiate(prefab) as MazePassage; passage.Initialize (otherCell, cell, direction.GetOpposite ()); if (cell.room != otherCell.room) RoomAssimilation (cell, otherCell); }
public int Solve() { // Parse the map and work out where we're going var map = Input.SplitByNewLines().Skip(1).Select(line => line.ToCharArray()).ToArray(); int currentColumn = Array.IndexOf(map[0], '|'); int currentRow = 0; MazeDirection direction = MazeDirection.Down; var lettersFound = new List <char>(); int steps = 0; while (true) { if (currentRow < 0 || currentRow >= map.Length || currentColumn < 0 || currentColumn >= map[currentRow].Length) { // We've run off the edge - hopefully we're done. Console.WriteLine($"Off the edge! Solution: {string.Join("", lettersFound.ToArray())}"); return(steps); } steps++; if (map[currentRow][currentColumn] >= 'A' && map[currentRow][currentColumn] <= 'Z') { // Woo, found a letter! var foundLetter = map[currentRow][currentColumn]; if (lettersFound.Contains(foundLetter)) { // Uh oh, we assume this is wrong; what shall we try doing? Console.WriteLine($"Oo, found {foundLetter} again; stop here"); return(steps); } else { lettersFound.Add(foundLetter); var allLetters = string.Join("", lettersFound.ToArray()); if (allLetters == "DWNBGECOMY") { return(steps); } } } Console.WriteLine($"Going {direction} at {currentRow}, {currentColumn} having found {string.Join("", lettersFound.ToArray())}"); switch (direction) { case MazeDirection.Down: // Base case: Assume we were already heading down via a sensible route, either a | or a letter or crossing over a - or something. So we // want to continue down unless we're o a + and going straight on will land us over the edge or on an empty space if ((currentRow == map.Length - 1 || map[currentRow + 1][currentColumn] == ' ') && map[currentRow][currentColumn] == '+') { // This is the "about to do something silly, but we can turn a corner so we're ok" case if (currentColumn > 0 && (map[currentRow][currentColumn - 1] == '-' || (map[currentRow][currentColumn - 1] >= 'A' && map[currentRow][currentColumn - 1] <= 'Z'))) { currentColumn--; direction = MazeDirection.Left; } else if (currentColumn < map[currentRow].Length - 1 && (map[currentRow][currentColumn + 1] == '-' || (map[currentRow][currentColumn + 1] >= 'A' && map[currentRow][currentColumn + 1] <= 'Z'))) { currentColumn++; direction = MazeDirection.Right; } else { throw new InvalidOperationException( "Oops, looks like we can and should turn a corner, but we can't, which is suspicious"); } } else { { // We can keep heading down, so let's do it currentRow++; } } break; case MazeDirection.Up: // BIG COMMENT TO MISS LATER: This should be identical to the DOWN case, but inverted // Base case: Assume we were already heading up via a sensible route, either a | or a letter or crossing over a - or something. So we // want to continue down unless we're o a + and going straight on will land us over the edge or on an empty space if ((currentRow == 0 || map[currentRow - 1][currentColumn] == ' ') && map[currentRow][currentColumn] == '+') { // This is the "about to do something silly, but we can turn a corner so we're ok" case if (currentColumn > 0 && (map[currentRow][currentColumn - 1] == '-' || (map[currentRow][currentColumn - 1] >= 'A' && map[currentRow][currentColumn - 1] <= 'Z'))) { currentColumn--; direction = MazeDirection.Left; } else if (currentColumn < map[currentRow].Length && (map[currentRow][currentColumn + 1] == '-' || (map[currentRow][currentColumn + 1] >= 'A' && map[currentRow][currentColumn + 1] <= 'Z'))) { currentColumn++; direction = MazeDirection.Right; } else { throw new InvalidOperationException( "Oops, looks like we can and should turn a corner, but we can't, which is suspicious"); } } else { { // We can keep heading up, so let's do it currentRow--; } } break; case MazeDirection.Left: // BIG COMMENT TO MISS LATER: This should be very similar to the DOWN case, but rotated somehow // Base case: Assume we were already heading left via a sensible route, either a - or a letter or crossing over a | or something. So we // want to continue left unless we're on a + and going straight on will land us over the edge or on an empty space if ((currentColumn == 0 || map[currentRow][currentColumn - 1] == ' ') && map[currentRow][currentColumn] == '+') { // This is the "about to do something silly, but we can turn a corner so we're ok" case if (currentRow > 0 && (map[currentRow - 1][currentColumn] == '|' || (map[currentRow - 1][currentColumn] >= 'A' && map[currentRow - 1][currentColumn] <= 'Z'))) { currentRow--; direction = MazeDirection.Up; } else if (currentRow < map.Length - 1 && (map[currentRow + 1][currentColumn] == '|' || (map[currentRow + 1][currentColumn] >= 'A' && map[currentRow + 1][currentColumn] <= 'Z'))) { currentRow++; direction = MazeDirection.Down; } else { throw new InvalidOperationException( "Oops, looks like we can and should turn a corner, but we can't, which is suspicious"); } } else { { // We can keep heading left, so let's do it currentColumn--; } } break; case MazeDirection.Right: // BIG COMMENT TO MISS LATER: This should be very similar to the LEFT case, but inverted // Base case: Assume we were already heading right via a sensible route, either a - or a letter or crossing over a | or something. So we // want to continue right unless we're on a + and going straight on will land us over the edge or on an empty space if ((currentColumn == map[currentRow].Length - 1 || map[currentRow][currentColumn + 1] == ' ') && map[currentRow][currentColumn] == '+') { // This is the "about to do something silly, but we can turn a corner so we're ok" case if (currentRow > 0 && (map[currentRow - 1][currentColumn] == '|' || (map[currentRow - 1][currentColumn] >= 'A' && map[currentRow - 1][currentColumn] <= 'Z'))) { currentRow--; direction = MazeDirection.Up; } else if (currentRow < map.Length - 1 && (map[currentRow + 1][currentColumn] == '|' || (map[currentRow + 1][currentColumn] >= 'A' && map[currentRow + 1][currentColumn] <= 'Z'))) { currentRow++; direction = MazeDirection.Down; } else { throw new InvalidOperationException( "Oops, looks like we can and should turn a corner, but we can't, which is suspicious"); } } else { { // We can keep heading right, so let's do it currentColumn++; } } break; } } return(42); }
public void SetDirection(MazeDirection direction) { m_CurrentDirection = direction; transform.localRotation = direction.ToRotation(); }
/// <summary> /// Called by Unity. /// </summary> public void Update() { if (HasArrived(targetPosition) == true) { // Update current position currentPosition = targetPosition; // Check available moves bool canMoveLeft = CanMoveInDirection(MazeDirection.Left); bool canMoveRight = CanMoveInDirection(MazeDirection.Right); bool canMoveUp = CanMoveInDirection(MazeDirection.Up); bool canMoveDown = CanMoveInDirection(MazeDirection.Down); // Calcualte the current index position Vector2Int index = new Vector2Int(Mathf.RoundToInt(currentPosition.x), Mathf.RoundToInt(currentPosition.y)); // Add to visited if (visited.Contains(index) == false) { visited.Add(index); DropBreadcrumb(); } try { // Get a move decsision MazeDirection moveDirection = DecideDirection( index, canMoveLeft, canMoveRight, canMoveUp, canMoveDown); // Validate direction switch (moveDirection) { case MazeDirection.Up: { // Validate move if (canMoveUp == false) { throw new InvalidOperationException("Invalid decision: Cannot move up. Game will restart"); } // Update target position targetPosition = currentPosition + new Vector2(0, 1); transform.localEulerAngles = new Vector3(0, 0, 0); break; } case MazeDirection.Down: { // Validate move if (canMoveDown == false) { throw new InvalidOperationException("Invalid decision: Cannot move down. Game will restart"); } // Update target position targetPosition = currentPosition + new Vector2(0, -1); transform.localEulerAngles = new Vector3(0, 0, 180); break; } case MazeDirection.Left: { // Validate move if (canMoveLeft == false) { throw new InvalidOperationException("Invalid decision: Cannot move left. Game will restart"); } // Update target position targetPosition = currentPosition + new Vector2(-1, 0); transform.localEulerAngles = new Vector3(0, 0, 90); break; } case MazeDirection.Right: { // Validate move if (canMoveRight == false) { throw new InvalidOperationException("Invalid decision: Cannot move right. Game will restart"); } // Update target position targetPosition = currentPosition + new Vector2(1, 0); transform.localEulerAngles = new Vector3(0, 0, -90); break; } } } catch (Exception e) { Debug.LogException(e); Restart(); } } else { // Move to target transform.position = Vector2.MoveTowards(transform.position, targetPosition, moveSpeed * Time.deltaTime); } }
private void initMazeData() { //initialize entire array for (int x = 0; x < size.x; x++) { for (int z = 0; z < size.z; z++) { SetType(x, z, WallType.SolidWall); } } //set start and end if (regenerating) { SetType(end, WallType.Floor); } else { SetType(start, WallType.Floor); } //loot room at the center of maze for (int x = mazeSize.x - 2; x <= mazeSize.x + 2; x++) { for (int z = mazeSize.z - 2; z <= mazeSize.z + 2; z++) { if (x == mazeSize.x - 2 || x == mazeSize.x + 2 || z == mazeSize.z - 2 || z == mazeSize.z + 2) { SetType(x, z, WallType.PermanentWall); } else { SetType(x, z, WallType.LootRoom); } } } //randomly decide entrance to loot room dir = MazeDirections.randomEnum <MazeDirection>(); if (dir == MazeDirection.South) { door.z -= 2; doorEntrance.z -= 3; } else if (dir == MazeDirection.North) { door.z += 2; doorEntrance.z += 3; } else if (dir == MazeDirection.West) { door.x -= 2; doorEntrance.x -= 3; } else { door.x += 2; doorEntrance.x += 3; } //add Treasure Chest if (!regenerating) { SetType(mazeSize, WallType.TreasureChest); } }
public void SetEdge(MazeDirection direction, MazeCellEdge edge) { edges[(int)direction] = edge; initializedEdgeCount += 1; }
public void SetEdge(MazeDirection direction, MazeCellEdge edge) { edges[(int)direction] = edge; // Increase count whenever a wall is set up initializedEdgeCount += 1; }
public void SetEdge(MazeDirection edge, MazeCellEdge.TypeEdgeEnum tEdge) { Edges[(int)edge] = tEdge; m_NumberDefinedEdges += 1; }
public override void Initialize(MazeCell cell, MazeCell otherCell, MazeDirection direction) { base.Initialize(cell, otherCell, direction); transform.GetChild(0).GetComponent <Renderer>().material = cell.room.settings.wallMaterial; }
public static MazeDirection GetNextCounterclockwise(this MazeDirection direction) { return((MazeDirection)(((int)direction + Count - 1) % Count)); }
//Rotation public static MazeDirection GetNextClockWise(this MazeDirection direction) { return((MazeDirection)(((int)direction + 1) % Count)); }
private void CreateMazeEntrance(Vector2Int coordinates, MazeDirection direction) { cells[coordinates.x, coordinates.y].entrance = direction; }
private void populateMaze() { //SetType(0, 1, WallType.Floor); IntVector2 pos = new IntVector2(0, 0); for (; pos.x < size.x; pos.x++) { pos.z = 0; for (; pos.z < size.z; pos.z++) { WallType type = GetType(pos); if (type == WallType.SolidWall || type == WallType.PermanentWall) { createPrefab <MazeWall>(pos, dir, wallPrefab); } if (type == WallType.Door) { createPrefab <MazeDoor>(pos, dir, doorPrefab); createPrefabMaterial <MazeFloor>(pos, floorPrefab, 1); } if (type == WallType.TreasureChest) { createPrefab <TreasureChest>(pos, dir, treasurePrefab); createPrefabMaterial <MazeFloor>(pos, floorPrefab, 1); if (hasCeiling) { createPrefab <MazeCeiling>(pos, ceilingPrefab); } } if (type == WallType.LootRoom) { createPrefabMaterial <MazeFloor>(pos, floorPrefab, 1); if (hasCeiling) { createPrefab <MazeCeiling>(pos, ceilingPrefab); } } if (type == WallType.Floor) { createPrefab <MazeFloor>(pos, dir, floorPrefab); if (hasCeiling) { createPrefab <MazeCeiling>(pos, ceilingPrefab); } if (pos.x != doorEntrance.x && pos.z != doorEntrance.z) { if (rollRandom(7)) { createPrefab <MazeVine>(pos, vinePrefab); createPrefab <MazeDoor>(pos, doorPrefab); randomlyAddCoin(pos, 1.5f, 10); } else if (mazeNum >= 2 && rollRandom(5)) { //CALC THE ORIENTATION MazeDirection facing = MazeDirection.East; createPrefab <MazeBreakable>(pos, facing, breakablePrefab); } else if (mazeNum >= 4 && rollRandom(5)) { createPrefab <MazeJumpObstacle>(pos, jumpPrefab); randomlyAddCoin(pos, 4.5f, 10); } else if (mazeNum >= 6 && rollRandom(5)) { createPrefab <MazePushObstacle>(pos, pushPrefab); } else { randomlyAddCoin(pos, 1.5f, 10); } } } } } }
public static Vector2Int ToIntVector2(this MazeDirection direction) { return(vectors[(int)direction]); }
public static Vector2i ToVector2i(this MazeDirection dir) { return(vectors[(int)dir]); }
public static MazeDirection GetOpposite(this MazeDirection direction) { return(opposites[(int)direction]); }
public MazeCellEdge GetEdge(MazeDirection dir) { return this.edges[(int)dir]; }
public static Quaternion ToRotation(this MazeDirection direction) { return(rotations[(int)direction]); }
public static IntVector2 ToIntVector2(this MazeDirection direction) { return(_vector2S[(int)direction]); }
internal void DestroyWall(MazeDirection direction) { walls[(int)direction].SetActive(false); }
private static MazeCell GetNeighborCellInDirection(MazeCell cell, MazeDirection direction) { return(GetCell(cell.GetX() + MazeDirections.ToIntVector2(direction).x, cell.GetY() + MazeDirections.ToIntVector2(direction).y)); }
public override void Initialize(MazeCell cell, MazeCell otherCell, MazeDirection direction) { base.Initialize(cell, otherCell, direction); //wall.GetComponent<MeshRenderer>().material.mainTexture = cell.room.settings.wallMaterial.mainTexture; }
// Das ist eine so genannte 'extension method'. Das 'this' keyword sorgt dafuer, dass sich das ganze wie eine auf MazeDirection definierte Methode // verhaelt. Probiert was passiert, wenn man das this keyword entfernt. public static CellVector ToCellVector(this MazeDirection direction) { return(MazeDirections.vectors[(int)direction]); }
public static string ToString(this MazeDirection direction) { return(direction.ToString()); }
public MazeCell AdvanceBuild(MazeCell mazeCell, MazeDirection mazeDirection) { MazeCell newHead = null; if (mazeCell != null) { switch (mazeDirection) { case MazeDirection.Up: newHead = this.MazeCells[mazeCell.Y - 1][mazeCell.X]; break; case MazeDirection.Right: newHead = this.MazeCells[mazeCell.Y][mazeCell.X + 1]; break; case MazeDirection.Down: newHead = this.MazeCells[mazeCell.Y + 1][mazeCell.X]; break; case MazeDirection.Left: newHead = this.MazeCells[mazeCell.Y][mazeCell.X - 1]; break; } ((List<MazeDirection>)mazeCell.BuildDirections).Remove(mazeDirection); ((List<MazeDirection>)mazeCell.ExploreDirections).Add(mazeDirection); newHead.PreviousBuildCell = mazeCell; newHead.PreviousBuildDirection = this.oppositeDirection(mazeDirection); newHead.HasPath = true; ((List<MazeDirection>)newHead.BuildDirections).Remove(this.oppositeDirection(mazeDirection)); ((List<MazeDirection>)newHead.ExploreDirections).Add(this.oppositeDirection(mazeDirection)); if (newHead.Y > 0) { MazeCell upCell = this.MazeCells[newHead.Y - 1][newHead.X]; if (upCell.HasPath) { ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Up); ((List<MazeDirection>)upCell.BuildDirections).Remove(MazeDirection.Down); } } if (newHead.X < this.Width - 1) { MazeCell rightCell = this.MazeCells[newHead.Y][newHead.X + 1]; if (rightCell.HasPath) { ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Right); ((List<MazeDirection>)rightCell.BuildDirections).Remove(MazeDirection.Left); } } if (newHead.Y < this.Height - 1) { MazeCell downCell = this.MazeCells[newHead.Y + 1][newHead.X]; if (downCell.HasPath) { ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Down); ((List<MazeDirection>)downCell.BuildDirections).Remove(MazeDirection.Up); } } if (newHead.X > 0) { MazeCell leftCell = this.MazeCells[newHead.Y][newHead.X - 1]; if (leftCell.HasPath) { ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Left); ((List<MazeDirection>)leftCell.BuildDirections).Remove(MazeDirection.Right); } } } return newHead; }
public MazeCellEdge GetEdge(MazeDirection dir) { return(this.edges[(int)dir]); }
public void WallGeneration (MazeCell cell, MazeCell otherCell, MazeDirection direction, int[] randomNumbers) { MazeWall wall = Maze.Instantiate (maze.wallSettings.wallPrefabs [randomNumbers[0]]) as MazeWall; wall.Initialize (cell, otherCell, direction); if (otherCell == null) return; wall = Maze.Instantiate (maze.wallSettings.wallPrefabs [randomNumbers[1]]) as MazeWall; wall.Initialize (otherCell, cell, direction.GetOpposite ()); }
/// <summary> /// </summary> /// <param name="direction"></param> /// <returns></returns> public static IntVector3 ToIntVector3(this MazeDirection direction) { return(_vectors[(int)direction]); }
private void GeneratePassageDifferentRoom (MazeCell cell, MazeCell otherCell, MazeDirection direction) { MazePassage prefab; if (maze.MaxDoorNumber == 0) prefab = GetMazePassageBasedOnDoorPropability (); else prefab = GetMazePassageBasedOnMaxDoorNumber (cell); MazePassage passage = Maze.Instantiate(prefab) as MazePassage; passage.Initialize(cell, otherCell, direction); passage = Maze.Instantiate(prefab) as MazePassage; DifferentRoomAction (cell, otherCell, passage); passage.Initialize (otherCell, cell, direction.GetOpposite ()); }
// SET EDGE: public void SetEdge(MazeDirection direction, MazeCellEdge edge) { edges[(int)direction] = edge; initializedEdgeCount += 1; }
private void Look(MazeDirection direction) { transform.localRotation = direction.ToRotation(); currentDirection = direction; }
public MazeCellEdge GetEdge(MazeDirection direction) { return(edges [(int)direction]); }
public MazeCellEdge GetEdge(MazeDirection direction) { return edges[(int)direction]; }
public static IVector2 ToIntVector2(this MazeDirection direction) { return(m_DirectionToVector[(int)direction]); }
public void SetEdge(MazeDirection dir, MazeCellEdge edge) { this.edges[(int)dir] = edge; this.initedEdgeCount += 1; }
public static MazeDirection GetNextCounterclockwise(this MazeDirection direction) { return((MazeDirection)(((int)direction + NumberDirections - 1) % NumberDirections)); }
void GetDataFromCurrentCell(MazeCell currentCell, out MazeDirection direction, out Vector2Int neighbourCoordinates) { direction = currentCell.RandomUninitializedDirection; neighbourCoordinates = MazeDirections.MakeNewCoordinates(currentCell.coordinates, direction); currentCell.RemoveEdge(direction); }
private void CreateMazeExit(Vector2Int coordinates, MazeDirection direction) { cells[coordinates.x, coordinates.y].exit = direction; }
public override void Initialize(MazeCell cell, MazeCell otherCell, MazeDirection direction) { base.Initialize(cell, otherCell, direction); wall.GetComponent<Renderer>().material = cell.room.settings.wallMaterial; }
private void CreatePassageInSameRoom (MazeCell cell, MazeCell otherCell, MazeDirection direction) { MazePassage passage = Instantiate(passagePrefab) as MazePassage; passage.Initialize(cell, otherCell, direction); passage = Instantiate(passagePrefab) as MazePassage; passage.Initialize(otherCell, cell, direction.GetOpposite()); if (cell.room != otherCell.room) { MazeRoom roomToAssimilate = otherCell.room; cell.room.Assimilate(roomToAssimilate); rooms.Remove(roomToAssimilate); Destroy(roomToAssimilate); } }