public void BuildExit() { AssetProxy pr = new AssetProxy(typeof(GameObject)); GameObject exitTile = Object.Instantiate(pr.LoadAsset("Objects/Tiles/ExitTile.prefab")); Vector2Int settings = StaticTestSettings.getMapSize(); int stX = settings.x; int stY = settings.y; List <Vector3> availabeleExitLocation = new List <Vector3>(); do { for (int i = -stX / 2; i < stX / 2; i++) { for (int j = -stY / 2; j < stY / 2; j++) { if (tiles.GetIndoorTiles().Contains(mapOperations.GetGroundTile(new Vector3Int(i, j, 0))) && !tiles.GetStructureTiles().Contains(mapOperations.GetStructureTile(new Vector3Int(i, j, 0)))) { if (Random.value < 0.1) { availabeleExitLocation.Add(new Vector3(i, j)); } } } } }while (availabeleExitLocation.Count == 0); int exitLocationIndex = Random.Range(0, availabeleExitLocation.Count); Vector3 exitLocation = availabeleExitLocation[exitLocationIndex]; exitTile.transform.Translate(exitLocation); exitTile.transform.Translate(new Vector3(0.5f, 0.5f)); }
protected List <Vector2Int> GetBuffsSpawnPositions(GameMap map, Tileset tileset) { List <Vector2Int> spawnPositions = new List <Vector2Int>(); MapModifier mapModifier = new MapModifier(map); GameData gameData = new AssetProxy(typeof(GameData)).LoadAsset("Objects/Data.asset"); int buffsEntries = 0; for (int x = -map.sizeX / 2; x < map.sizeX / 2; x++) { for (int y = -map.sizeY / 2; y < map.sizeY / 2; y++) { if (tileset.GetIndoorTiles().Contains(mapModifier.GetGroundTile(new Vector3Int(x, y, 0))) && !tileset.GetStructureTiles().Contains(mapModifier.GetStructureTile(new Vector3Int(x, y, 0)))) { //spawn if (Random.value < gameData.GetSpawnRate()) { spawnPositions.Add(new Vector2Int(x, y)); buffsEntries++; } if (buffsEntries >= MAX_BUFFS_ENTRIES) { return(spawnPositions); } } } } Debug.Log("Buffs spawn rate:" + gameData.GetSpawnRate()); return(spawnPositions); }