예제 #1
0
 public void Jump(UserPiece up, int current, int destination)
 {
     if (this.Dispatcher.CheckAccess())
     {
         Property cur = null;
         Property des = null;
         foreach (var tp in myBoard.myBoard.Children)
         {
             if (tp as Property != null && ((Property)tp).PropertyListing.Location == current)
                 cur = ((Property)tp);
             if (tp as Property != null && ((Property)tp).PropertyListing.Location == destination)
                 des = ((Property)tp);
         }
         if (cur == null || des == null)
             return;
         cur.Spots.Children.Remove(up);
         try
         {
             des.Spots.Children.Add(up);
         }
         catch (Exception) { }
         up.CurrentLocation = destination;
         if (up.CurrentLocation == 0)
         {
             Players[up.PlayerGUID].Money += 200;
             myChat.NewMessage("System", Players[up.PlayerGUID].PlayerName + " receives $200 for passing on GO.");
         }
     }
     else this.Dispatcher.BeginInvoke(new Action<UserPiece, int, int>(Jump), new object[] { up, current, destination });
 }
예제 #2
0
        public void movePlayer(int numSpaces)
        {
            //place holder-----------
            UserPiece up = new UserPiece();

            //---------------
            MW.Move(up, numSpaces);
        }
예제 #3
0
        public void Move(UserPiece up, int value)
        {
            ParameterizedThreadStart start = new ParameterizedThreadStart(MoveWork);
            Thread moveThread = new Thread(start);

            moveThread.IsBackground = true;
            moveThread.Name         = "MoveThread";
            moveThread.Start(new object[] { up, value } as object);
        }
예제 #4
0
        public void jumpTo(int loc)
        {
            //place holders--------
            UserPiece up      = new UserPiece();
            int       current = 0;

            //------------
            MW.Jump(up, current, loc);
        }
예제 #5
0
 ///////////
 //Methods//
 ///////////
 public void InitialPlacement(ref UserPiece u)
 {
     foreach (var tp in myBoard.myBoard.Children)
     {
         if (tp as Property != null && ((Property)tp).PropertyListing.Location == 0)
         {
             ((Property)tp).Spots.Children.Add(u = new UserPiece());
             u.CurrentLocation = 0;
         }
     }
 }
예제 #6
0
 ///////////
 //Methods//
 ///////////
 public void InitialPlacement(ref UserPiece u)
 {
     foreach (var tp in myBoard.myBoard.Children)
     {
         if (tp as Property != null && ((Property)tp).PropertyListing.Location == 0)
         {
             ((Property)tp).Spots.Children.Add(u = new UserPiece());
             u.CurrentLocation = 0;
         }
     }
 }
예제 #7
0
        private void MoveWork(object param)
        {
            object[] parameters = param as object[];
            if (parameters == null)
            {
                System.Console.WriteLine("Error in parsing parameters for MoveWork.");
                return;
            }
            UserPiece up    = parameters[0] as UserPiece;
            int       value = (int)parameters[1];

            if (up == null)
            {
                System.Console.WriteLine("Error in parsing UserPiece for MoveWork.");
                return;
            }
            int i = up.CurrentLocation + value;

            if (i > 39)
            {
                int j = up.CurrentLocation;
                i     = i - 40;
                value = value - i;
                while (up.CurrentLocation <= j + value)
                {
                    if (up.CurrentLocation == 39)
                    {
                        Jump(up, up.CurrentLocation, 0);
                        Thread.Sleep(250);
                        break;
                    }
                    else
                    {
                        Jump(up, up.CurrentLocation, up.CurrentLocation + 1);
                    }
                    Thread.Sleep(250);
                }
            }
            while (up.CurrentLocation < i)
            {
                Jump(up, up.CurrentLocation, up.CurrentLocation + 1);
                Thread.Sleep(250);
            }
            if (localPlayer.PlayerId == currentTurnPlayerID)
            {
                ShowBuyQuery(myBoard.Listings[up.CurrentLocation]);
            }
        }
예제 #8
0
 public void Jump(UserPiece up, int current, int destination)
 {
     if (this.Dispatcher.CheckAccess())
     {
         Property cur = null;
         Property des = null;
         foreach (var tp in myBoard.myBoard.Children)
         {
             if (tp as Property != null && ((Property)tp).PropertyListing.Location == current)
             {
                 cur = ((Property)tp);
             }
             if (tp as Property != null && ((Property)tp).PropertyListing.Location == destination)
             {
                 des = ((Property)tp);
             }
         }
         if (cur == null || des == null)
         {
             return;
         }
         cur.Spots.Children.Remove(up);
         try
         {
             des.Spots.Children.Add(up);
         }
         catch (Exception) { }
         up.CurrentLocation = destination;
         if (up.CurrentLocation == 0)
         {
             Players[up.PlayerGUID].Money += 200;
             myChat.NewMessage("System", Players[up.PlayerGUID].PlayerName + " receives $200 for passing on GO.");
         }
     }
     else
     {
         this.Dispatcher.BeginInvoke(new Action <UserPiece, int, int>(Jump), new object[] { up, current, destination });
     }
 }
예제 #9
0
 public void Move(UserPiece up, int value)
 {
     ParameterizedThreadStart start = new ParameterizedThreadStart(MoveWork);
     Thread moveThread = new Thread(start);
     moveThread.IsBackground = true;
     moveThread.Name = "MoveThread";
     moveThread.Start(new object[] { up, value } as object);
 }
예제 #10
0
 public void jumpTo(int loc)
 {
     //place holders--------
     UserPiece up = new UserPiece();
     int current = 0;
     //------------
     MW.Jump(up, current, loc);
 }
예제 #11
0
 public void movePlayer(int numSpaces)
 {
     //place holder-----------
     UserPiece up = new UserPiece();
     //---------------
     MW.Move(up, numSpaces);
 }