Exemple #1
0
        public override void Start(Game Game)
        {
            Button.Click += delegate(object sender, RoutedEventArgs e)
            {
                if (IsPressed == false)
                {
                    if (CheckList != null && CheckList.Count > 0)
                    {
                        foreach (var x in CheckList)
                        {
                            if (x.Check() == false)
                            {
                                return;
                            }
                        }
                    }
                    foreach (var x in Abilities)
                    {
                        if (x.DoEffect() == false)
                        {
                            return;
                        }
                    }

                    Game.MakeMove();
                    Button.Background = (Brush)App.Current.TryFindResource("TButtonGradientBrush");
                    IsPressed         = !IsPressed;
                }
                else
                {
                    foreach (var x in Abilities)
                    {
                        if (x is PositiveAbility)
                        {
                            NegativeAbility xx = new NegativeAbility(((Ability)x).MainStat, ((Ability)x).TempStat);
                            if (xx.DoEffect() == false)
                            {
                                return;
                            }
                        }
                        else if (x is NegativeAbility)
                        {
                            PositiveAbility xx = new PositiveAbility(((Ability)x).MainStat, ((Ability)x).TempStat);
                            if (xx.DoEffect() == false)
                            {
                                return;
                            }
                        }
                    }

                    Game.MakeMove();
                    Button.Background = (Brush)App.Current.TryFindResource("FButtonGradientBrush");
                    IsPressed         = !IsPressed;
                }
            };
        }
Exemple #2
0
        public virtual void Start(Game Game, IValuta Price)
        {
            Button.Click += delegate(object sender, RoutedEventArgs e)
            {
                if (IsPressed == false)
                {
                    if (CheckList != null && CheckList.Count > 0)
                    {
                        foreach (var x in CheckList)
                        {
                            if (x.Check() == false)
                            {
                                return;
                            }
                        }
                    }

                    foreach (var x in Abilities)
                    {
                        x.DoEffect();
                    }

                    cts   = new CancellationTokenSource();
                    Token = cts.Token;
                    Button.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate { Button.Background = (Brush)App.Current.TryFindResource("TButtonGradientBrush"); });                   // = );
                    IsPressed = !IsPressed;

                    AsyncStart(Game, Token, Price);
                }
                else
                {
                    cts.Cancel();
                    Button.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate { Button.Background = (Brush)App.Current.TryFindResource("FButtonGradientBrush"); });                   // = );
                    foreach (var x in Abilities)
                    {
                        if (x is PositiveAbility)
                        {
                            NegativeAbility xx = new NegativeAbility(((Ability)x).MainStat, ((Ability)x).TempStat);
                            xx.DoEffect();
                        }
                        else if (x is NegativeAbility)
                        {
                            PositiveAbility xx = new PositiveAbility(((Ability)x).MainStat, ((Ability)x).TempStat);
                            xx.DoEffect();
                        }
                    }
                    Button.Background = (Brush)App.Current.TryFindResource("FButtonGradientBrush");
                    IsPressed         = !IsPressed;
                }
            };
        }