예제 #1
0
        private SetCategoryDTO BuildBoard(string levelName, int levelCardTotal)
        {
            PossibleItems.Shuffle();
            var items = PossibleItems.Take(levelCardTotal).ToList();
            var setCategory = new SetCategoryDTO { Key = OptionsKeys.Colors, Name = CategoryConstants.ColorCategoryName, LevelName = levelName };

            foreach (var item in items)
            {
                item.SetLevelName = levelName;
            }

            setCategory.Populate(items);

            return setCategory;
        }
예제 #2
0
        public async void Init(Frame rootFrame, SetCategoryDTO category, int userId)
        {
            var users = await _storageManager.Users();
            CurrentUser = new UsersViewModel(users.FirstOrDefault(x => x.Id == userId));

            PageTitle = category.Name;
            CurrentGameBoardLevel = category.LevelName;

            _category = category;

            CreateGameboard(category.Sets);
            CreateLeaderboard(_category.Name, _category.LevelName, CurrentUser.Id);
            
            _rootFrame = rootFrame;
                        
        }
예제 #3
0
        private async Task SetupBoard(string boardId, string boardLevel, int userId )
        {
            var optionsFactory = new OptionsFactory();
            var categoryFactory = optionsFactory.SelectedCategory(boardId);
            var setCategoryDTO = new SetCategoryDTO();

            switch (boardLevel)
            {
                case LevelConstants.EasyLevel:
                    setCategoryDTO = categoryFactory.BuildEasyBoard();
                    break;

                case LevelConstants.MediumLevel:
                    setCategoryDTO = categoryFactory.BuildMediumBoard();
                    break;

                case LevelConstants.HardLevel:
                    setCategoryDTO = categoryFactory.BuildHardBoard();
                    break;
            }

            ((GameBoardViewModel)DataContext).Init(Frame, setCategoryDTO, userId);

        }
예제 #4
0
        private void SetGameBoardLevelMode(string boardLevelName)
        {
            // need to prompt the users before we do all this
            if (boardLevelName == CurrentGameBoardLevel) { return; }

            Action callback = () => 
            {
                try
                {
                    CurrentGameMode = GameMode.Loading;

                    var categoryFactory = _optionsFactory.SelectedCategory(_category.Key);

                    switch (boardLevelName)
                    {
                        case LevelConstants.EasyLevel:
                            _category = categoryFactory.BuildEasyBoard();
                            break;

                        case LevelConstants.HardLevel:
                            _category = categoryFactory.BuildHardBoard();
                            break;

                        case LevelConstants.MediumLevel:
                        default:
                            _category = categoryFactory.BuildMediumBoard();
                            break;
                    }

                    _sets = _category.Sets;

                    CurrentGameBoardLevel = boardLevelName;
                    CreateGameboard(_sets);
                    CreateLeaderboard(_category.Name, CurrentGameBoardLevel, CurrentUser.Id);

                    OnPropertyChanged("IsCurrentGameBoardPinned");

                }
                finally
                {
                    CurrentGameMode = GameMode.NotStarted;
                }
            };

            if (IsGameInProgress)
            {
                OnAskToStartNewGame(boardLevelName, callback.Invoke);
            }
            else
            {
                callback.Invoke();
            }
        }