//Methods public void Initialize(DungeonCell cell, DungeonCell otherCell, DungeonDirection direction) { this.cell = cell; this.otherCell = otherCell; this.direction = direction; cell.SetEdge(direction, this); transform.parent = cell.transform; transform.localPosition = Vector2.zero; transform.localRotation = direction.ToRotation(); }
private void CreateWall(DungeonCell cell, DungeonCell otherCell, DungeonDirection direction) //Creates a wall between two cells { DungeonWall wall = Instantiate(wallPrefab) as DungeonWall; wall.Initialize(cell, otherCell, direction); if (otherCell != null) { wall.Initialize(otherCell, cell, direction.GetOpposite()); } //Stagger walls z value to prevent lighting glitch Vector3 wallTrans = wall.transform.position; wallTrans.z += Random.Range(-.5f, .5f); wall.transform.position = wallTrans; }
private void CreatePassageInSameRoom(DungeonCell cell, DungeonCell otherCell, DungeonDirection direction) //Combines rooms into larger rooms { DungeonPassage passage = Instantiate(passagePrefab) as DungeonPassage; passage.Initialize(cell, otherCell, direction); passage = Instantiate(passagePrefab) as DungeonPassage; passage.Initialize(otherCell, cell, direction.GetOpposite()); if (cell.room != otherCell.room) { DungeonRoom roomToCombine = otherCell.room; cell.room.Combine(roomToCombine); rooms.Remove(roomToCombine); Destroy(roomToCombine); } }
private void CreatePassage(DungeonCell cell, DungeonCell otherCell, DungeonDirection direction) //Creates a passage between cells { DungeonPassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab; DungeonPassage passage = Instantiate(prefab) as DungeonPassage; passage.Initialize(cell, otherCell, direction); if (passage is DungeonDoor) { otherCell.Initialize(CreateRoom(cell.room.settingIndex)); } else { otherCell.Initialize(cell.room); } passage = Instantiate(prefab) as DungeonPassage; passage.Initialize(otherCell, cell, direction.GetOpposite()); }
private void DoNextGenStep(List <DungeonCell> activeCells) //Handles all other cell and wall generations and room additions { int currentIndex = activeCells.Count - 1; DungeonCell currentCell = activeCells[currentIndex]; if (currentCell.IsFullyInitialized) { activeCells.RemoveAt(currentIndex); return; } DungeonDirection direction = currentCell.RandomUninitializedDirection; IntVector2 coordinates = currentCell.coordinates + direction.ToIntVec2(); if (ContainsCoords(coordinates)) //If the coords are valid { DungeonCell neighbor = GetCell(coordinates); if (neighbor == null) //If its neighbor hasnt been generated { neighbor = CreateCell(coordinates); CreatePassage(currentCell, neighbor, direction); activeCells.Add(neighbor); } else if (currentCell.room.settingIndex == neighbor.room.settingIndex) //If the neighbor is in the same room { CreatePassageInSameRoom(currentCell, neighbor, direction); } else //Otherwise { CreateWall(currentCell, neighbor, direction); } } else //If it is on the edge { CreateWall(currentCell, null, direction); } }
//Gets the rotation public static Quaternion ToRotation(this DungeonDirection direction) { return(rotations[(int)direction]); }
//Gets the opposite direction public static DungeonDirection GetOpposite(this DungeonDirection direction) { return(opposites[(int)direction]); }
//Converts a given direction to its respective intvect2 public static IntVector2 ToIntVec2(this DungeonDirection direction) { return(vectors[(int)direction]); }
public DungeonDirection GetDirection() => default; // 0x00985200-0x009852A0 public List <ICreature> FindEnemies(int distance, bool narrowOnly, bool ignoreLook, DungeonCoord overwriteCoord, DungeonDirection overwriteDir) => default; // 0x009852A0-0x009855E0
public static ICreature FindCreature(ICreature observer, DungeonCoord coord, DungeonDirection direction, int distance, bool narrowOnly) => default; // 0x00984A80-0x00984CB0 public static List <ICreature> FindCreatures(ICreature observer, DungeonCoord coord, DungeonDirection direction, int distance, bool narrowOnly) => default; // 0x00984CB0-0x00984F20
} // 0x007B6D10-0x007B6D50 public DungeonCoord(DungeonDirection dir) { } // 0x007B6D50-0x007B6E80
public void SetEdge(DungeonDirection direction, DungeonCellEdge edge) //Sets a given cellEdge { edges[(int)direction] = edge; initializedEdgeCount += 1; }
public DungeonCellEdge GetEdge(DungeonDirection direction) //Returns cellEdge in a given direction { return(edges[(int)direction]); }