private void CreateStartingPoints() { Object obj = Resources.Load("PlayerStartingPoint"); int x = (int)startingRoom.GetMedianPoint().x; int y = (int)startingRoom.GetMedianPoint().z; TileScript2D up = DungeonGenerationUtils.GetUpTile(x, y, tilesMap); TileScript2D down = DungeonGenerationUtils.GetDownTile(x, y, tilesMap); TileScript2D left = DungeonGenerationUtils.GetLeftTile(x, y, tilesMap); TileScript2D right = DungeonGenerationUtils.GetRightTile(x, y, tilesMap); GameObject go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = up.transform.position + new Vector3(0, 1f, 0); go.transform.SetParent(map.transform, false); go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = down.transform.position + new Vector3(0, 1f, 0); go.transform.SetParent(map.transform, false); go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = left.transform.position + new Vector3(0, 1f, 0); go.transform.SetParent(map.transform, false); go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = right.transform.position + new Vector3(0, 1f, 0); go.transform.SetParent(map.transform, false); }
private Room FindRoomGoingRight(int x, int y, Room currentRoom) { GameObject tile = DungeonGenerationUtils.GetRight(x, y, tilesMap); if (currentRoom.GetTiles().Contains(tile)) { return(null); } else { foreach (Room room in rooms) { if (room != currentRoom && room.GetTiles().Contains(tile)) { return(room); } } if (x < WIDTH) { return(FindRoomGoingRight(x + 1, y, currentRoom)); } else { return(null); } } }
private void CreateWall(GameObject gameObject, int x, int y) { TileScript2D up = DungeonGenerationUtils.GetUpTile(x, y, tilesMap); TileScript2D down = DungeonGenerationUtils.GetDownTile(x, y, tilesMap); TileScript2D left = DungeonGenerationUtils.GetLeftTile(x, y, tilesMap); TileScript2D right = DungeonGenerationUtils.GetRightTile(x, y, tilesMap); UnityEngine.Object obj = null; float degrees = 0; if (IsNullOrFloor(up) && IsNullOrFloor(down)) { obj = Resources.Load("WallCubeH"); } if (IsNullOrFloor(right) && IsNullOrFloor(left)) { obj = Resources.Load("WallCubeH"); degrees = 90; } if (IsWall(up) && IsWall(left)) { obj = Resources.Load("WallAngle"); degrees = 270; } if (IsWall(up) && IsWall(right)) { obj = Resources.Load("WallAngle"); degrees = 180; } if (IsWall(down) && IsWall(left)) { obj = Resources.Load("WallAngle"); degrees = 0; } if (IsWall(down) && IsWall(right)) { obj = Resources.Load("WallAngle"); degrees = 90; } if (obj != null) { GameObject go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = gameObject.transform.position + new Vector3(0, 1.5f, 0); go.transform.Rotate(Vector3.up, degrees); go.transform.SetParent(map.transform, false); } }
private void CreateDoor(GameObject gameObject, int x, int y) { TileScript2D up = DungeonGenerationUtils.GetUpTile(x, y, tilesMap); TileScript2D down = DungeonGenerationUtils.GetDownTile(x, y, tilesMap); float degrees = 90; UnityEngine.Object obj = Resources.Load("Door"); if (IsWall(up) && IsWall(down)) { degrees = 0; } GameObject go = (GameObject)Utils.MyInstantiate(obj); go.transform.position = gameObject.transform.position + new Vector3(0, 1.5f, 0); go.transform.Rotate(Vector3.up, degrees); go.transform.SetParent(map.transform, false); if (lockedDoors.ContainsKey(gameObject)) { LockDoorAndCreateKey(go, gameObject); } }