Example #1
0
        public List <UnityPlayerPetPosition> GetOthers(int tileX, int tileY)
        {
            listPlayerPos.Clear();
            for (int i = 0; i < listPlayer.Count; i++)
            {
                Player player = listPlayer.ElementAt <Player>(i);

                if (player.GetMapController().GetTileX() == tileX && player.GetMapController().GetTileY() == tileY)
                {
                    if (player.GetIsActive())
                    {
                        float[] pos = GeoConverter.GeoCoorToMercatorProjection(player.GetLatitude(), player.GetLongitude());

                        UnityPlayerPetPosition playerInList = new UnityPlayerPetPosition();
                        playerInList.playerName    = player.GetPlayerName();
                        playerInList.posX          = pos[0];
                        playerInList.posY          = pos[1];
                        playerInList.petName       = player.GetPet().GetPetName();
                        playerInList.petPosX       = player.GetPet().GetPosX();
                        playerInList.petPosY       = player.GetPet().GetPosY();
                        playerInList.petLastPosX   = player.GetPet().GetLastPosX();
                        playerInList.petLastPosY   = player.GetPet().GetLastPosY();
                        playerInList.timeStartMove = player.GetPet().GetTimeStartMove();
                        playerInList.petState      = player.GetPet().GetPetState();
                        playerInList.ballState     = player.GetPet().GetBallState();
                        playerInList.petSpeed      = player.GetPet().GetSpeed();

                        listPlayerPos.Add(playerInList);
                    }
                }
            }

            return(listPlayerPos);
        }
Example #2
0
        private void ProcessRouteData(dynamic routeData)
        {
            string shape = (string)routeData.routes[0].geometry;

            shape = shape.Replace("\\\\", "\\"); // remove the escaped character '\'

            PolylineDecoder   pd       = new PolylineDecoder();
            List <Coordinate> listCoor = pd.Decode(shape, 5);

            for (int i = 0; i < listCoor.Count; i++)
            {
                Coordinate coor     = listCoor[i];
                float[]    mercator = GeoConverter.GeoCoorToMercatorProjection((float)Convert.ToDouble(coor.latitude), (float)Convert.ToDouble(coor.longitude));
                float      tempX    = mercator[0] - this.centerMercatorX;
                float      tempY    = mercator[1] - this.centerMercatorY;

                Coordinate newCoor = new Coordinate();
                newCoor.latitude  = tempX;
                newCoor.longitude = tempY;

                this.finalRoute.Add(newCoor);
            }
        }
Example #3
0
        public bool ConvertLocationAndCheck(float latitude, float longitude)
        {
            bool result = false;

            float[] mercator = GeoConverter.GeoCoorToMercatorProjection(latitude, longitude);
            float[] pixel    = GeoConverter.MercatorProjectionToPixel(mercator, zoom);
            int[]   tile     = GeoConverter.PixelToTileCoordinate(pixel);

            if (firstAcess)
            {
                centerMercatorX = mercator[0];
                centerMercatorY = mercator[1];
                firstAcess      = false;
            }

            if (tile[0] == tileX && tile[1] == tileY)
            {
                result = false;
            }
            else
            {
                centerMercatorX = mercator[0];
                centerMercatorY = mercator[1];

                tileX  = tile[0];
                tileY  = tile[1];
                result = true;
            }

            this.posX       = mercator[0] - centerMercatorX;
            this.posY       = mercator[1] - centerMercatorY;
            this.centerPosX = centerMercatorX; //mercator[0];
            this.centerPosY = centerMercatorY; //mercator[1];

            return(result);
        }
Example #4
0
        private void ConvertBuildingData(dynamic building)
        {
            this.listMapData.listBuildingData.Clear();

            for (int i = 0; i < building.features.Count; i++)
            {
                var tempData = building.features[i];
                if (tempData.properties.building != "")
                {
                    if (tempData.geometry.type == "Polygon")
                    {
                        BuildingData buildingData = new BuildingData();
                        buildingData.listCoordinate = new List <Coordinate>();

                        for (int j = 0; j < tempData.geometry.coordinates[0].Count; j++)
                        {
                            var coordinate = tempData.geometry.coordinates[0][j];

                            float tempX = (float)Convert.ToDouble(coordinate[0]) - this.centerMercatorX;
                            float tempY = (float)Convert.ToDouble(coordinate[1]) - this.centerMercatorY;

                            Coordinate coor = new Coordinate();
                            coor.latitude  = tempX;
                            coor.longitude = tempY;
                            buildingData.listCoordinate.Add(coor);
                        }

                        buildingData.buildingName = tempData.properties.name;
                        this.listMapData.listBuildingData.Add(buildingData);

                        // add centroid of polygon
                        BuildingData centroidData = new BuildingData();
                        centroidData.listCoordinate = new List <Coordinate>();

                        float[]    centroid     = this.FindCentroid(buildingData.listCoordinate);
                        Coordinate coorCentroid = new Coordinate();
                        coorCentroid.latitude  = centroid[0];
                        coorCentroid.longitude = centroid[1];
                        centroidData.listCoordinate.Add(coorCentroid);
                        centroidData.buildingName = tempData.properties.name;
                        this.listMapData.listBuildingData.Add(centroidData);
                    }

                    if (tempData.geometry.type == "Point")
                    {
                        BuildingData buildingData = new BuildingData();
                        buildingData.listCoordinate = new List <Coordinate>();

                        var     coordinate = tempData.geometry.coordinates;
                        float[] mercator   = GeoConverter.GeoCoorToMercatorProjection((float)Convert.ToDouble(coordinate[1]), (float)Convert.ToDouble(coordinate[0]));
                        float   tempX      = mercator[0] - this.centerMercatorX;
                        float   tempY      = mercator[1] - this.centerMercatorY;

                        Coordinate coor = new Coordinate();
                        coor.latitude  = tempX;
                        coor.longitude = tempY;
                        buildingData.listCoordinate.Add(coor);

                        buildingData.buildingName = tempData.properties.name;
                        this.listMapData.listBuildingData.Add(buildingData);
                    }
                }
            }
        }