void InitialSpawn() { int cellsNumberToSpawn = (int)(FIELD_SIZE * FIELD_SIZE * DEVELOPMENT_COEFF); int overallSquare = 0; int steps = 0; while (overallSquare < cellsNumberToSpawn) { steps++; GameBuilding randomBuilding = SpawnRandom(cellsNumberToSpawn - overallSquare, steps); if (randomBuilding != null) { overallSquare += GameBuilding.Square((int)(randomBuilding.Type)); } } }
int GetRandomType(int cellsLeftToSpawn, int steps) { int randomType = 0; int maxType = (int)(BuildingType.ebm_max); Random.seed = (int)(Time.time) + steps + 2; if (cellsLeftToSpawn > GameBuilding.Square(maxType)) { randomType = Random.Range(0, maxType); } else if (cellsLeftToSpawn > GameBuilding.Square(--maxType)) { randomType = Random.Range(0, maxType); } return(randomType); }