private void ScatterCards(List <CardView> cards, double animationTime, List <Task <object> > taskList) { if (cards.Count == 0) { Debug.Assert(false, "Called ScatterCards before AddCardsToGrid"); return; } Rect rect = Window.Current.Bounds; Rect scatterBounds = ViewCallback.ScatterBounds(); double width = rect.Width - cards[0].ActualWidth; double height = rect.Height - cards[0].ActualHeight; Random rand = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); Point ptRand; foreach (CardView card in cards) { do { ptRand = new Point(rand.NextDouble() * width, rand.NextDouble() * height); } while (!scatterBounds.Contains(ptRand)); card.AnimateToTaskList(ptRand, true, animationTime, taskList); } }
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; }
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; }
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); } }
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(); }
public async Task HintWindow_ShowAndWait(string message) { if (_hintDispatchTimer == null) { _hintDispatchTimer = new DispatcherTimer(); _hintDispatchTimer.Tick += HintReminder_Tick; _hintDispatchTimer.Interval = TimeSpan.FromSeconds(5); } _hintDispatchTimer.Start(); await HintWindow.ShowAndWait(message); ViewCallback.RemindUserToHitContinue(false); _hintDispatchTimer.Stop(); }
public void Reset() { if (PlayerScore != null) { PlayerScore.Reset(); ComputerScore.Reset(); } Board.Reset(); PlayerSetScoreControl.HideAsync(); HintWindow.ShowAsync(false, false, "Swipe Up to and hit New Game!"); if (GridDeck.Items.Count > 52) { Debug.Assert(false, "Too many cards in your deck after reset!"); } HintWindow.ResetScoreHistory(); ViewCallback.Reset(); }
public async Task OnGameOver(PlayerType winner, int winBy) { string message = ""; if (winner == PlayerType.Player) { message = "Congratulations! You won the game."; if (winBy > 30) { message += "\n\nYou skunked the computer!"; } } else { winner = PlayerType.Computer; message = "Sorry, you have lost the game.\nBetter luck next time."; if (winBy > 30) { message += "\n\n(You were skunked)"; } } await AnimateAllCardsBackToDeck(); ShowHintWindowAsync(true, false, message); if (winner == PlayerType.Player) { await ViewCallback.ShowSomethingFlashy(); } MainPage.Current.AppBar.IsOpen = true; }
////Loads the preview of the selected claim, similar to the core XIAP functionality. public void LoadPreview(IEnumerable<ISearchRow> rows, ViewCallback callback, HandleErrorCallback handleErrorCallback) { this._previewController.LoadPreview(rows, arg => callback(arg), handleErrorCallback); }
public Rect ScatterBounds() { return(ViewCallback.ScatterBounds()); }
private void HintReminder_Tick(object sender, object e) { ViewCallback.RemindUserToHitContinue(true); _hintDispatchTimer.Stop(); }