private void InstantiateAnomalySegment(TileCoordinates startTile) { //Debug.Log("X : " + startTile.tileX + "Y : " + startTile.tileY); GridTile tileToReplace = _gameGridTiles[startTile.tileX, startTile.tileY]; GridTile newTile; ReplaceTile(tileToReplace, 10, out newTile); AnomalySegment segment = new AnomalySegment(); _allAnomalySegments.Add(segment); segment.AssignActiveTile(newTile); }
private void InstantiateAnomalySegment(int positiveQuadrantIndex) { TileCoordinates newAnomalyCoords = default; List <GridTile> candidates = new List <GridTile>(); List <Bounds> otherQuadrants = new List <Bounds>(_currentGridInfo.gameGridQuadrants.GetOtherBounds(_currentGridInfo.positiveQuadrantIndex)); bool foundPosition = false; while (!foundPosition) { if (otherQuadrants.Count > 0) { int randomIndex = UnityEngine.Random.Range(0, otherQuadrants.Count); Bounds candidateBounds = otherQuadrants[randomIndex]; otherQuadrants.Remove(candidateBounds); candidates = GetGridTilesInBounds(candidateBounds); foreach (var candidate in candidates) { if (candidate.tileType == 0) { newAnomalyCoords.tileX = candidate.tileX; newAnomalyCoords.tileY = candidate.tileY; foundPosition = true; break; } } } else { foundPosition = true; //Debug.Log("NO MORE POSSIBLE TILES TO SPAWN ANOMALY"); return; } } //Debug.Log("X : " + newAnomalyCoords.tileX + "Y : " + newAnomalyCoords.tileY); GridTile tileToReplace = _gameGridTiles[newAnomalyCoords.tileX, newAnomalyCoords.tileY]; GridTile newTile; ReplaceTile(tileToReplace, 10, out newTile); AnomalySegment segment = new AnomalySegment(); _allAnomalySegments.Add(segment); segment.AssignActiveTile(newTile); }