コード例 #1
0
        public IEnumerator QueryForBuildingByName(string buildingName, System.Action <Building> callBack)
        {
            //Get Buildings
            BuildingTransferCollection buildingCollection = null;

            yield return(StartCoroutine(GetBuildingsByStreetName(buildingName, (BuildingTransferCollection b) => {
                buildingCollection = b;
            })));

            Building buildingGo = null;

            if (buildingCollection == null)
            {
                UIManager.Instance.QueryError();
            }
            else if (buildingCollection != null && buildingCollection.buildings.Length > 0)
            {
                buildingGo = Building.CreateFromTransfer(buildingCollection.buildings [0]);

                //Get Floors for every building
                foreach (BuildingTransfer building in buildingCollection.buildings)
                {
                    FloorTransferCollection tempftc = null;
                    yield return(StartCoroutine(GetFloorsByBuildingId(building.id, (FloorTransferCollection ftc) => {
                        tempftc = ftc;
                    })));

                    foreach (FloorTransfer floor in tempftc.floors)
                    {
                        //Get sensors per floor
                        SensorTransferCollection tempSTC = null;
                        yield return(StartCoroutine(GetSensorByFloorId(floor.id, (SensorTransferCollection stc) => {
                            tempSTC = stc;
                        })));

                        PolygonQueryTransfer tempPQT = null;
                        yield return(StartCoroutine(GetPolygonByFloorId(floor.id, (PolygonQueryTransfer pqt) => {
                            tempPQT = pqt;
                        })));

                        //Merge the floor,sensor and polygon transfer object into the Building obj.
                        Floor tempFloor = Floor.CreateFromTransfer(floor);
                        tempFloor.ImportSensors(tempSTC);
                        tempFloor.ImportPolygons(tempPQT);
                        buildingGo.ImportFloor(tempFloor);
                    }
                }
            }
            callBack(buildingGo);
        }
コード例 #2
0
        public void ImportPolygon(PolygonQueryTransfer pqt)
        {
            if (polygons == null)
            {
                polygons = new List <Polygon>();
            }

            foreach (PolygonTransferCollection st in pqt.polygons)
            {
                Polygon p = Polygon.CreateFromTransfer(st.polygon);
                p.transform.SetParent(container);
                p.gameObject.name = st.polygon.id.ToString();
                polygons.Add(p);
            }
        }
コード例 #3
0
        public IEnumerator GetPolygonByFloorId(int floorId, System.Action <PolygonQueryTransfer> callBack)
        {
            string url = string.Format(APIUrls.POLYGONS_BY_FLOOR_ID, floorId.ToString());

            WWW www = new WWW(url, null, headers);

            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                string response = RequestUtils.ArrayFormatter(ArrayFormatterType.polygons, www.text);

                PolygonQueryTransfer sc = JsonUtility.FromJson <PolygonQueryTransfer> (response);
                callBack(sc);
            }
        }
コード例 #4
0
ファイル: Floor.cs プロジェクト: ziadsawalha/IMRSV
 public void ImportPolygons(PolygonQueryTransfer tempPQT)
 {
     polygons.ImportPolygon(tempPQT);
     InitBlueprint();
 }