public async Task <bool> Initialize() { //var result = await Game.StartGame(puzzle.GameId); //if (result.Status != GameStartStatus.Ok) //{ // var dialog = new MessageDialog("You have already played this game or an error occurred. Please select another one.", "Can't start this game"); // await dialog.ShowAsync(); // return false; //} //Image = puzzle.Background; //OnPropertyChanged(nameof(Image)); //puzzle.Word = result.WordToGuess; if (string.IsNullOrWhiteSpace(puzzle?.Word)) { return(false); } Background = await LogicHelper.GetBluredImage(puzzle.GamePhotoNoSplitUrl); OnPropertyChanged(nameof(Background)); resultWord = new ObservableCollection <Cell>(); for (int i = 0; i < puzzle.Word.Length; i++) { resultWord.Add(new Cell { Letter = puzzle.Word[i].ToString(), BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xE4, 0xE4, 0xE4)), ForeColor = new SolidColorBrush(Color.FromArgb(0xff, 0x47, 0x47, 0x47)), }); } LogicHelper.DownloadPhoto(puzzle.GamePhotoNoSplitUrl, PhotoDownloaded); OnPropertyChanged(nameof(ResultWord)); return(true); }
public AddNewGameViewModel(PictureSourceEnum selectedPictureSource) { scrambledWord = new ObservableCollection <Cell>(); resultWord = new ObservableCollection <Cell>(); enteredWord = new ObservableCollection <Cell>(); enteredWord.Add(new Cell { BackgroundColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xDA, 0x95, 0x00)), Letter = "" }); for (int i = 0; i < 7; i++) { enteredWord.Add(new Cell { Letter = "", BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xA8, 0xA8, 0xA8)), ForeColor = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) }); } puzzle = new Puzzle { CreatorName = AppInfo.AppUser.Name, Language = AppInfo.AppUser.SelectedLanguage }; LanguageImage = new BitmapImage(new Uri(@"ms-appx:///Assets/Graphics/Languages/language_empty.png")); PictureSource = selectedPictureSource; LogicHelper.DownloadPhoto(LogicHelper.CreateImageUrl(ImageTypeToDownload.ProfilePhotoBig, AppInfo.AppUser.UserId), PhotoDownloaded); }
public MainPageViewModel() { selectedCategory = CategoryEnum.AllPuzzles; allPuzzles = new ObservableCollection <Puzzle>(); if (AppInfo.AppUser != null) { selectedLanguage = AppInfo.AppUser.SelectedLanguage; LogicHelper.DownloadPhoto(LogicHelper.CreateImageUrl(ImageTypeToDownload.ProfilePhotoBig, AppInfo.AppUser.UserId), PhotoDownloaded); } }
public async void LoadImage() { if (imageLoading) { return; } imageLoading = true; LogicHelper.DownloadPhoto(creatorPhotoUrl, UpdateProfileImage); Background = await LogicHelper.GetBluredImage(gamePhotoNoSplitUrl); OnPropertyChanged(nameof(Background)); }
private void StartGame() { timer.Stop(); this.Image = nextPhoto; OnPropertyChanged(nameof(Image)); OnPropertyChanged(nameof(NeedDisplayStartTimer)); OnPropertyChanged(nameof(NeedDisplayPlayControl)); OnPropertyChanged(nameof(CanSkip)); timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 80) }; timer.Tick += GameTimer_Tick; timer.Start(); LogicHelper.DownloadPhoto(puzzle.GamePhotoMidSplitUrl, NextPhotoDownloaded); }
public UserViewModel(UserModel user = null) { if (user == null) { this.user = new UserModel(); } else { this.user = user; copyUser = this.user.GetCopy(); connectedToFb = AppInfo.AppUser?.FbId != null && AppInfo.AppUser?.FbId != "no_email_accept" && AppInfo.AppUser?.FbId != "no_facebook"; UserDataUpdated(); } this.Image = new BitmapImage(new Uri(@"ms-appx:///Assets/Graphics/btn_owl.png")); LogicHelper.DownloadPhoto(LogicHelper.CreateImageUrl(ImageTypeToDownload.ProfilePhotoBig, this.user.UserId), PhotoDownloaded); countryCodes = Task.Run(async() => await LogicHelper.GetCountriesCodes()).Result; if (string.IsNullOrWhiteSpace(this.user.CountryCode)) { var region = new GeographicRegion().CodeThreeLetter; var item = countryCodes.FirstOrDefault(r => r.ContryCode == region); if (item != null) { selectedCountry = item; } else { selectedCountry = countryCodes.FirstOrDefault(); } this.user.CountryCode = selectedCountry.PhoneCodeDigitOnly; } else { var item = countryCodes.FirstOrDefault(r => r.PhoneCodeDigitOnly == this.user.CountryCode); if (item != null) { selectedCountry = item; } else { selectedCountry = countryCodes.FirstOrDefault(); } } }
public async Task <bool> Initialize() { var result = await Game.StartGame(puzzle.GameId); if (result.Status != GameStartStatus.Ok) { var dialog = new MessageDialog("You have already played this game or an error occurred. Please select another one.", "Can't start this game"); await dialog.ShowAsync(); return(false); } //Image = puzzle.Background; //OnPropertyChanged(nameof(Image)); puzzle.Word = result.WordToGuess; resultWord = new ObservableCollection <Cell>(); for (int i = 0; i < puzzle.Word.Length; i++) { resultWord.Add(new Cell { Letter = "", BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xA8, 0xA8, 0xA8)), ForeColor = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) }); } lettersArray = new ObservableCollection <Cell>(); CreateLettersArray(result.Leters); App.IgnorGoBackRequest = true; timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 1) }; timer.Tick += Timer_Tick; timer.Start(); LogicHelper.DownloadPhoto(puzzle.GamePhotoMaxSplitUrl, NextPhotoDownloaded); OnPropertyChanged(nameof(ResultWord)); OnPropertyChanged(nameof(LettersArray)); return(true); }
private void GameTimer_Tick(object sender, object e) { timeInMillieconds -= 10; if (timeInMillieconds == 2000) { this.Image = nextPhoto; OnPropertyChanged(nameof(Image)); LogicHelper.DownloadPhoto(puzzle.GamePhotoNoSplitUrl, NextPhotoDownloaded); } else if (timeInMillieconds == 1000) { this.Image = nextPhoto; OnPropertyChanged(nameof(Image)); } else if (timeInMillieconds <= 0) { timeInMillieconds = 0; TimeOut(); } OnPropertyChanged(nameof(TimeInMilliseconds)); }
private void EndGame() { timer.Stop(); if (timeInMillieconds > 1000) { LogicHelper.DownloadPhoto(puzzle.GamePhotoNoSplitUrl, image => { this.Image = image; OnPropertyChanged(nameof(Image)); }); } resultWord.Clear(); var str = puzzle.Word.ToUpper(); foreach (char t in str) { resultWord.Add(new Cell { Letter = t.ToString(), BackgroundColor = new SolidColorBrush(Color.FromArgb(0xff, 0xE4, 0xE4, 0xE4)), ForeColor = new SolidColorBrush(Color.FromArgb(0xff, 0x47, 0x47, 0x47)), }); } OnPropertyChanged(nameof(SkipButtonText)); OnPropertyChanged(nameof(CanSkip)); OnPropertyChanged(nameof(NeedDisplayPlayControl)); OnPropertyChanged(nameof(NeedDisplayEndGameControl)); OnPropertyChanged(nameof(EndGameMessage)); if (skiped) { timeInMillieconds = 0; } Game.EndGame(puzzle.GameId, timeInMillieconds); }