コード例 #1
0
        } // 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);
            }
        }
コード例 #2
0
ファイル: Racer.cs プロジェクト: jxw7456/Repos
        } // 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);
            }
        }
コード例 #3
0
        } // 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;
                }
            }
        }