void IService.Initialize() { _spawnTimer = Observable.Timer(TimeSpan.FromSeconds(_settings.GenerationRateInSeconds)) .Repeat() .Subscribe(_ => { var bomb = _settings.GeneratedObjects[Random.Range(0, _settings.GeneratedObjects.Count)]; _signalService.FireSignal(new SpawnBombSignal(bomb.View, bomb.Data, GenerationExtensions.GetRandomPoint(_settings.MinGenerationPoint, _settings.MaxGenerationPoint, _settings.DefaultStartHeight))); }); }
void IService.Initialize() { _spawnTimer = Observable.Timer(TimeSpan.FromSeconds(_settings.GenerationRateInSeconds)) .Repeat() .Subscribe(_ => { var unit = _settings.GeneratedObjects[Random.Range(0, _settings.GeneratedObjects.Count)]; var targetPosition = GenerationExtensions.GetRandomPoint(_settings.MinGenerationPoint, _settings.MaxGenerationPoint, _settings.DefaultStartHeight); if (UnitCanBeSpawned(targetPosition, unit.View.transform.localScale)) { _signalService.FireSignal(new SpawnUnitSignal(unit.View, unit.Data, targetPosition)); } }); }