public bool TryLoadRandom(out LevelConfigModel level) { var minLevelNum = _levelProvider.Levels.Select(l => l.Num).Min(); var maxLevelNum = _levelProvider.Levels.Select(l => l.Num).Max(); var randomLevelNum = Random.Range(minLevelNum, maxLevelNum + 1); level = LoadLevel(randomLevelNum); return(level != null); }
public LevelConfigModel LoadNextLevel() { int currentLevelNum = _currentLevel?.Num ?? 1; currentLevelNum++; if (_levelController.TryLoadLevel(currentLevelNum, out var level)) { _currentLevel = level; _uiComponentFacade.OnSendAction(ViewActionType.LevelNumUpdate, new CustomObject(_currentLevel.Num)); return(_currentLevel); } return(LoadLevel(1)); }
public LevelConfigModel LoadLevel(int levelNum) { _currentLevel = null; if (_levelController.TryLoadLevel(levelNum, out var level)) { _currentLevel = level; } else if (_levelController.TryLoadRandom(out var levelRnd)) { _currentLevel = levelRnd; } if (_currentLevel == null) { throw new Exception("No levels"); } _uiComponentFacade.OnSendAction(ViewActionType.LevelNumUpdate, new CustomObject(_currentLevel.Num)); return(_currentLevel); }
public LevelModelEntity(LevelConfigModel levelConfigModel) { LevelConfigModel = levelConfigModel; }
public bool TryLoadLevel(int levelNum, out LevelConfigModel level) { level = LoadLevel(levelNum); return(level != null); }