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 }); }
public void movePlayer(int numSpaces) { //place holder----------- UserPiece up = new UserPiece(); //--------------- MW.Move(up, numSpaces); }
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); }
public void jumpTo(int loc) { //place holders-------- UserPiece up = new UserPiece(); int current = 0; //------------ MW.Jump(up, current, loc); }
/////////// //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; } } }
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]); } }
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 }); } }