static void PlaceRandomObstacles() { int targetCount = (int)(room.tileCount * settings.obstaclePercent); int currentCount = 0; bool[,] obstacleMap = new bool[room.size.x, room.size.y]; for (int i = 0; i < targetCount; i++) { Coord randomCoord = openCoords.Next(); obstacleMap[randomCoord.x, randomCoord.y] = true; currentCount++; if (randomCoord != room.center && (room.tileCount - currentCount) == GetAccessibleCount(room.center, obstacleMap)) { InsertObstacle(randomCoord); openCoords.Remove(randomCoord); } else { obstacleMap[randomCoord.x, randomCoord.y] = false; currentCount--; } } }
public Transform SpawnSubBoss() { if (numOfActiveSubBosses >= SubBossController.MAX_SUB_BOSSES) { return(null); } numOfActiveSubBosses += 1; Vector3 start = transform.position; Vector3 end = spawnPoints.Next(); Rigidbody proj = Instantiate(subBossProjectilePrefab); proj.transform.position = start; proj.velocity = CalculateBallisticVelocity(end); return(proj.transform); }
void SpawnEnemy() { if (Enemy.totalEntities >= MAX_ENEMIES) { return; } Transform enemy = Instantiate(enemyPrefab); // spawn at a random spawn point if (spawnPoints != null) { enemy.position = spawnPoints.Next().position; } else { enemy.position = transform.position; } }
public Coord GetRandomOpenCoord() { return(openTiles.Next()); }