Ejemplo n.º 1
0
 public static void AirGateThresholdCrossed(Controller.DroneRacer player, AirGate airGate)
 {
     if (IsRaceInProgress() == true && instance != null && instance.droneRacer == player)
     {
         //Debug.Log(string.Format("Air Gate {0} threshold crossed.", airGate.name));
         instance.HandleThreshold(airGate);
     }
 }
Ejemplo n.º 2
0
        int FindAirGate(AirGate airGate)
        {
            int retVal = -1;

            for (int i = 0; i < airGates.Count; i++)
            {
                if (airGate == airGates[i])
                {
                    retVal = i;
                    break;
                }
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        void HandleThreshold(AirGate airGate)
        {
            int airGateIdx = FindAirGate(airGate);

            if (airGateIdx < 0)
            {
                Debug.LogError("Air gate not found!");
                return;
            }

            if (firstThresholdCrossed == false && airGateIdx != 0)
            {
                return;
            }

            firstThresholdCrossed = true;

            if (airGateIdx == 0)
            {
                if (lapThresholdCrossed == true)
                {
                    lapCount++;

                    //Debug.Log(string.Format("lapCount={0}  totalLaps={1}", lapCount, raceInfo.totalLaps));

                    lapThresholdCrossed = false;

                    if (lapCount < raceInfo.totalLaps)
                    {
                        stopwatch.Lap();

                        UpdateRaceStatus(RaceStatus.InProgress);

                        SetAllAirGatesNotCrossed();
                    }
                    else
                    {
                        UpdateRaceStatus(RaceStatus.Finished);

                        SetAllAirGatesNone();

                        StopRace();
                    }
                }
                else
                {
                    lapThresholdCrossed = true;
                }
            }

            if (droneRacer.RaceStatus == RaceStatus.InProgress)
            {
                airGateIdx = airGateIdx + (lapCount * airGates.Count);

                SetAirGateCrossed(airGateIdx);

                if (airGateIdx > curAirGateIdx)
                {
                    curAirGateIdx = airGateIdx;

                    UpdateRaceStatus(RaceStatus.InProgress);

                    //Debug.Log("*** Passed thru air gate " + curAirGateIdx);
                }

                SetAirGateNext(curAirGateIdx + 1);
            }
        }