コード例 #1
0
 private void ShowBuyQuery(PropertyListing property)
 {
     if (this.Dispatcher.CheckAccess())
     {
         myBoard.Dice.ToggleEndTurnEnabled(true);
         if (property.IsOwned)
         {
             string msg = localPlayer.PlayerGUID + Message.DELIMETER + property.Owner + Message.DELIMETER + property.CalculateRent();
             comm.Send(new Message(Message.Type.Rent, Encoding.UTF8.GetBytes(msg)).ToBytes());
             PayRent(localPlayer.PlayerGUID, property.Owner, property.CalculateRent());
             return;
         }
         if (property.Cost > localPlayer.Money)
         {
             MessageBox.Show("You cannot afford this property");
             return;
         }
         if (property.Cost == 0)
         {
             return;
         }
         BuyQuery bq = new BuyQuery(this, property);
         bq.Result += new EventHandler <BuyPropertyEventArgs>(bq_Result);
         bq.ShowDialog();
     }
     else
     {
         this.Dispatcher.BeginInvoke(new Action <PropertyListing>(ShowBuyQuery), new object[] { property });
     }
 }
コード例 #2
0
 private void ShowBuyQuery(PropertyListing property)
 {
     if (this.Dispatcher.CheckAccess())
     {
         myBoard.Dice.ToggleEndTurnEnabled(true);
         if (property.IsOwned)
         {
             string msg = localPlayer.PlayerGUID + Message.DELIMETER + property.Owner + Message.DELIMETER + property.CalculateRent();
             comm.Send(new Message(Message.Type.Rent, Encoding.UTF8.GetBytes(msg)).ToBytes());
             PayRent(localPlayer.PlayerGUID, property.Owner, property.CalculateRent());
             return;
         }
         if (property.Cost > localPlayer.Money)
         {
             MessageBox.Show("You cannot afford this property");
             return;
         }
         if(property.Cost == 0)
         {
             return;
         }
         BuyQuery bq = new BuyQuery(this, property);
         bq.Result += new EventHandler<BuyPropertyEventArgs>(bq_Result);
         bq.ShowDialog();
     }
     else this.Dispatcher.BeginInvoke(new Action<PropertyListing>(ShowBuyQuery), new object[] { property });
 }