public override void GenerateObjects() { SubjectInstances = new List <VehicleGameSubject>(); for (int i = 0; i < GameLine.Size; i++) { VehicleGameSubject prefab = SubjectPrefabs[Random.Range(0, SubjectPrefabs.Length)]; bool needGenerate = Random.Range(0, 10) < 1; if (needGenerate) { VehicleGameSubject gameSubject = PoolsContainer.PullObjectByPrefab <VehicleGameSubject>(prefab.gameObject, GameLine.transform); gameSubject.PrefabForPulling = prefab.gameObject; gameSubject.transform.localPosition = new Vector3(i - GameLine.Size / 2, 0, 0); SubjectInstances.Add(gameSubject); GameLine.SetCellState(i, gameSubject.Size, GameCell.CellState.Dangerous); i += (gameSubject.Size); } } }
public override void GenerateObjects() { float gs2 = GameLine.Size / 2; SubjectInstances = new List <GameSubject>(); for (int i = 0; i < GameLine.Size; i++) { GameSubject prefab = SubjectPrefabs[Random.Range(0, SubjectPrefabs.Length)]; bool needGenerate = Random.Range(0, gs2 - Mathf.Abs(gs2 - i)) < 1; if (needGenerate) { // GameSubject gameSubject = Instantiate(prefab, GameLine.transform); GameSubject gameSubject = PoolsContainer.PullObjectByPrefab <GameSubject>(prefab.gameObject, GameLine.transform); gameSubject.PrefabForPulling = prefab.gameObject; gameSubject.transform.localPosition = new Vector3(i - GameLine.Size / 2, 0, 0); SubjectInstances.Add(gameSubject); GameLine.SetCellState(i, GameCell.CellState.Busy); } } }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { ConfigurationUtils.Initialize(); ScreenUtils.Initialize(); PoolsContainer.Initialize(); }
void OnDestroy() { PoolsContainer.FreePools(); }