public Score(string name, WordManager manager, WordSearchPageViewModel viewModel) { Name = name; Points = viewModel.GameScore; Level = 2;// (int)manager.DifficultyLevel; Date = DateTimeOffset.Now; }
// Initialize tiles private bool InitalizeHeaderAndTiles(Defines.GameDifficulty level, double width, double height) { bool bOK = true; try { // Check if sound is on SoundSettingIsOn = Preferences.Get("soundOn", true); ScorePenaltyWarned = false; // Create word manager Manager = new WordManager(); Manager.DifficultyLevel = level; // set up WordManager delegate events Manager.GameCompletedCallback += OnGameCompletedCallbackAsync; Manager.WordCompletedCallback += OnWordCompletedCallbackAsync; // Databinding int secondsRemaining = Manager.GetStartSecondsRemaining(); int points = Manager.GetPointsPerLetter(); BindingContext = new WordSearchPageViewModel(Navigation, secondsRemaining, points, webViewHeader, webViewTiles); // Html callbacks webViewHeader.RegisterAction(HeaderJSCallback); webViewTiles.RegisterAction(TilesJSCallback); // Set sizes ScreenWidth = width; ScreenHeight = height; TilesScreenHeight = height - Defines.HEADER_HTML_HEIGHT; ViewModel.HtmlPageWidth = width; ViewModel.HtmlHeaderPageHeight = 100; double wordHeight = height - 100; ViewModel.HtmlTilePageHeight = wordHeight; Task.Run(() => { CalculateTiles(); LoadWordsTiles(); LoadWordsHeader(); }); // xamarin essentials screen lock if (!ScreenLock.IsActive) { ScreenLock.RequestActive(); } } catch (Exception ex) { Logger.Instance.Error($"InitalizeHeaderAndTiles exception, {ex.Message}"); bOK = false; } return(bOK); }