// Prepear list to spawn rocks InsideRockGeneratorOutput ListWithRandomNumersToRandomRocks() { int _fullRockCheck = 0; InsideRockGeneratorOutput RandomNumersForRocks = new InsideRockGeneratorOutput(); for (int i = 0; i < DistanceFromMidToSideRock - 1; i++) { if (ShouldLeaveOpenSquareRandom()) { RandomNumersForRocks.Add(false); } else { RandomNumersForRocks.Add(true); _fullRockCheck += 1; } } // Make sure there is one empty square if (_fullRockCheck == DistanceFromMidToSideRock - 1) { RandomNumersForRocks.RemoveOneRandomRock((int)DistanceFromMidToSideRock); } return(RandomNumersForRocks); }
public void CreateInsideRocks() { float _spawnPoint = -DistanceFromMidToSideRock + Constants.GridSize; InsideRockGeneratorOutput _listNumbers = ListWithRandomNumersToRandomRocks(); //Spawn random rocks foreach (var shouldSpawn in _listNumbers.RockSpawnFlags) { if (shouldSpawn) { GameObject _rock = InstantiateRandomRock(); _rock.transform.position = transform.position + new Vector3(_spawnPoint, 0.0f, 0.0f); } _spawnPoint += Constants.GridSize; } }