Example #1
0
    private void Update()
    {
        // Check if mouse is within map area
        if (mapViewArea.IsMouseInside())
        {
            Vector3 worldPos;
            inputHandler.GetWorldPoint(Input.mousePosition, out worldPos);
            Coordinate coords = map.GetCoordinatesFromUnits(worldPos.x, worldPos.z);

            // Check if mouse is within site bounds
            if (grid.IsInside(coords.Longitude, coords.Latitude))
            {
                // Convert coords to column & row
                int cellX = (int)((coords.Longitude - grid.west) * gridCoordsToCell.x);
                int cellY = (int)((coords.Latitude - grid.north) * gridCoordsToCell.y);

                int index = cellX + cellY * grid.countX;

                // Convert cell center to coords
                coords.Longitude = (cellX + 0.5) * gridCellToCoords.x + grid.west;
                coords.Latitude  = (cellY + 0.5) * gridCellToCoords.y + grid.north;

                if (drawingTool != null && !drawingTool.CanDraw)
                {
                    EnableDrawing();
                }

                if (index != selectedCellIndex)
                {
                    selectedCellIndex = index;
                    pulsatingCell.SetCoords(coords);

                    if (drawingArea == null)
                    {
                        PlanningCell cell;
                        if (planningCellsMap.TryGetValue(index, out cell))
                        {
                            flagger.SetSelected(cell);
                        }
                        else
                        {
                            flagger.Deselect();
                        }
                    }
                }

                return;
            }
        }

        if (drawingTool != null && drawingTool.CanDraw)
        {
            DisableDrawing();
        }
    }
Example #2
0
    //
    // Private Methods
    //

    private void UpdateValues()
    {
        // Check if mouse is within map view
        if (!mapViewArea.IsMouseInside())
        {
            ResetValues();
            return;
        }

        // Check if mouse is hitting something, and transform screen to world position
        if (!inputHandler.GetWorldPoint(Input.mousePosition, out Vector3 worldPos))
        {
            ResetValues();
            return;
        }

        // Update coordinates
        Coordinate coords = map.GetCoordinatesFromUnits(worldPos.x, worldPos.z);

        latitude.text  = ToString(coords.Latitude, "N", "S");
        longitude.text = ToString(coords.Longitude, "E", "W");
    }
Example #3
0
    private void Update()
    {
        bool isInsideOtherPanel = inputHandler.IsPointerInUI;

        if (!isInsideOtherPanel && !hidePanel && mapViewArea.IsMouseInside() && dataLayers.availableLayers.Count > 0)
        {
            if (!panel.gameObject.activeSelf)
            {
                panel.gameObject.SetActive(true);
            }

            UpdatePanelPosition();
            UpdatePanelValues();
        }
        else
        {
            if (panel.gameObject.activeSelf)
            {
                panel.gameObject.SetActive(false);
            }
        }
    }