/// <summary> /// Get the character used to display a particular type of cell /// </summary> /// <param name="Cell">Cell to check</param> /// <returns>Character to display on screen for cell</returns> public static char CellScreenChar(DungeonCell Cell) { switch (Cell) { case DungeonCell.Empty: return(' '); case DungeonCell.Floor: return('.'); case DungeonCell.Door: return('+'); case DungeonCell.Wall: return('#'); case DungeonCell.StairUp: return('<'); case DungeonCell.StairDown: return('>'); default: return('X'); } }
Mesh CreateMesh(Texture texture, int tileSize, CheckMapTile condition, GetMapTile func) { Mesh mesh = new Mesh(); mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; Vector4[] uvs = GenerateUV(texture, tileSize); int mapSize = mapHeight * mapWidth; Vector3[] verticies = new Vector3[4 * 4 * mapSize]; Vector2[] uv = new Vector2[4 * 4 * mapSize]; List <int> triangles = new List <int>(); for (int i = 0; i < mapWidth; i++) { for (int j = 0; j < mapHeight; j++) { DungeonCell data = map[i, j]; if (condition(data)) { GenerateMeshData(i, j, func(data), verticies, uv, triangles, uvs); } } } mesh.vertices = verticies; mesh.uv = uv; mesh.triangles = triangles.ToArray(); MeshUtility.Optimize(mesh); return(mesh); }
private void CreateCorridorWalls(DungeonCell cell, int dir, Transform parent) { if (dir == 0) { if (tileMatrix[cell.Coordinates.z + 1, cell.Coordinates.x] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.North], Direction.North, cell, parent); cell.addWallRefenceToCell(aWall, "north"); } if (tileMatrix[cell.Coordinates.z - 1, cell.Coordinates.x] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.South], Direction.South, cell, parent); cell.addWallRefenceToCell(aWall, "south"); } } if (dir == 1) { if (tileMatrix[cell.Coordinates.z, cell.Coordinates.x - 1] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.West], Direction.West, cell, parent); cell.addWallRefenceToCell(aWall, "west"); } if (tileMatrix[cell.Coordinates.z, cell.Coordinates.x + 1] == 0) { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.East], Direction.East, cell, parent); cell.addWallRefenceToCell(aWall, "east"); } } }
private void DoFirstGenStep(List <DungeonCell> activeCells) //Generates the first cell and room { DungeonCell cell = CreateCell(RandomCoordinates); cell.Initialize(CreateRoom(-1)); activeCells.Add(cell); }
private void ConnectFarTaskNodesRooms(Room upperRoom, Room lowerRoom) { // Choose random cell in the lower part of the upper room int random = Random.Range(0, upperRoom.getTilesDownRow().Count - 1); DungeonCell firstCell = upperRoom.getTilesDownRow()[random].getCorrespondingDungeonCell(); // Choose random cell in the upper part of the lower room random = Random.Range(0, lowerRoom.getTilesUpRow().Count - 1); DungeonCell lastCell = lowerRoom.getTilesUpRow()[random].getCorrespondingDungeonCell(); // Check if both cells are aligned if (firstCell.getCellColumnPositionInGrid() == lastCell.getCellColumnPositionInGrid()) { dungeon.getDungeonCorridors().Add(new Corridor(dungeon, firstCell, lastCell, Direction.Down, floorTileDimensions, floorMaterial, wallHeight, wallMaterial, false)); } else { // Get first middle point between both rooms int middle = (firstCell.getCellRowPositionInGrid() + lastCell.getCellRowPositionInGrid()) / 2; DungeonCell firstMiddleCell = dungeon.getDungeonGrid()[middle, firstCell.getCellColumnPositionInGrid()]; // Get second middle point DungeonCell secondMiddleCell = dungeon.getDungeonGrid()[middle, lastCell.getCellColumnPositionInGrid()]; // Calculate direction of middle corridor Direction middleDirection = Direction.Right; if (firstMiddleCell.getCellColumnPositionInGrid() > secondMiddleCell.getCellColumnPositionInGrid()) { middleDirection = Direction.Left; } // Create corridors dungeon.getDungeonCorridors().Add(new Corridor(dungeon, firstCell, firstMiddleCell, Direction.Down, floorTileDimensions, floorMaterial, wallHeight, wallMaterial, true)); dungeon.getDungeonCorridors().Add(new Corridor(dungeon, firstMiddleCell, secondMiddleCell, middleDirection, floorTileDimensions, floorMaterial, wallHeight, wallMaterial, true)); dungeon.getDungeonCorridors().Add(new Corridor(dungeon, secondMiddleCell, lastCell, Direction.Down, floorTileDimensions, floorMaterial, wallHeight, wallMaterial, false)); } }
protected void UpdateTileGraphics() { ClearTileGraphics(); for (int y = 0; y < mGrid.Height; ++y) { for (int x = 0; x < mGrid.Width; ++x) { DungeonCell cell = mGrid.GetGridCell(x, y); TileSet tileSet; if (kTileMapping.TryGetValue(cell.mTileType, out tileSet)) { GameObject tilePrefab = GetRandomTilePrefab(tileSet.mPrefabs); Quaternion rotation = Quaternion.identity; if (tileSet.mAllowRandomOrientation) { rotation = kTileRotations[Random.Range(0, kTileRotations.Length)]; } GameObject tileObj = Instantiate(tilePrefab, GetTilePosition(x, y), rotation) as GameObject; tileObj.transform.SetParent(GetRenderGroup(x, y).transform); mTileObjects.Add(tileObj); } } } foreach (var pair in mRenderGroups) { CombineMesh(pair.Value); } for (int i = mTileObjects.Count - 1; i >= 0; --i) { Destroy(mTileObjects[i]); } mTileObjects.Clear(); }
protected void GenerateEnemies() { ClearEnemies(); for (int i = 0; i < mCurrentLevelData.mNumEnemies; ++i) { int attempts = 0; do { Room room = GetRandomRoom(); Vector2i randPos = room.GetRandomPos(); DungeonCell cell = mDungeon.GetCell(randPos.mX, randPos.mY); if (cell.mTileType == DungeonCell.TileType.Ground) { cell.mTileType = DungeonCell.TileType.Collectable; GameObject prefab = mCurrentLevelData.mEnemyPrefabs[Random.Range(0, mCurrentLevelData.mEnemyPrefabs.Length)]; GameObject enemyObj = SpawnPrefab(prefab, mDungeon.GetTilePosition(randPos.mX, randPos.mY), Quaternion.identity); EnemyController enemy = enemyObj.GetComponent <EnemyController>(); enemy.Init(); mEnemies.Add(enemy); break; } attempts++; } while (attempts < kMaxPlacementAttempts); } }
private void CreateRoomAndConnectNodes(Dictionary <AlphabetNode, Room> nodesWithRoom, List <AlphabetNode> nodesToVisit, AlphabetNode currentNode, Direction dir) { // Choose random corridor length to separate the rooms by that distance int randomCorridorLength = 1; if (dir == Direction.Right || dir == Direction.Left) { randomCorridorLength = Random.Range(minCorridorLengthWhenHorizontal, maxCorridorLengthWhenHorizontal); } else { randomCorridorLength = Random.Range(minCorridorLengthWhenVertical, maxCorridorLengthWhenVertical); } // Choose random room width int randomRoomWidth = Random.Range(roomMinTilesWidth, roomMaxTilesWidth); // Choose random room height int randomRoomHeight = Random.Range(roomMinTilesHeight, roomMaxTilesHeight); // Calculate top left corner column and row based on the direction and the middle cell of corresponding external side to align the rooms as much as possible int topLeftCornerColumn = 0; int topLeftCornerRow = 0; switch (dir) { case Direction.Right: int rigthColumnTilesNumber = nodesWithRoom[nodesToVisit[0]].getTilesRightColumn().Count; DungeonCell rightColumnMiddleCell = nodesWithRoom[nodesToVisit[0]].getTilesRightColumn()[rigthColumnTilesNumber / 2].getCorrespondingDungeonCell(); topLeftCornerColumn = rightColumnMiddleCell.getCellColumnPositionInGrid() + randomCorridorLength + 1; topLeftCornerRow = rightColumnMiddleCell.getCellRowPositionInGrid() - (randomRoomHeight / 2); break; case Direction.Left: int leftColumnTilesNumber = nodesWithRoom[nodesToVisit[0]].getTilesLeftColumn().Count; DungeonCell leftColumnMiddleCell = nodesWithRoom[nodesToVisit[0]].getTilesLeftColumn()[leftColumnTilesNumber / 2].getCorrespondingDungeonCell(); topLeftCornerColumn = leftColumnMiddleCell.getCellColumnPositionInGrid() - randomCorridorLength - randomRoomWidth; topLeftCornerRow = leftColumnMiddleCell.getCellRowPositionInGrid() - (randomRoomHeight / 2); break; case Direction.Up: int upRowTilesNumber = nodesWithRoom[nodesToVisit[0]].getTilesUpRow().Count; DungeonCell upRowMiddleCell = nodesWithRoom[nodesToVisit[0]].getTilesUpRow()[upRowTilesNumber / 2].getCorrespondingDungeonCell(); topLeftCornerColumn = upRowMiddleCell.getCellColumnPositionInGrid() - (randomRoomWidth / 2); topLeftCornerRow = upRowMiddleCell.getCellRowPositionInGrid() - randomCorridorLength - randomRoomHeight; break; case Direction.Down: int downRowTilesNumber = nodesWithRoom[nodesToVisit[0]].getTilesDownRow().Count; DungeonCell downRowMiddleCell = nodesWithRoom[nodesToVisit[0]].getTilesDownRow()[downRowTilesNumber / 2].getCorrespondingDungeonCell(); topLeftCornerColumn = downRowMiddleCell.getCellColumnPositionInGrid() - (randomRoomWidth / 2); topLeftCornerRow = downRowMiddleCell.getCellRowPositionInGrid() + randomCorridorLength + 1; break; } // Create room dungeon.getDungeonRooms().Add(new Room(dungeon, topLeftCornerRow, topLeftCornerColumn, randomRoomHeight, randomRoomWidth, floorTileDimensions, floorMaterial, wallHeight, wallMaterial)); // Add node to lists nodesWithRoom.Add(currentNode.getConnection(dir), dungeon.getDungeonRooms()[dungeon.getDungeonRooms().Count - 1]); nodesToVisit.Add(currentNode.getConnection(dir)); // Connect rooms dungeon.getDungeonCorridors().Add(new Corridor(dungeon, nodesWithRoom[currentNode], nodesWithRoom[currentNode.getConnection(dir)], floorTileDimensions, floorMaterial, wallHeight, wallMaterial)); }
public void CopyConstructorCopiesMap(XY Coord, DungeonCell Value) { var f1 = new AtlasWarriorsGame.DungeonGenerators.Feature(4, 4); f1.SetCell(Coord, Value); var f2 = new AtlasWarriorsGame.DungeonGenerators.Feature(f1); Assert.AreEqual(Value, f2.GetCell(Coord)); }
public void SetCell(int x, int y, DungeonCell.TileType tileType) { DungeonCell cell = GetCell(x, y); if (cell != null) { cell.mTileType = tileType; mGrid.SetGridCell(x, y, cell); } }
private WallUnit InstanciateWall(IntVector2 wallDirection, Direction direction, DungeonCell cell, Transform parent) { WallUnit aWall = Instantiate(wallPrefab) as WallUnit; aWall.transform.parent = cell.transform; aWall.transform.localPosition = new Vector3(wallDirection.x, 0.5f, wallDirection.z); aWall.transform.localRotation = direction.ToRotation(); aWall.transform.parent = parent; return(aWall); }
//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 DungeonCell createCorridorTile(GameObject corridors, IntVector2 c, string sDir, string nextSdir, bool lastSegmentTile) { DungeonCell aCell = null; if (tileMatrix[c.z, c.x] == 0) {//se non c'è sovrapposizione crea la mattonella del corridoio tileMatrix[c.z, c.x] = 2; aCell = CreateCorridorCell(c, corridors); //print("Corridor tile created at " + c); try { activeDungeonCells.Add(c, aCell); } catch (System.ArgumentException) { print("An element with Key = \"txt\" already exists."); } return(aCell); } //se sono all'interno di una stanza mentre costruisco il percorso di connessione distruggo le mura nord-sud oppure east-ovest //nella direzione di marcia solo se non è l'ultimo pezzo di segmento if (tileMatrix[c.z, c.x] == 1 && !lastSegmentTile) { destroyWall(c, sDir, true); //print("FOUND tile TYPE 1 i need to destroy wall at " + c + " direction " + sDir); } //se invece è l'ultimo segmento distruggo un solo muro nella direzione del prossimo segmento nextSDir else if (tileMatrix[c.z, c.x] == 1 && lastSegmentTile) { destroyWall(c, nextSdir, false); //libero anche eventuali mura nell'ultima cella del segmento che non ho distrutto // perchè passo false come paramentro, se avessi passato true avrei rimosso le mura nella direzione di percorrenza //in questo caso però rimuovendo due mura si corre il rischio di eliminare mura perimetrali delle stanze infatti // l'ultimo tile di questo segmento potrebbe trovarsi all'interno di una stanza ma sul perimetro destroyWall(c, oppositeDir(sDir), false); } //gestisco il caso in cui sto creando tile di corridoio in posizioni già occupate da altri pezzi di corridoio if (tileMatrix[c.z, c.x] == 2) { if (lastSegmentTile) { //se sono l'ultimo segmento faccio attenzione a non rimuovere mura che non sono del segmento in questione destroyWall(c, nextSdir, false); //rimuovo le mura solo nella direzione del prossimo segmento destroyWall(c, oppositeDir(sDir), false); //rimuovo l'ultimo eventuale muro nella direzione attuale //print("FOUND last segment TYPE 2 i need to destroy wall at " + c + " direction " + nextSdir); } else { //se non sono l'ultima cella segmente distruggo tutto nella mia direzione quindi coppie di mura east,ovest oppure nord,sud destroyWall(c, sDir, true); //print("FOUND TYPE 2 i need to destroy wall at " + c + " direction " + sDir); } } return(null); }
public DungeonCell CreateCell(IntVector2 coords) //Creates an individual cell of the dungeon { DungeonCell tempCell = Instantiate(cellPrefab) as DungeonCell; cells[coords.x, coords.y] = tempCell; tempCell.coordinates = coords; tempCell.name = "Dungeon Cell " + coords.x + ", " + coords.y; tempCell.transform.parent = transform; tempCell.transform.localPosition = new Vector3(coords.x, coords.y, 0); return(tempCell); }
//crea una mattonella del pavimento nelle coordinate "coordinates" private DungeonCell CreateCorridorCell(IntVector2 coordinates, GameObject corridors) { DungeonCell newDungeonCell = Instantiate(dungeonCellPrefab) as DungeonCell; //cells[coordinates.x,coordinates.z] = newDungeonCell; newDungeonCell.name = "Dungeon Corridor Cell " + coordinates.x + ", " + coordinates.z; newDungeonCell.Coordinates = coordinates; newDungeonCell.transform.localPosition = new Vector3(coordinates.x + 0.5f, 0f, coordinates.z + 0.5f); newDungeonCell.transform.parent = corridors.transform; return(newDungeonCell); }
public Corridor(Dungeon dungeon, Room room1, Room room2, Vector3 floorTileDimensions, Material floorMaterial, float wallHeight, Material wallMaterial) { // Choose one random tile from room 1 and room 2 FloorTile randomRoom1Tile = room1.getFloorTiles()[Random.Range(0, room1.getRoomHeight() - 1), Random.Range(0, room1.getRoomWidth() - 1)]; FloorTile randomRoom2Tile = room2.getFloorTiles()[Random.Range(0, room2.getRoomHeight() - 1), Random.Range(0, room2.getRoomWidth() - 1)]; // Build corridor DungeonCell firstCell = randomRoom1Tile.getCorrespondingDungeonCell(); DungeonCell lastCell = randomRoom2Tile.getCorrespondingDungeonCell(); BuildCorridor(dungeon, firstCell, lastCell, false, floorTileDimensions, floorMaterial, wallHeight, wallMaterial); }
public void createDungeonGrid(Vector3 dungeonTopLeftCellPosition, Vector3 floorTileDimensions) { for (int i = 0; i < dungeonHeight; i++) { for (int j = 0; j < dungeonWidth; j++) { Vector3 cellPosition = dungeonTopLeftCellPosition + new Vector3(floorTileDimensions.x * j, floorTileDimensions.y, -floorTileDimensions.z * i); dungeonGrid[i, j] = new DungeonCell(cellPosition, i, j); } } }
//crea una mattonella del pavimento nelle coordinate "coordinates" private DungeonCell CreateCell(IntVector2 coordinates) { DungeonCell newDungeonCell = Instantiate(dungeonCellPrefab) as DungeonCell; //cells[coordinates.x,coordinates.z] = newDungeonCell; newDungeonCell.name = "Dungeon Cell " + coordinates.x + ", " + coordinates.z; newDungeonCell.Coordinates = coordinates; newDungeonCell.transform.parent = transform; //fa diventare tutte le celle generate figlie del game object Dungeon newDungeonCell.transform.localPosition = new Vector3(coordinates.x + 0.5f, 0f, coordinates.z + 0.5f); return(newDungeonCell); }
public void SetDiggerInitialPosition(int roomMinTilesWidth, int roomMinTilesHeight) { // Get margins int minRow = 0; int maxRow = dungeon.getDungeonHeight() - 1 - roomMinTilesHeight; int minColumn = 0; int maxColumn = dungeon.getDungeonWidth() - 1 - roomMinTilesWidth; // Place digger in random cell that is inside those margins currentCell = dungeon.getDungeonGrid()[Random.Range(minRow, maxRow), Random.Range(minColumn, maxColumn)]; }
private TileType tileType; // The type of floor tile public FloorTile(DungeonCell cell, Material material, Vector3 dimensions, TileType tileType) { // Create primitive will attach to the game object a collider, a mesh filter and a mesh renderer tile = GameObject.CreatePrimitive(PrimitiveType.Cube); this.dungeonCell = cell; tile.GetComponent <MeshRenderer>().material = material; tile.transform.localScale = dimensions; tile.transform.position = new Vector3(0.0f, dimensions.y * 0.5f, 0.0f) + cell.getCellWorldPosition(); this.tileType = tileType; tile.name = "FloorTile"; }
internal void AddNavigationPoints(DungeonCell owner) { navigationButtons = new List <Button>(); foreach (CellConnection connection in owner.connectionPoints) { if (!connection.isCurrent && connection.connected) { NavigationPoint(connection); } } }
//crea il pavimento intero invece di piccole mattonelle, usato per questioni di efficenza date dalla reduzione del carico di mesh da renderizzare private void CreateBaseFloor(IntVector2 coordinates, int width, int height) { DungeonCell roomFloor = Instantiate(dungeonCellPrefab) as DungeonCell; //cells[coordinates.x,coordinates.z] = newDungeonCell; roomFloor.name = "DungeonRoomFloor_origin"; roomFloor.Coordinates = coordinates; roomFloor.transform.parent = transform; //fa diventare tutte le celle generate figlie del game object Dungeon roomFloor.transform.localPosition = new Vector3(coordinates.x + 0.5f, 0f, coordinates.z + 0.5f); roomFloor.transform.localScale = new Vector3(width, 0, height); //roomFloor.transform.GetChild(0).transform.localScale = new Vector3(width, 0, height); //dato che lo scaling in unity parte dal centro devo poi traslare in avanti e sopra della metà + 0.5f (0.5 perché la singola mattonella altrimenti non combacia con lunità di unity) roomFloor.transform.position = new Vector3(roomFloor.transform.position.x + roomFloor.transform.localScale.x / 2 - 0.5f, 0, roomFloor.transform.position.z + roomFloor.transform.localScale.z / 2 - 0.5f); }
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 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 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()); }
public List <DungeonCell> AllocateRoomInSpace() { for (int x = 0; x < Data.Width; x++) { for (int z = 0; z < Data.Height; z++) { DungeonCell aCell = CreateCell((new IntVector2(x, z))); aCell.transform.GetChild(0).GetComponent <Renderer>().enabled = false; activeCells.Add(aCell); //ogni volta che si crea una cella se questa fa parte del perimetro creo una unità muro //il controllo che sia nel perimetro viene effettuato nella funzione stessa CreateWall(x, z, Data.Width, Data.Height, aCell); } } CreateBaseFloor(new IntVector2(0, 0), Data.Width, Data.Height);//costruisce un quad unico delle dimensioni passate, piccola ottimizzazione in modo da non avere wxh celle return(activeCells); }
internal IEnumerator Connect(DungeonCell foreignCell) { var localConnectPoint = RandomConnection(); var foreignConnectPoint = foreignCell.RandomConnection(); if (foreignCell.blocked) { yield break; } Vector3 localConnectDirection = localConnectPoint.transform.position - transform.position; Vector3 foreignConnectDirection = foreignConnectPoint.transform.position - foreignCell.transform.position; transform.position = foreignCell.transform.position; float angleDiff = Vector3.SignedAngle(localConnectDirection, foreignConnectDirection, transform.up); // Debug.Log(angleDiff); transform.Rotate(transform.up, angleDiff); transform.position = foreignConnectPoint.transform.position + (foreignConnectDirection.normalized * localConnectDirection.magnitude); var heightDiff = foreignConnectPoint.HeightDiff() - localConnectPoint.HeightDiff(); transform.position = new Vector3(transform.position.x, transform.position.y + heightDiff, transform.position.z); transform.Rotate(transform.up, 180f); yield return(new WaitForSeconds(0.1f)); if (ValidConnection()) { localConnectPoint.gameObject.SetActive(true); localConnectPoint.connected = true; localConnectPoint.connectedTo = foreignConnectPoint; foreignConnectPoint.gameObject.SetActive(true); foreignConnectPoint.connected = true; foreignConnectPoint.connectedTo = localConnectPoint; } else { foreignConnectPoint.gameObject.SetActive(true); foreignConnectPoint.blocked = true; foreignConnectPoint.GetComponent <Renderer>().material.SetColor("_BaseColor", Color.red); yield return(Connect(foreignCell)); } }
public bool CanPlaceRoom(Room room) { for (int y = room.mMin.mY; y <= room.mMax.mY; ++y) { for (int x = room.mMin.mX; x <= room.mMax.mX; ++x) { if (x == 0 || x == mGrid.Width - 1 || y == 0 || y == mGrid.Height - 1) { return(false); } DungeonCell cell = GetCell(x, y); if (cell == null || cell.mTileType != DungeonCell.TileType.Wall) { return(false); } } } return(true); }
//Methods public void Setup(Dungeon dungeon) //Collects all necessary information and sets the boss up for the level { alive = true; this.dungeon = dungeon; IntVector2 coords; float distToPlayer; do { coords = dungeon.RandomCoordinates; transform.position = new Vector3(coords.x * dungeon.cellScale, coords.y * dungeon.cellScale, 98); distToPlayer = Vector2.Distance((Vector2)player.transform.position, (Vector2)transform.position); } while (distToPlayer < 100f); currentStartCell = dungeon.GetCell(coords).gameObject; currentTargetCell = currentStartCell; GameObject emptyDungeonHole = GameObject.Find("EmptyDungeonHole"); holeCell = dungeon.GetCell(new IntVector2((int)emptyDungeonHole.transform.position.x / dungeon.cellScale, (int)emptyDungeonHole.transform.position.y / dungeon.cellScale)); cellList = new List <GameObject>(); }
private void createSingleWall(DungeonCell cell, string type, Transform parent) { if (type == "north") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.North], Direction.North, cell, parent); cell.addWallRefenceToCell(aWall, "north"); } if (type == "south") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.South], Direction.South, cell, parent); cell.addWallRefenceToCell(aWall, "south"); } if (type == "east") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.East], Direction.East, cell, parent); cell.addWallRefenceToCell(aWall, "east"); } if (type == "west") { WallUnit aWall = InstanciateWall(Directions.directionVectors[(int)Direction.West], Direction.West, cell, parent); cell.addWallRefenceToCell(aWall, "west"); } }
public void SetCell(Vector3 worldPos, DungeonCell.TileType tileType) { Vector2i pos = WorldToCellPos(worldPos); SetCell(pos.mX, pos.mY, tileType); }