Esempio n. 1
0
    public void SetCenterTile(int x, int y)
    {
        this.centerTileNumbers = new Vector2(x, y);
        Vector2 newCenterCoords = GeographicCoordinates.TileToWorldPos(x, y, this.zoomLevel);

        this.centerLongitude = newCenterCoords.x;
        this.centerLatitude  = newCenterCoords.y;
    }
Esempio n. 2
0
    private void CalculateDegreesPerPixel()
    {
        // TileToWorldPosition vom CenterTile
        Vector2 tileToWorldCenterTile = GeographicCoordinates.TileToWorldPos(Mathf.RoundToInt(centerTileNumbers.x), Mathf.RoundToInt(centerTileNumbers.y), this.zoomLevel);

        // TileToWorldPosition vom ein Tile weiter
        Vector2 tileToWorldCenterNextTile = GeographicCoordinates.TileToWorldPos(Mathf.RoundToInt(centerTileNumbers.x + 1), Mathf.RoundToInt(centerTileNumbers.y), this.zoomLevel);

        // Distanz zwischen Punkten geteilt durch TileSize in Pixeln = degreesPerPixel
        this.degreesPerPixel = (tileToWorldCenterNextTile.x - tileToWorldCenterTile.x) / this.tileSize;
    }
Esempio n. 3
0
    /// <summary>
    ///
    /// </summary>
    public void ScrollControl()
    {
        if (editorMode == 0)
        {
            if (Event.current.isMouse)
            {
                if (Event.current.button == 0 && Event.current.type == EventType.MouseUp)
                {
                    if (tileMap.isOnMap(Event.current.mousePosition))
                    {
                        tileMap.centerTileNumbers = tileMap.MouseToTilePosition((int)Event.current.mousePosition.x, (int)Event.current.mousePosition.y);
                        Vector2 newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel);
                        tileMap.centerLatitude  = newPos.y;
                        tileMap.centerLongitude = newPos.x;
                        tileMap.changed         = true;
                    }
                }
            }
        }

        if (Event.current.isKey && Event.current.type == EventType.KeyUp)
        {
            // Handle KeyScrolling
            Vector2 newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel);
            switch (Event.current.keyCode)
            {
            case KeyCode.UpArrow:
                newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y - 1, tileMap.zoomLevel);
                break;

            case KeyCode.DownArrow:
                newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x, (int)tileMap.centerTileNumbers.y + 1, tileMap.zoomLevel);
                break;

            case KeyCode.LeftArrow:
                newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x - 1, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel);
                break;

            case KeyCode.RightArrow:
                newPos = GeographicCoordinates.TileToWorldPos((int)tileMap.centerTileNumbers.x + 1, (int)tileMap.centerTileNumbers.y, tileMap.zoomLevel);
                break;

            default:
                break;
            }
            tileMap.centerLatitude  = newPos.y;
            tileMap.centerLongitude = newPos.x;
            tileMap.changed         = true;
            //Event.current.Use();
        }
    }