コード例 #1
0
ファイル: ShipPhysics.cs プロジェクト: Jamedjo/BeatShift
 private void initializeWaypoints()
 {
     mapData = MapManager.currentMap.CurrentMapData;
     currentProgressWaypoint = mapData.getStartPoint();
     nearestMapPoint = mapData.getStartPoint();
     nextWaypoint = mapData.nextPoint(currentProgressWaypoint);
 }
コード例 #2
0
ファイル: KdTree3.cs プロジェクト: Jamedjo/BeatShift
 float distance(Vector3 position, MapPoint point)
 {
     return (point.position - position).Length();
 }
コード例 #3
0
ファイル: ShipPhysics.cs プロジェクト: Jamedjo/BeatShift
        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; }
            }
        }
コード例 #4
0
 float distance(Vector3 position, MapPoint point)
 {
     return((point.position - position).Length());
 }
コード例 #5
0
ファイル: MapData.cs プロジェクト: Jamedjo/BeatShift
 //Compares which map point is nearest out of the two given points
 //returns true if second point is nearest
 Boolean nearestMapPoint(Vector3 position, float firstMapPointDistance, MapPoint secondMapPoint, out float secondDistance)
 {
     secondDistance = distanceToMapPoint(position, secondMapPoint);
     if (secondDistance < firstMapPointDistance) return true;
     return false;
 }
コード例 #6
0
ファイル: MapData.cs プロジェクト: Jamedjo/BeatShift
 public MapPoint wrongwayPoint(MapPoint current)
 {
     int nextIndex = current.getIndex();
     return mapPoints[previousIndex(previousIndex(previousIndex(previousIndex(nextIndex))))];
 }
コード例 #7
0
ファイル: MapData.cs プロジェクト: Jamedjo/BeatShift
 public MapPoint previousPoint(MapPoint current)
 {
     int nextIndex = current.getIndex();
     return mapPoints[previousIndex(nextIndex)];
 }
コード例 #8
0
ファイル: MapData.cs プロジェクト: Jamedjo/BeatShift
 public MapPoint nextPoint(MapPoint current)
 {
     int nextIndex = current.getIndex() + 1;
     if (nextIndex == mapPoints.Count) nextIndex = 0;
     return mapPoints[nextIndex];
 }