예제 #1
0
        public async Task OnLoadGame(ClientStateMachine stateMachine)
        {
            StateMachine = stateMachine;
            ViewCallback.SetUIState(stateMachine.UiState);

            await AnimateAllCardsBackToDeck();

            this.Reset();   // this reletive order matters -- you want all cards belonging to the deck when this is run
            MainPage.Current.AppBar.IsOpen = false;
        }
예제 #2
0
        private async void OnNewGame(object sender, RoutedEventArgs e)
        {
            _btnNewGame.IsEnabled = false;
            _appBarBottom.IsOpen  = false;
            CribbageView view = GetCribbageView();

            _stateMachine = new ClientStateMachine();
            _stateMachine.Init(false, view);
            await view.OnNewGame(_stateMachine);

            _btnNewGame.IsEnabled = true;
        }
예제 #3
0
        public async Task OnNewGame(ClientStateMachine stateMachine)
        {
            StateMachine = stateMachine;
            ViewCallback.SetUIState(stateMachine.UiState);

            await AnimateAllCardsBackToDeck();

            this.Reset();   // this reletive order matters -- you want all cards belonging to the deck when this is run
            await PickCard("Pick a card by touching (clicking) it.  Low card deals!");

            MainPage.Current.AppBar.IsOpen = false;
        }
예제 #4
0
        public async Task Initialize(Deck deck, ClientStateMachine stateMachine)
        {
            this.Deck = deck;
            await AddCardsToGrid();

            StateMachine = stateMachine;
            if (StateMachine != null)
            {
                Hfs = stateMachine.HandsFromService;
                ViewCallback.SetUIState(stateMachine.UiState);
            }
        }
예제 #5
0
        public void InitializeAsync(Deck deck, ClientStateMachine stateMachine)
        {
            this.Deck    = deck;
            StateMachine = stateMachine;
#pragma warning disable 1998, 4014
            AddCardsToGrid();
#pragma warning restore 1998, 4014
            if (StateMachine != null)
            {
                ViewCallback.SetUIState(stateMachine.UiState);
            }

            PlayerSetScoreControl.HideAsync();
        }
예제 #6
0
        private async void OnOpenGame(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            b.IsEnabled           = false;
            _btnNewGame.IsEnabled = false;
            _appBarBottom.IsOpen  = false;
            try
            {
                var filePicker = new FileOpenPicker();
                filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                filePicker.ViewMode = PickerViewMode.List;
                filePicker.FileTypeFilter.Add(".crib");
                StorageFile file = await filePicker.PickSingleFileAsync();

                if (file == null)
                {
                    return;
                }



                using (var stream = await file.OpenStreamForReadAsync())
                {
                    using (var streamReader = new StreamReader(stream))
                    {
                        string savedGame = streamReader.ReadToEnd();

                        CribbageView view = GetCribbageView();
                        _stateMachine = new ClientStateMachine();
                        _stateMachine.Init(false, view);
                        await view.OnLoadGame(_stateMachine);

                        await _stateMachine.Load(savedGame);
                    }
                }
            }

            finally
            {
                b.IsEnabled           = true;
                _btnNewGame.IsEnabled = true;
            }
        }