Ejemplo n.º 1
0
        public BoardViewModel(IHighScoreService hsm, IToastPopUp toast, IMvxMainThreadAsyncDispatcher dispatcher)
        {
            _settings = GetSettings();
            _ge       = new GameEngine(_settings, this, hsm);

            _toast      = toast;
            _dispatcher = dispatcher;

            Title = "Play";
            // w411 h660
            //ShortestDimension = Math.Min((int)Application.Current.MainPage.Width, (int)Application.Current.MainPage.Height);

            ClickedTheProfCommand = new MvxCommand <Point>((p) =>
            {
                PerformRound(MoveDirection.None);
            });


            StartGameCommand = new MvxCommand(() =>
            {
                _gameTimer?.Stop();
                _elapsed = TimeSpan.Zero;

                _gameTimer          = new Timer(1000);
                _gameTimer.Elapsed += GameTimerElapsed;
                _gameTimer.Start();

                _ge.StartGame(GameMode.Random);
                UpdateUi(GameStatus.GameStarted, _ge.GetState(_elapsed));
            });

            ComingSoonCommand = new MvxCommand(() =>
            {
                _ = Task.Run(async() => await Application.Current.MainPage.DisplayAlert("Dahlex", "Coming SoOon", "Ok"));
            });

            NextLevelCommand = new MvxCommand(() =>
            {
                if (_ge != null)
                {
                    if (_ge.Status == GameStatus.LevelComplete)
                    {
                        //storyPanel.Resources.Clear();

                        _ge.StartNextLevel();

                        _gameTimer?.Start();
                    }

                    UpdateUi(_ge.Status, _ge.GetState(_elapsed));
                }
            });

            BombCommand = new MvxCommand(() =>
            {
                try
                {
                    _ = Task.Run(async() => await BlowBomb());
                }
                catch (Exception)
                {
                }
            });

            TeleCommand = new MvxCommand(() => DoTeleport());
        }
Ejemplo n.º 2
0
        public ScoresViewModel(IHighScoreService scores, IMvxNavigationService navigationService, IMvxMainThreadAsyncDispatcher dispatcher)
        {
            _scores     = scores;
            _dispatcher = dispatcher;
            //_navigationService = navigationService;

            BackCommand = new MvxCommand(() => _ = Task.Run(async() => await navigationService.Close(this)));
            CloseImage  = ImageSource.FromResource("DahlexApp.Assets.Images.Close.png");
        }
Ejemplo n.º 3
0
 public UiObservableCollection(IMvxMainThreadAsyncDispatcher dispatcher)
 {
     _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
 }