示例#1
0
    private IEnumerator co_LoadCompletedForDataType(BusDataType dataType)
    {
        if (dataType == BusDataType.Stops)
        {
            foreach (BusDataStop busStop in this.busRouteDataController.busStops)
            {
                // Show all bus stops
//				this.mapIndicatorController.AddIndicatorAtLatLong(busStop.latitudeLongitude);
            }
        }
        else if (dataType == BusDataType.RouteStops)
        {
            Debug.Log("-------- this.busRouteDataController.busRouteStops.Count: " + this.busRouteDataController.busRouteStops.Count);

//			foreach (BusRouteStopItemData routeStop in this.busRouteDataController.busRouteStops) {
//				if (routeStop.routeNumber == 1) {
//					BusDataStop busStop = this.busRouteDataController.BusStopForStopId(routeStop.stopId);
//
//					this.mapIndicatorController.AddIndicatorAtLatLong(busStop.latitudeLongitude);
//
//					yield return null;
//				}
//			}

            int routeId = 3;

            for (int i = 0; i < BusRouteStopItemData.NumberOfRouteStopItemsForRoute(routeId); i++)
            {
                BusRouteStopItemData routeStopItem = BusRouteStopItemData.RouteStopItemForRouteAtIndex(routeId, i);

                BusDataStop busStop = this.busRouteDataController.BusStopForStopId(routeStopItem.stopId);

                this.mapIndicatorController.AddIndicatorAtLatLong(busStop.latitudeLongitude, 1);

                Debug.Log("Adding routeStopItem sort id: " + routeStopItem.sortOrder + " stopIds are equal: " + (routeStopItem.stopId == busStop.id).ToString());

//				yield return new WaitForSeconds(0.25f);
            }
        }

        yield return(null);
    }
    private void LoadDataIntoObjects <T>(BusDataType busDataType, XMLQuickParser xmlData, string rootNodeName, List <T> dataArray, System.Action <BusDataType> dataReadyCallback) where T : BusDataBaseObject
    {
        int dataLength = 0;

        try {
            BusDataBaseObject dataObj = null;

            foreach (XmlNode node in xmlData.xmlDoc)
            {
                if (node.Name == rootNodeName)
                {
                    foreach (XmlNode stopNode in node)
                    {
                        dataLength++;

                        // Hmm... need to look up this error
//						dataObj = new T(); // Cannot create an instance of the variable type `T' because it does not have the new() constraint

                        if (typeof(T) == typeof(BusDataStop))
                        {
                            dataObj = new BusDataStop();
                        }
                        else if (typeof(T) == typeof(BusRouteStopItemData))
                        {
                            dataObj = new BusRouteStopItemData();
                        }
                        else
                        {
                            Debug.LogWarning("No class defined for T: " + typeof(T).ToString());
                            dataObj = null;
                        }

                        foreach (XmlNode stopNodeElement in stopNode)
                        {
                            dataObj.ParseAndLoadDataElement(stopNodeElement.Name, stopNodeElement.InnerText);
                        }

                        dataObj.ParseAndLoadFinishedForObject();

                        dataArray.Add((T)dataObj);
                    }
                }
            }

            if (dataObj != null)
            {
                dataObj.ParseAndLoadFinishedForClass();
            }
            else
            {
                Debug.LogError("dataObj null on ParseAndLoadFinishedForClass");
            }

            if (dataReadyCallback != null)
            {
                dataReadyCallback(busDataType);
            }
        }
        catch (System.Exception e) {
            Debug.LogError("Failed to parse data for type: " + BusDataType.Stops + " error: " + e.ToString());
        }

        Debug.Log("Loaded data count: " + dataLength + " for type: " + typeof(T).ToString());
    }