Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void ProcessRouteData(dynamic routeData)
        {
            string shape = (string)routeData.trip.legs[0].shape;

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

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

            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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public List <UnityPlayerPetPosition> GetOthers(dynamic data)
        {
            listPlayerPos.Clear();
            for (int i = 0; i < listPlayer.Count; i++)
            {
                Player player = listPlayer.ElementAt <Player>(i);

                //Console.WriteLine("player name = "+player.GetPlayerName());
                //Console.WriteLine("player X = "+ player.GetMapController().GetTileX()+" ;;;; data X = "+ (int)data.tileX);
                //Console.WriteLine("player Y = " + player.GetMapController().GetTileY() + " ;;;; data Y = " + (int)data.tileY);

                if (player.GetMapController().GetTileX() == (int)data.tileX && player.GetMapController().GetTileY() == (int)data.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();

                        listPlayerPos.Add(playerInList);
                    }
                }
            }

            return(listPlayerPos);
        }
Ejemplo n.º 5
0
        private void ConvertPOIData(dynamic poi)
        {
            if (this.listMapData.listBuildingData == null)
            {
                this.listMapData.listBuildingData = new List <BuildingData>();
            }

            for (int i = 0; i < poi.features.Count; i++)
            {
                var tempData = poi.features[i];

                BuildingData buildingData = new BuildingData();
                buildingData.listCoordinate = new List <Coordinate>();

                var     coordinate = tempData.geometry.coordinates;
                float[] mercator   = GeoConverter.GeoCoorToMercatorProjection((float)coordinate[1], (float)coordinate[0]);

                /*
                 * float tempX = mercator[0] - this.centerMercatorX;
                 * float tempY = mercator[1] - this.centerMercatorY;
                 */

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

                //coordinate[1] = tempX;
                //coordinate[0] = tempY;
                Coordinate coor = new Coordinate();
                coor.latitude  = tempX;
                coor.longitude = tempY;
                buildingData.listCoordinate.Add(coor);

                buildingData.buildingName = tempData.properties.name;
                this.listMapData.listBuildingData.Add(buildingData);
            }
        }
Ejemplo n.º 6
0
        private void ConvertBuildingData(dynamic building)
        {
            this.listMapData.listBuildingData.Clear();

            for (int i = 0; i < building.features.Count; i++)
            {
                var tempData = building.features[i];
                //Debug.WriteLine(tempData.properties.code);
                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[] 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;
                             */

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

                            //coordinate[1] = tempX;
                            //coordinate[0] = tempY;
                            Coordinate coor = new Coordinate();
                            coor.latitude  = tempX;
                            coor.longitude = tempY;
                            buildingData.listCoordinate.Add(coor);
                        }

                        buildingData.buildingName = tempData.properties.name;

                        buildingData.buildingCode = tempData.properties.code;
                        this.listMapData.listBuildingData.Add(buildingData);

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

                        float[]    centeroid     = this.FindCenteroid(buildingData.listCoordinate);
                        Coordinate coorCenteroid = new Coordinate();
                        coorCenteroid.latitude  = centeroid[0];
                        coorCenteroid.longitude = centeroid[1];
                        centeroidData.listCoordinate.Add(coorCenteroid);
                        centeroidData.buildingName = tempData.properties.name;
                        this.listMapData.listBuildingData.Add(centeroidData);
                    }

                    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[1] = tempX;
                        //coordinate[0] = tempY;
                        Coordinate coor = new Coordinate();
                        coor.latitude  = tempX;
                        coor.longitude = tempY;
                        buildingData.listCoordinate.Add(coor);

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