private bool IsPositionEmpty(Vector2Int pos) { int tileType = mDungeon.TileType(pos); bool possiblyEmpty = (tileType == RandomDungeonTileData.WALKABLE_TILE || tileType == RandomDungeonTileData.EXIT_TILE || tileType == AVATAR_POSITION); if (!possiblyEmpty) { return(false); } return(mCollisionMap.SpaceMarking(pos.x, pos.y) == 0); }
public void SetupWithDungeon(RandomDungeon dungeon) { mMap = new int[dungeon.width, dungeon.height]; for (int x = 0; x < dungeon.width; ++x) { for (int y = 0; y < dungeon.height; ++y) { if (dungeon.TileType(x, y) == RandomDungeonTileData.WALL_TILE) { mMap[x, y] = 1; } else if (dungeon.TileType(x, y) == RandomDungeonTileData.EMPTY_TILE) { mMap[x, y] = -1; } else { mMap[x, y] = 0; } } } }
private void GenerateEnvironmentFromDungeon(RandomDungeon dungeon) { DungeonBiomeData biomeData = Game.instance.currentDungeonData.biomeData; for (int x = 0; x < dungeon.width; ++x) { for (int y = 0; y < dungeon.height; ++y) { RandomDungeonTileData tileData = dungeon.Data(x, y); if (dungeon.TileType(x, y) >= 'A' && dungeon.TileType(x, y) <= 'Z') { HandleCheatTile(tileData, x, y, biomeData); } else if (dungeon.TileType(x, y) == RandomDungeonTileData.EMPTY_TILE) { mCollisionMap.MarkSpace(x, y, -1); } else if (dungeon.TileType(x, y) == RandomDungeonTileData.WALL_TILE) { // In the space level, we actually have requirements for what wall tiles // can be placed where; otherwise we get weird decoration clipping if (Game.instance.currentDungeonData.dungeonNum == 3) { bool hasForwardTile = (y + 1 < dungeon.height); char forwardTile = hasForwardTile ? dungeon.TileType(x, y + 1) : RandomDungeonTileData.EMPTY_TILE; if (forwardTile != RandomDungeonTileData.WALKABLE_TILE && forwardTile != RandomDungeonTileData.EXIT_TILE && forwardTile != RandomDungeonTileData.EMPTY_TILE) { int wall = Random.Range(0, 2); PlaceMapPrefab(biomeData.wallPrefabs[wall], x, y, WALKABLEMAP_STATIC_MARK); } else { PlaceMapPrefab(biomeData.wallPrefabs.Sample(), x, y, WALKABLEMAP_STATIC_MARK); } } else { PlaceMapPrefab(biomeData.wallPrefabs.Sample(), x, y, WALKABLEMAP_STATIC_MARK); } } else if (dungeon.TileType(x, y) == RandomDungeonTileData.WALKABLE_TILE || dungeon.TileType(x, y) == RandomDungeonTileData.EXIT_TILE || dungeon.TileType(x, y) == AVATAR_POSITION) { PlaceMapPrefab(biomeData.floorPrefabs.Sample(), x, y, -1, 0, true); } else if (dungeon.TileType(x, y) == SHOP_PEDESTAL) { PlaceMapPrefab(biomeData.floorPrefabs[0], x, y).GetComponent <RevealWhenAvatarIsClose>().allowScaleVariation = false;; PlaceMapPrefab(biomeData.shopPedestablPrefab, x, y, WALKABLEMAP_STATIC_MARK).GetComponent <RevealWhenAvatarIsClose>().allowScaleVariation = false; GameObject buyableItem = PlaceMapPrefab(RandomItem(), x, y); buyableItem.transform.localPosition += Vector3.up * 0.3f; GameObject activationPlate = PlaceMapPrefab("ActivationPlate", x, y + 1); PlaceSurroundingActivationPlates(x, y, null, null, null, buyableItem.GetComponent <Item>()); } else if (dungeon.TileType(x, y) == SHOP_KEEPER) { PlaceMapPrefab(biomeData.floorPrefabs[0], x, y); GameObject shopKeeper = PlaceMapPrefab("ShopKeep", x, y, WALKABLEMAP_USE_PREFAB_MARK, 0.5f); PlaceSurroundingActivationPlates(x, y, "shopkeep_talk", null, shopKeeper); if (Game.instance.isShopKeeperEnemy) { Game.instance.MakeShopKeeperEnemy(); } } else if (dungeon.TileType(x, y) == PRESET_ENEMY) { PlaceMapPrefab(biomeData.floorPrefabs[0], x, y); PlaceEnemy(CurrentDungeonFloorData(), new Vector2Int(x, y)); } if (tileData.chest == 2) { PlaceChest(new Vector2Int(x, y)); } else if (tileData.chest == 1) { bool generateShrine = (Random.Range(0, 100) < 50); if (generateShrine) { Debug.Log("A special room has spawned including a shrine."); PlaceShrine(new Vector2Int(x, y)); } else { Debug.Log("A special room has spawned including a chest."); PlaceChest(new Vector2Int(x, y)); } } } } }