} // constructor Racer #endregion #region racing /// <summary> /// Temporary move method (need to fix): /// </summary> public void move() { //Make sure the previous runner has finished unless there is no previous runner if(prev != null) prev.Join(); while (xPos < endPoint) { Thread.Sleep(sleep); xPos += speed; } //If its the last runner win the race for the team on this track if(lastRunner) { raceTrack.raceComplete(track); } }
} // constructor Racer #endregion #region racing /// <summary> /// Temporary move method (need to fix): /// </summary> public void move() { //if the previous thread is not null and the xPos is >= to the distance //the racer needs to travel, then join the threads. if (prev != null && xPos >= distance) { prev.Join(); } //while xPos is > endPoint while (xPos < endPoint) { Thread.Sleep(sleep); xPos += speed; } //if lastRunner is true, then end the race; call raceComplete if (lastRunner == true) { raceTrack.raceComplete(track); } }
} // constructor Racer #endregion #region racing /// <summary> /// Temporary move method (need to fix): /// </summary> public void move() { if (prev != null) { prev.Join(); } while (true) { if(xPos >= endPoint+distance) { if (lastRunner) { raceTrack.raceComplete(track); } return; } else { Thread.Sleep(sleep); xPos += speed; } } }