public virtual void Inicialize(MazeCell cell, MazeCell otherCell, MazeDirecction 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(); }
private void CreateWall(MazeCell cell, MazeCell otherCell, MazeDirecction direcction) { MazeWall wall = Instantiate(WallPrefabs[Random.Range(0, WallPrefabs.Length)]); wall.Inicialize(cell, otherCell, direcction); if (otherCell != null) { wall = Instantiate(WallPrefabs[Random.Range(0, WallPrefabs.Length)]); wall.Inicialize(otherCell, cell, direcction.GetOpposite()); } }
public override void Inicialize(MazeCell cell, MazeCell otherCell, MazeDirecction direction) { base.Inicialize(cell, otherCell, direction); if (otherSideofDoor != null) { #pragma warning disable 0219 Hinge.localScale = new Vector3(-1f, 1f, 1f); Vector3 p = Hinge.localPosition; p.x = -p.x; Hinge.localPosition = p; #pragma warning restore 0219 } }
private void CreatePassageInSameRoom(MazeCell cell, MazeCell other, MazeDirecction direction) { MazePassage passage = Instantiate(PassagePrefab); passage.Inicialize(cell, other, direction); passage = Instantiate(PassagePrefab); passage.Inicialize(other, cell, direction.GetOpposite()); if (cell.Room != other.Room) { MazeRoom roomToAssimilate = other.Room; cell.Room.Assimilate(roomToAssimilate); rooms.Remove(roomToAssimilate); Destroy(roomToAssimilate); } }
private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirecction direcction) { MazePassage prefab = Random.value < DoorProbability ? DoorPrefab : PassagePrefab; MazePassage passage = Instantiate(prefab); passage.Inicialize(cell, otherCell, direcction); passage = Instantiate(prefab); if (passage is MazeDoor) { otherCell.Initialized(CreateRoom(cell.Room.SettingsIndex)); } else { otherCell.Initialized(cell.Room); } passage.Inicialize(otherCell, cell, direcction.GetOpposite()); }
private void DoNextGenerationStep(List <MazeCell> activeCells) { int currentIndex = activeCells.Count - 1; MazeCell currentCell = activeCells[currentIndex]; if (currentCell.IsFullyInitialized) { activeCells.RemoveAt(currentIndex); return; } MazeDirecction direcction = currentCell.RandomUnitializedDirection; IntVector2 coordinates = currentCell.Coordinates + direcction.ToIntVector2(); if (ContainsCoordinates(coordinates)) { MazeCell neighbour = GetCell(coordinates); if (neighbour == null) { neighbour = CreateCell(coordinates); CreatePassage(currentCell, neighbour, direcction); activeCells.Add(neighbour); } else if (currentCell.Room.SettingsIndex == neighbour.Room.SettingsIndex) { CreatePassageInSameRoom(currentCell, neighbour, direcction); } else { CreateWall(currentCell, neighbour, direcction); } } else { CreateWall(currentCell, null, direcction); } }
public override void Inicialize(MazeCell cell, MazeCell otherCell, MazeDirecction direction) { base.Inicialize(cell, otherCell, direction); transform.GetChild(0).GetComponent <Renderer>().material = cell.Room.Settings.wallMaterial; }
public void SetEdge(MazeDirecction direction, MazeCellEdge edge) { edges[(int)direction] = edge; initializedEdgeCount += 1; }
public MazeCellEdge GetEdge(MazeDirecction direction) { return(edges[(int)direction]); }
public static Quaternion ToRotation(this MazeDirecction direcction) { return(rotations[(int)direcction]); }
public static IntVector2 ToIntVector2(this MazeDirecction direcction) { return(Vectors[(int)direcction]); }
public static MazeDirecction GetOpposite(this MazeDirecction direcction) { return(opposites[(int)direcction]); }