protected override async Task <bool> OnApply(IGameState gameState)
        {
            var playerWantsToDoBoth = false;

            if (CanDoBoth(gameState))
            {
                playerWantsToDoBoth =
                    await
                    MetroDialog.ShowMessage("Play visitor",
                                            $"Do you want to perform both actions (cost: {DoBothCost}",
                                            MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative;
            }

            var twoChoicesViewModel = MefContainer.GetExportedValue <ITwoChoicesViewModel>();

            twoChoicesViewModel.Option1          = Option1;
            twoChoicesViewModel.Option2          = Option2;
            twoChoicesViewModel.CanSelectOption1 = CanApplyOption1(gameState);
            twoChoicesViewModel.CanSelectOption2 = CanApplyOption2(gameState);

            var result = await MetroDialog.ShowDialog(twoChoicesViewModel);

            if (result == Selection.None)
            {
                return(false);
            }

            if (playerWantsToDoBoth)
            {
                if (result == Selection.Option1)
                {
                    await ApplyOption1(gameState);

                    if (CanApplyOption2(gameState))
                    {
                        await ApplyOption2(gameState);
                    }
                }
                else
                {
                    await ApplyOption2(gameState);

                    if (CanApplyOption1(gameState))
                    {
                        await ApplyOption1(gameState);
                    }
                }

                ApplyCostforDoingBoth(gameState);
                return(true);
            }

            return(result == Selection.Option1 ? await ApplyOption1(gameState) : await ApplyOption2(gameState));
        }
예제 #2
0
        private async Task <bool> HarvestTwoFields()
        {
            var success = await HarvestField.OnExecute();

            if (!success)
            {
                return(false);
            }

            success = await HarvestField.OnExecute();

            if (!success)
            {
                return((await MetroDialog.ShowMessage("Done or cancel",
                                                      "Are you done harvesting or do you want to cancel the visitor card",
                                                      MessageDialogStyle.AffirmativeAndNegative,
                                                      new MetroDialogSettings {
                    AffirmativeButtonText = "Done", NegativeButtonText = "Cancel"
                })) ==
                       MessageDialogResult.Affirmative);
            }

            return(true);
        }