예제 #1
0
    private BusIconController NewBusIndicatorIcon(string idString, BusGTFSDataController.RouteInfo routeInfo)
    {
        BusIconController newBusIndicator = Instantiate <BusIconController>(this.busIndicatorIconTemplate);

        newBusIndicator.transform.SetParent(this.busIndicatorIconTemplate.transform.parent, false);

        newBusIndicator.SetLabelString(routeInfo.routeId);
        newBusIndicator.idString = idString;
        newBusIndicator.backgroundImage.color = Color.Lerp(routeInfo.routeColor, Color.black, 0.0f);
        newBusIndicator.shadowLabel.color     = Color.white;    // routeInfo.routeTextColor;

        newBusIndicator.name += " - " + idString;

        newBusIndicator.gameObject.SetActive(true);

        return(newBusIndicator);
    }
예제 #2
0
    public BusIconController BusIndicatorIconForId(string idString, BusGTFSDataController.RouteInfo routeInfo)
    {
        if (this.busIconControllersByIdString.ContainsKey(idString))
        {
            BusIconController busIcon = this.busIconControllersByIdString[idString];

            busIcon.gameObject.SetActive(true);

            return(busIcon);
        }
        else
        {
//			Debug.Log("Creating bus icon for id: " + idString);

            BusIconController newBusIcon = this.NewBusIndicatorIcon(idString, routeInfo);

            this.busIconControllersByIdString.Add(idString, newBusIcon);

            return(newBusIcon);
        }
    }
예제 #3
0
    private void UpdateBusPositions()
    {
//		float fractionalSecond = 0;// (float) (System.DateTime.Now - new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day, System.DateTime.Now.Hour, System.DateTime.Now.Minute, System.DateTime.Now.Second)).TotalSeconds;
//
//		float currentSecondsIntoDay = BusGTFSDataController.SecondsIntoDayForTimeString(System.DateTime.Now.ToString("HH:mm:ss")) + fractionalSecond + this.timeOffset;

        System.DateTime startOfDayDateTime    = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.Now.Day);
        float           currentSecondsIntoDay = (float)(System.DateTime.Now - startOfDayDateTime).TotalSeconds + this.timeOffset;

//		Debug.Log("Current time: " + currentSecondsIntoDay);

        if (this.timeOverride > 0)
        {
            currentSecondsIntoDay = this.timeOverride + Time.time + this.timeOffset;
        }

        this.playSpeedTimeOffset += ((this.overlayUIController.timelineBarUIController.playSpeedScalar - 1) * Time.deltaTime);

        currentSecondsIntoDay += (this.overlayUIController.timelineBarUIController.timelineScrollRect.normalizedPosition.x * 2500000) + this.playSpeedTimeOffset;

        float totalSecondsFromStartOfToday = currentSecondsIntoDay;

        while (currentSecondsIntoDay > 86400)
        {
            currentSecondsIntoDay -= 86400;
        }
        while (currentSecondsIntoDay < 0)
        {
            currentSecondsIntoDay += 86400;
        }

        this.currentTime = currentSecondsIntoDay;

        System.DateTime currentDateTime = startOfDayDateTime.AddSeconds(totalSecondsFromStartOfToday);

        this.overlayUIController.timelineBarUIController.SetCurrentTime(currentDateTime);

        foreach (KeyValuePair <string, List <BusGTFSDataController.TripInfo> > routeTripInfosPair in this.busRouteDataController.gtfsDataController.tripInfosByRouteId)
        {
            string routeStringId = routeTripInfosPair.Key;

            if (this.visibleRoutesByRouteId.Count == 0 || this.visibleRoutesByRouteId.Contains(routeStringId))
            {
                foreach (BusGTFSDataController.TripInfo tripInfo in routeTripInfosPair.Value)
                {
                    string tripId = tripInfo.tripId;

//					if (tripId.Equals("3-1209-O-92")) // at time 44697 (debug point for sequential same arrival times
//					if (tripId.Contains("-1a")) // is Mon - Fri
                    if (this.busRouteDataController.gtfsDataController.TripIdIsActiveForDayOfWeek(tripId, currentDateTime.DayOfWeek))
                    {
                        if (this.busRouteDataController.gtfsDataController.stopPointInfosByTripId.ContainsKey(tripId))
                        {
                            List <BusGTFSDataController.StopPointInfo> routeStopInfos = this.busRouteDataController.gtfsDataController.stopPointInfosByTripId[tripId];

                            for (int i = 0; i < routeStopInfos.Count - 1; i++)
                            {
                                BusGTFSDataController.StopPointInfo stopInfoA = routeStopInfos[i];
                                BusGTFSDataController.StopPointInfo stopInfoB = routeStopInfos[i + 1];

                                if (currentSecondsIntoDay >= stopInfoA.arrivalSecondsIntoTheDay && currentSecondsIntoDay < stopInfoB.arrivalSecondsIntoTheDay)
                                {
                                    float percentageBetweenStops = Mathf.InverseLerp(stopInfoA.arrivalSecondsIntoTheDay, stopInfoB.arrivalSecondsIntoTheDay, currentSecondsIntoDay);

//									percentageBetweenStops = EaseInOutSine(0, 1, percentageBetweenStops);

//									Debug.Log("tripId: " + tripId + " percentage: " + percentageBetweenStops);

//									Debug.Log("Hit active stop for tripId: " + tripId + " index: " + i + " sequence: [" + stopInfoA.sequence + ", " + stopInfoB.sequence + "] percentage: " + percentageBetweenStops);

                                    LatitudeLongitude stopALongLat = this.busRouteDataController.gtfsDataController.stopInfos[stopInfoA.stopId].latlong;
                                    LatitudeLongitude stopBLongLat = this.busRouteDataController.gtfsDataController.stopInfos[stopInfoB.stopId].latlong;

                                    LatitudeLongitude percentageLatLong = LatitudeLongitude.Lerp(stopALongLat, stopBLongLat, (double)percentageBetweenStops);

//									#warning !
//									{
//										if (tripId.Contains("65")) // Experimenting with fix for buses going off path, example at 6:21:14pm on Sunday for Route 65
//											percentageLatLong = this.busRouteDataController.gtfsDataController.LatLongClosestToPointOnRoughShapePath(percentageLatLong, "65_IB_to_DIMOND_2017");
//									}

                                    //										this.mapIndicatorController.AddIndicatorAtLatLong(stopALongLat, 4);
                                    //										this.mapIndicatorController.AddIndicatorAtLatLong(stopBLongLat, 4);

                                    //								this.mapIndicatorController.AddIndicatorAtLatLong(percentageLatLong, 4);

                                    BusIconController newBusIcon = this.overlayUIController.busMapUIController.BusIndicatorIconForId(tripId, this.busRouteDataController.gtfsDataController.routeInfosByRouteId[routeStringId]);

                                    newBusIcon.lastFrameUpdated = Time.frameCount;

                                    newBusIcon.SetLatLongPosition(percentageLatLong);
                                }
                            }
                        }
                        else
                        {
                            //								if (tripId.Trim().Equals("3-1636-I-1a"))
                            Debug.LogError("Found unknown tripId: <" + tripId + ">" + "nl: " + tripId.Contains("\n"));
                        }
                    }
                }
            }
        }

        this.overlayUIController.busMapUIController.DisableAllIndicatorsNotEqualToFrame(Time.frameCount);
    }