示例#1
0
        private void AllCardPlace_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var cp = sender as CardPlace;

            foreach (CardPlace item in SlotGrid.Children)
            {
                if (item.ContainsCard)
                {
                    continue;
                }

                var oslot = cp.ThisCard.slot;
                var nslot = int.Parse(item.Tag.ToString());

                var isError = false;

                var res = false;

                App.ProxyMutex.WaitOne();
                try
                {
                    res = ServiceProxy.Proxy.ChangeCardslot(App.UserName, oslot, nslot);
                }
                catch (CommunicationException exc)
                {
                    App.OnException();
                    isError = true;
                }

                App.ProxyMutex.ReleaseMutex();

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


                if (res)
                {
                    cp.selected = false;
                    var fillMyCardGridThread = new Thread(GetAllCard)
                    {
                        IsBackground = true
                    };
                    fillMyCardGridThread.Start();
                }

                return;
            }

            var dw = new DialogWin(this,
                                   "Все боевые слоты уже заняты\nЧтобы переместить туда эту карту необходимо освободить один...",
                                   MessageBoxButton.OK);

            App.WindowList.Add(dw.Name, dw);
            dw.ShowDialog();
        }
示例#2
0
        private void sellBtn_MouseUp_1(object sender, MouseButtonEventArgs e)
        {
            DialogWin dw = new DialogWin(App.WindowList["LobbyWnd"], "Вы точно хотите продать эту карту за 350 очков?",
                                         MessageBoxButton.YesNo);

            App.WindowList.Add(dw.Name, dw);

            if (dw.ShowDialog() == true)
            {
                bool res = false;

                new Action(delegate
                {
                    bool isError = false;

                    App.ProxyMutex.WaitOne();
                    try
                    {
                        res = ServiceProxy.Proxy.SellCard(App.UserName, thisCard.slot);
                    }
                    catch (CommunicationException exc)
                    {
                        App.OnException();
                        isError = true;
                    }

                    App.ProxyMutex.ReleaseMutex();

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

                if (res)
                {
                    selected = false;
                    CardDeath();
                    //CardContextMenu.Visibility = Visibility.Hidden;
                    (App.WindowList["LobbyWnd"] as LobbyScreen).GetAllCard();
                    (App.WindowList["LobbyWnd"] as LobbyScreen).UpdateInfo();
                }
            }
            sellBtn.Visibility = Visibility.Hidden;
        }
示例#3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.DialogWnd = ((CardGameClient.DialogWin)(target));

            #line 5 "..\..\..\DialogWin.xaml"
                this.DialogWnd.Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);

            #line default
            #line hidden

            #line 5 "..\..\..\DialogWin.xaml"
                this.DialogWnd.ContentRendered += new System.EventHandler(this.DialogWnd_ContentRendered);

            #line default
            #line hidden
                return;

            case 2:
                this.TextInfo = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 3:
                this.AcceptBtn = ((CardGameClient.StyledBtn)(target));
                return;

            case 4:
                this.AcceptBtnOnly = ((CardGameClient.StyledBtn)(target));
                return;

            case 5:
                this.CancelBtn = ((CardGameClient.StyledBtn)(target));
                return;
            }
            this._contentLoaded = true;
        }
示例#4
0
        public void BuyCards(int number)
        {
            string price = string.Empty;

            DoubleAnimation da = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(250));
            da.FillBehavior = FillBehavior.Stop;
            da.Completed += new EventHandler(delegate(object sender, EventArgs e)
                {
                    ShopGrid.Visibility = Visibility.Hidden;
                });
            ShopGrid.BeginAnimation(OpacityProperty, da);


            if (number == 1) price = "2000";
            else if (number == 2) price = "4000";
            else if (number == 3) price = "8000";

            DialogWin dw = new DialogWin(this, "Внимание!\nПокупка карты будет стоить " + price  + " очков\nЖелаете продолжить?",
                        MessageBoxButton.YesNo);

            App.WindowList.Add(dw.Name, dw);
            if (dw.ShowDialog() == true)
            {
                new Action(delegate
                {
                    List<Card> card = null;
                    bool isError = false;

                    App.ProxyMutex.WaitOne();
                    try
                    {
                        card = ServiceProxy.Proxy.BuyCard(App.UserName, number);
                        App.charInfo = ServiceProxy.Proxy.EnterWorld(App.UserName);
                        GetAllCard();

                    }
                    catch (CommunicationException exc)
                    {
                        App.OnException();
                        isError = true;
                    }

                    App.ProxyMutex.ReleaseMutex();

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

                    if (card.Count == 0)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            DialogWin dw2 = new DialogWin(this, 
                                "Недостаточно средств.\nДля покупки необходимо не менее " + price + " очков",
                                MessageBoxButton.OK);
                            App.WindowList.Add(dw2.Name, dw2);
                            dw2.ShowDialog();
                        }));
                    }
                    else
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Rating.Text = "Очки: " + App.charInfo.score;
                            CardsScore.Text = "Очки: " + App.charInfo.score;

                            CardPackWindow cpw = new CardPackWindow(card);
                            App.WindowList.Add(cpw.Name, cpw);
                            ShopGrid.Visibility = Visibility.Hidden;

                            cpw.ShowDialog();

                        }));
                    }
                }).BeginInvoke(new AsyncCallback(delegate(IAsyncResult ar) { }), null);
            }
        }