示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
 public LevelModelEntity(LevelConfigModel levelConfigModel)
 {
     LevelConfigModel = levelConfigModel;
 }
示例#5
0
 public bool TryLoadLevel(int levelNum, out LevelConfigModel level)
 {
     level = LoadLevel(levelNum);
     return(level != null);
 }