Ejemplo n.º 1
0
        /// <summary>
        /// Activate the provided SectorCheckpoint after deactivating the current active checkpoint.
        /// By activating, a marker will be placed at the checkpoint, and timer will run until player is in range of the checkpoint.
        /// If the index is out of bounds (>= no. of checkpoints), either end the race or reset the lap.
        /// </summary>
        /// <param name="idx">List index of SectorCheckpoint to activate in <c>markedSectorCheckpoints</c></param>
        /// <returns>The now-active SectorCheckpoint</returns>
        private SectorCheckpoint activateRaceCheckpoint(int idx)
        {
            // deactivate current active checkpoint's marker
            try { markedSectorCheckpoints[activeSector].hideMarker(); }
            catch { }

            // detect if index is out of expected range
            if (idx >= markedSectorCheckpoints.Count && lapRace)
            {
                //// if point-to-point race, then race is completed. Print time and exit race mode.
                //if (!lapRace)
                //{
                //	lapFinishedHandler(activeCheckpoint);
                //	return activeCheckpoint;
                //}

                //// if lapped race, activate the 0th checkpoint
                //else
                //{
                //	idx = 0;
                //}
                idx = 0;
            }

            // set the new SectorCheckpoint as active (by index)
            activeSector     = idx;
            activeCheckpoint = markedSectorCheckpoints[idx];

            // determine if this is the final checkpoint based on the index
            bool isFinal = activeCheckpoint.GetHashCode() == finishCheckpoint.GetHashCode();             //idx == markedSectorCheckpoints.Count - 1 || idx == 0;

            // the marker placed should be different, depending on whether this checkpoint is final
            if (isFinal)
            {
                activeCheckpoint.marker = activeCheckpoint.placeMarker(MarkerType.raceFinish, idx);
            }

            // if not final checkpoint, place a checkpoint w/ an arrow pointing to the next checkpoint
            else
            {
                Vector3 nextChkptPosition = getNextCheckpoint(idx).position;
                activeCheckpoint.marker = activeCheckpoint.placeMarker(MarkerType.raceArrow, idx, nextChkptPosition);
            }

            return(activeCheckpoint);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Redraw the blips and checkpoints of all saved SectorCheckpoints. Should only be used in placement mode.
 /// </summary>
 private void redrawAllSectorCheckpoints()
 {
     for (int i = 0; i < markedSectorCheckpoints.Count; i++)
     {
         // copy the instance of SectorCheckpoint and replace marker with a new instance returned by placeMarker
         SectorCheckpoint newCheckpoint = markedSectorCheckpoints[i];
         newCheckpoint.marker       = newCheckpoint.placeMarker(MarkerType.placement, markedSectorCheckpoints[i].number);
         markedSectorCheckpoints[i] = newCheckpoint;                                         // assign new instance of SectorCheckpoint to the original index in the List
     }
 }