Merge pull request #65 from dnutiu/fix-enemy-spawn
Fix enemy spawn position
This commit is contained in:
commit
eaed21b897
2 changed files with 6 additions and 3 deletions
|
@ -12,6 +12,10 @@ namespace src.Level
|
||||||
{
|
{
|
||||||
public class LevelManager : GameplayComponent, IDynamicLevelData
|
public class LevelManager : GameplayComponent, IDynamicLevelData
|
||||||
{
|
{
|
||||||
|
/** Extracted them here for easy to change reason */
|
||||||
|
private const int XMaxEnemyPosition = 5;
|
||||||
|
private const int YMinEnemyPosition = -5;
|
||||||
|
|
||||||
public Count DestructibleWallCount
|
public Count DestructibleWallCount
|
||||||
{
|
{
|
||||||
get => _destructibleWallCount;
|
get => _destructibleWallCount;
|
||||||
|
@ -202,15 +206,14 @@ namespace src.Level
|
||||||
private void SetupLevelEnemies()
|
private void SetupLevelEnemies()
|
||||||
{
|
{
|
||||||
var numberOfEnemiesToPlace = _enemyCount.RandomIntRange();
|
var numberOfEnemiesToPlace = _enemyCount.RandomIntRange();
|
||||||
|
|
||||||
_freeGridPositions.ShuffleList();
|
_freeGridPositions.ShuffleList();
|
||||||
|
_freeGridPositions.RemoveAll(pos => pos.x <= XMaxEnemyPosition && pos.y >= YMinEnemyPosition);
|
||||||
foreach (var nextPosition in _freeGridPositions)
|
foreach (var nextPosition in _freeGridPositions)
|
||||||
{
|
{
|
||||||
if (numberOfEnemiesToPlace == 0)
|
if (numberOfEnemiesToPlace == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaceEnemy(nextPosition);
|
PlaceEnemy(nextPosition);
|
||||||
numberOfEnemiesToPlace -= 1;
|
numberOfEnemiesToPlace -= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
m_EditorVersion: 2018.4.3f1
|
m_EditorVersion: 2018.4.5f1
|
||||||
|
|
Loading…
Reference in a new issue