public MapPoint nextPoint(MapPoint current) { int nextIndex = current.getIndex() + 1; if (nextIndex == mapPoints.Count) { nextIndex = 0; } return(mapPoints[nextIndex]); }
public void UpdateWaypoints(GameTime gameTime) { nearestMapPoint = mapData.nearestMapPoint(ShipPosition); if (gameTime.TotalGameTime.Milliseconds % 500 == 0) { nearestMapPoint.pointHit(); //togle colour of nearest mapPoint every 500ms } //If ship is not on track do not update waypoints if (!parentRacer.isRespawning) { //Don't hit next waypoint if on wrong section of track (nearestPoint not within 10 of nextWaypoint if (Math.Abs(nearestMapPoint.getIndex() - nextWaypoint.getIndex()) <= 10) { //Check for collision with next waypoint using the plane defined by the tangent as the waypoint //If the Vector from the waypoint to the ship is within 90 degrees of tangent it is on the positive side of the waypoint plane if (Vector3.Dot(nextWaypoint.tangent, (ShipPosition - nextWaypoint.position)) >= 0) { //nextWaypoint.pointHit(); currentProgressWaypoint = nextWaypoint; if (currentProgressWaypoint.getIndex() == 0) { //Start point has been reached, shut down the ship if it's the last lap if (parentRacer.GetType() == typeof(RacerHuman)) { SoundManager.LapComplete(); } parentRacer.raceTiming.finishLap();//++laps //TODO: shift into } nextWaypoint = mapData.nextPoint(currentProgressWaypoint); parentRacer.racerPoints.newWaypointHit(); } } //Point to test for wrong way is mapPoint 4 behind current MapPoint wrongwayPoint = mapData.wrongwayPoint(currentProgressWaypoint); //Use vector definition of a plane to test if behind wrong way point. TODO: change this so wrongway not detected on sharp curves Boolean behindWrongwaypoint = (Vector3.Dot(wrongwayPoint.tangent, (ShipPosition - wrongwayPoint.position)) < 0); if (Vector3.Dot(racerEntity.OrientationMatrix.Forward, nearestMapPoint.tangent) < -0.2 && parentRacer.raceTiming.isRacing && (!parentRacer.isRespawning)) { wrongWay = true; } else { wrongWay = false; } } }
public void UpdateWaypoints(GameTime gameTime) { nearestMapPoint = mapData.nearestMapPoint(ShipPosition); if(gameTime.TotalGameTime.Milliseconds%500 ==0) nearestMapPoint.pointHit();//togle colour of nearest mapPoint every 500ms //If ship is not on track do not update waypoints if(!parentRacer.isRespawning){ //Don't hit next waypoint if on wrong section of track (nearestPoint not within 10 of nextWaypoint if (Math.Abs(nearestMapPoint.getIndex()-nextWaypoint.getIndex())<=10) { //Check for collision with next waypoint using the plane defined by the tangent as the waypoint //If the Vector from the waypoint to the ship is within 90 degrees of tangent it is on the positive side of the waypoint plane if (Vector3.Dot(nextWaypoint.tangent, (ShipPosition - nextWaypoint.position)) >= 0) { //nextWaypoint.pointHit(); currentProgressWaypoint = nextWaypoint; if (currentProgressWaypoint.getIndex() == 0) { //Start point has been reached, shut down the ship if it's the last lap if (parentRacer.GetType() == typeof(RacerHuman)) SoundManager.LapComplete(); parentRacer.raceTiming.finishLap();//++laps //TODO: shift into } nextWaypoint = mapData.nextPoint(currentProgressWaypoint); parentRacer.racerPoints.newWaypointHit(); } } //Point to test for wrong way is mapPoint 4 behind current MapPoint wrongwayPoint = mapData.wrongwayPoint(currentProgressWaypoint); //Use vector definition of a plane to test if behind wrong way point. TODO: change this so wrongway not detected on sharp curves Boolean behindWrongwaypoint = (Vector3.Dot(wrongwayPoint.tangent, (ShipPosition - wrongwayPoint.position)) < 0); if (Vector3.Dot(racerEntity.OrientationMatrix.Forward, nearestMapPoint.tangent) < -0.2 && parentRacer.raceTiming.isRacing && (!parentRacer.isRespawning)) { wrongWay = true; } else { wrongWay = false; } } }
public MapPoint wrongwayPoint(MapPoint current) { int nextIndex = current.getIndex(); return(mapPoints[previousIndex(previousIndex(previousIndex(previousIndex(nextIndex))))]); }
public MapPoint previousPoint(MapPoint current) { int nextIndex = current.getIndex(); return(mapPoints[previousIndex(nextIndex)]); }
public MapPoint wrongwayPoint(MapPoint current) { int nextIndex = current.getIndex(); return mapPoints[previousIndex(previousIndex(previousIndex(previousIndex(nextIndex))))]; }
public MapPoint previousPoint(MapPoint current) { int nextIndex = current.getIndex(); return mapPoints[previousIndex(nextIndex)]; }
public MapPoint nextPoint(MapPoint current) { int nextIndex = current.getIndex() + 1; if (nextIndex == mapPoints.Count) nextIndex = 0; return mapPoints[nextIndex]; }