示例#1
0
        private void SelectHex(HexCoordinate hexWorldCoordinate)
        {
            if (_selectedCoordinate != null) //Redraw the previously selected hex (deselect) if there was a previously selected hex
            {
                var oldSelectedCoordinate = _selectedCoordinate;
                _selectedCoordinate = null; //We set the SelectedCoordinate to null, so that hexMapFactory knows it is not selected
                _drawingHandler.RedrawSelectedHex(oldSelectedCoordinate);
            }

            _selectedCoordinate = hexWorldCoordinate; //Mark the new hex as selected
            _drawingHandler.RedrawSelectedHex(_selectedCoordinate);

            //Update the textfield with the hex's detail (if any)
            Hex hex = _db.Hexes.GetForCoordinate(hexWorldCoordinate);

            if (hex != null)
            {
                txtDetail.Text = hex.Detail;
            }
            else
            {
                txtDetail.Text = "";
            }

            lblCoordinates.Text = _selectedCoordinate.ToText();
        }