public void TerrainFragmentFilling(TerrainFragment terrainFragment) { for(int i=1; i<=terrainFragment.TerrainLength; i++) { if(!TryToSpawn(_obstacles, terrainFragment, i)) { TryToSpawn(_bonuses, terrainFragment, i); } } }
private bool TryToSpawn(SceneObjectsType _objects, TerrainFragment terrainFragment, int zPos) { SceneObjectsData _objectToSpawn = _objects.NeedToSpawn(); if(_objectToSpawn!=null) { _objects.CooldownCounter += _objects.Cooldown; BaseSceneObject sceneObject = _objectToSpawn.SceneObjectPool.GetObjectFromPool(); sceneObject.transform.parent = terrainFragment.transform; sceneObject.transform.localPosition = new Vector3(_objectToSpawn.PossibleLineSpawn.GetRandomItem().localPosition.x, sceneObjectsYPos, zPos); terrainFragment.AddSceneObject(sceneObject, _objectToSpawn.SceneObjectPool); return true; } return false; }
private void ReleaseTerrain(TerrainFragment terrain) { _terrainPool.ReleaseObject(terrain); }