Exemplo n.º 1
0
        public void AnimateDmgAdtnl(LastHitInfo lhi)
        {
            if (lhi.IsCritical)
            {
                dmgLabeladtnl.Content = "Крит!";
                dmgLabel.Foreground   = Brushes.CornflowerBlue;

                dmgLabeladtnl.Opacity = 1;
            }

            if (lhi.isMissed)
            {
                dmgLabeladtnl.Content    = "Промах!";
                dmgLabeladtnl.Foreground = Brushes.DimGray;

                dmgLabeladtnl.Opacity = 1;
            }

            if (!lhi.isMissed)
            {
                dmgLabel.Content = lhi.dmg;
                dmgLabel.Opacity = 1;


                DoubleAnimation db = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(350));
                db.FillBehavior = FillBehavior.Stop;
                db.AutoReverse  = true;
                dmgImgEffect.BeginAnimation(OpacityProperty, db);

                ThicknessAnimation th = new ThicknessAnimation();
                th.From         = dmgLabel.Margin;
                th.FillBehavior = FillBehavior.Stop;
                th.To           = new Thickness(dmgLabel.Margin.Left, dmgLabel.Margin.Top - 70, dmgLabel.Margin.Right, dmgLabel.Margin.Bottom);
                th.Duration     = TimeSpan.FromMilliseconds(700);
                th.Completed   += new EventHandler(th_Completed);
                dmgLabel.BeginAnimation(MarginProperty, th);
            }

            ThicknessAnimation tha = new ThicknessAnimation();

            tha.From         = dmgLabeladtnl.Margin;
            tha.FillBehavior = FillBehavior.Stop;
            tha.To           = new Thickness(dmgLabeladtnl.Margin.Left, dmgLabeladtnl.Margin.Top - 70, dmgLabeladtnl.Margin.Right,
                                             dmgLabeladtnl.Margin.Bottom);
            tha.Duration   = TimeSpan.FromMilliseconds(700);
            tha.Completed += new EventHandler(tha_Completed);
            dmgLabeladtnl.BeginAnimation(MarginProperty, tha);
        }
Exemplo n.º 2
0
        private void enemyCardPlace_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var cp = sender as CardPlace;

                if (enemySelectedCardPlace != null && enemySelectedCardPlace != cp)
                {
                    enemySelectedCardPlace.selected = false;
                }

                enemySelectedCardPlace = cp;

                foreach (var item in enemyCardPlases.Values)
                {
                    item.IsEnabled = false;
                }

                foreach (var item in myCardPlases.Values)
                {
                    item.IsEnabled = false;
                }

                //attack
                var         isError = false;
                LastHitInfo lhi     = null;
                App.ProxyMutex.WaitOne();
                try
                {
                    lhi = ServiceProxy.Proxy.DoAttack(App.NickName, mySelectedCardPlace.ThisCard.slot,
                                                      enemySelectedCardPlace.ThisCard.slot);
                }
                catch
                {
                    App.OnException();
                    isError = true;
                }

                App.ProxyMutex.ReleaseMutex();

                if (isError)
                {
                    App.OnConnectionError();
                    return;
                }

                //if success
                if (lhi != null)
                {
                    enemySelectedCardPlace.AnimateDmgAdtnl(lhi);
                    mySelectedCardPlace.AnimateTurn();
                }

                enemySelectedCardPlace.selected = mySelectedCardPlace.selected = false;

                foreach (var item in myCardPlases.Values)
                {
                    if (item.ContainsCard && item.ThisCard.Enabled)
                    {
                        item.IsEnabled = true;
                    }
                }
            }
            catch (Exception exc)
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    MessageBox.Show(exc.Message, "Критическая ошибка!");
                    App.isConnected = false;
                    App.dumpException(exc);
                    Application.Current.Shutdown();
                }));
            }
        }