Exemple #1
0
        private void resetShipOnTrack()
        {
            parentRacer.isRespawning = false;
            millisecsLeftTillReset   = 5000;
            //public struct ResetColumn { public Vector3 pos; int column; int resetWaypointIncrement; }

            Vector3 originalPos = currentProgressWaypoint.position;
            Vector3 putativePos = currentProgressWaypoint.position; //nearestMapPoint.position;

            float       shipLength          = 1.5f;                 //TODO:don't set manually
            int         columnInc           = 0;
            int         waypointInc         = 0;
            bool        readyToPlaceOnTrack = false;
            ResetColumn newRC = new ResetColumn(putativePos, parentRacer.raceTiming.stopwatch.ElapsedMilliseconds);

            // On each iteration - 5 horizontal slots
            while (!readyToPlaceOnTrack && waypointInc < 8)
            {
                putativePos -= 2 * shipLength * currentProgressWaypoint.tangent;
                // Start at current way point, go left and right to find an empty spot, then start going forward.
                if (Race.currentRaceType.resettingShips.Count == 0)
                {
                    readyToPlaceOnTrack = true;
                    newRC.position      = putativePos;
                    newRC.timeFromReset = parentRacer.raceTiming.stopwatch.ElapsedMilliseconds;
                }

                // Go across 5
                while (!readyToPlaceOnTrack && columnInc < 3)
                {
                    foreach (ResetColumn rc in Race.currentRaceType.resettingShips)
                    {
                        if ((rc.position.X - putativePos.X) < shipLength && (rc.position.Y - putativePos.Y) < shipLength && (rc.position.Z - putativePos.Z) < shipLength)
                        {
                            readyToPlaceOnTrack = false;
                        }
                        else
                        {
                            // Found a good location to place the ship
                            readyToPlaceOnTrack = true;
                            newRC.position      = putativePos;
                            newRC.timeFromReset = parentRacer.raceTiming.stopwatch.ElapsedMilliseconds;
                            //newRC.column = columnInc;
                            //newRC.resetWaypointIncrement = resetWaypointInc;}
                        }
                    }

                    putativePos += shipLength * currentProgressWaypoint.tangent;
                    columnInc++;
                }
                columnInc = 0;
                waypointInc++;
                currentProgressWaypoint = mapData.nextPoint(currentProgressWaypoint);
            }

            Race.currentRaceType.resettingShips.Add(newRC);

            Vector3 newShipPosition = newRC.position + currentProgressWaypoint.trackUp * 4;

            ShipPosition = newShipPosition;
            racerEntity.LinearVelocity  = Vector3.Zero;
            racerEntity.AngularVelocity = Vector3.Zero;
            racerEntity.WorldTransform  = Matrix.CreateWorld(newShipPosition, mapData.nextPoint(currentProgressWaypoint).position - newShipPosition, currentProgressWaypoint.trackUp);

            //resetShipAtLastWaypoint(); //TODO: start some kind of animation, white noise
            parentRacer.shipDrawing.spawn.Respawn(parentRacer.shipPhysics.ShipPosition, parentRacer.shipPhysics.DrawOrientation);
            despawnShown = false;
        }
        private void resetShipOnTrack()
        {
            parentRacer.isRespawning = false;
            millisecsLeftTillReset = 5000;
            //public struct ResetColumn { public Vector3 pos; int column; int resetWaypointIncrement; }

            Vector3 originalPos = currentProgressWaypoint.position;
            Vector3 putativePos = currentProgressWaypoint.position; //nearestMapPoint.position;

            float shipLength = 1.5f;//TODO:don't set manually
            int columnInc = 0;
            int waypointInc = 0;
            bool readyToPlaceOnTrack = false;
            ResetColumn newRC = new ResetColumn(putativePos, parentRacer.raceTiming.stopwatch.ElapsedMilliseconds);

            // On each iteration - 5 horizontal slots
            while (!readyToPlaceOnTrack && waypointInc < 8)
            {
                putativePos -= 2 * shipLength * currentProgressWaypoint.tangent;
                // Start at current way point, go left and right to find an empty spot, then start going forward.
                if (Race.currentRaceType.resettingShips.Count == 0)
                {
                    readyToPlaceOnTrack = true;
                    newRC.position = putativePos;
                    newRC.timeFromReset = parentRacer.raceTiming.stopwatch.ElapsedMilliseconds;
                }

                // Go across 5
                while (!readyToPlaceOnTrack && columnInc < 3)
                {
                    foreach (ResetColumn rc in Race.currentRaceType.resettingShips)
                    {
                        if ((rc.position.X - putativePos.X) < shipLength && (rc.position.Y - putativePos.Y) < shipLength && (rc.position.Z - putativePos.Z) < shipLength)
                        {
                            readyToPlaceOnTrack = false;

                        }
                        else
                        {
                            // Found a good location to place the ship
                            readyToPlaceOnTrack = true;
                            newRC.position = putativePos;
                            newRC.timeFromReset = parentRacer.raceTiming.stopwatch.ElapsedMilliseconds;
                            //newRC.column = columnInc;
                            //newRC.resetWaypointIncrement = resetWaypointInc;}
                        }
                    }

                    putativePos += shipLength * currentProgressWaypoint.tangent;
                    columnInc++;
                }
                columnInc = 0;
                waypointInc++;
                currentProgressWaypoint = mapData.nextPoint(currentProgressWaypoint);
            }

            Race.currentRaceType.resettingShips.Add(newRC);

            Vector3 newShipPosition = newRC.position + currentProgressWaypoint.trackUp * 4;

            ShipPosition = newShipPosition;
            racerEntity.LinearVelocity = Vector3.Zero;
            racerEntity.AngularVelocity = Vector3.Zero;
            racerEntity.WorldTransform = Matrix.CreateWorld(newShipPosition, mapData.nextPoint(currentProgressWaypoint).position - newShipPosition, currentProgressWaypoint.trackUp);

            //resetShipAtLastWaypoint(); //TODO: start some kind of animation, white noise
            parentRacer.shipDrawing.spawn.Respawn(parentRacer.shipPhysics.ShipPosition, parentRacer.shipPhysics.DrawOrientation);
            despawnShown = false;
        }