public OffsetCoords ConvertWorldToOffsetTest(int worldX, int worldY, int size) { // ACT var factOffsetCoords = HexHelper.ConvertWorldToOffset(worldX, worldY, size); // ASSERT return(factOffsetCoords); }
private void ProcessMouseCommands(SectorViewModelContext sectorViewModelContext) { var mouseState = Mouse.GetState(); var inverseCameraTransform = Matrix.Invert(_camera.Transform); var mouseInWorld = Vector2.Transform(new Vector2(mouseState.X, mouseState.Y), inverseCameraTransform); var offsetMouseInWorld = HexHelper.ConvertWorldToOffset((int)mouseInWorld.X, (int)mouseInWorld.Y * 2, (int)(MapMetrics.UnitSize / 2)); var map = _sector.Map; var hoverNodes = map.Nodes.OfType <HexNode>().Where(node => node.OffsetCoords == offsetMouseInWorld); var hoverNode = hoverNodes.FirstOrDefault(); _uiState.HoverViewModel = GetViewModelByNode(sectorViewModelContext, _uiState.HoverViewModel, hoverNode); if (!_leftMousePressed && mouseState.LeftButton == ButtonState.Pressed && _uiState.HoverViewModel != null && _uiState.CanPlayerGivesCommand && !BottomMenuPanel.MouseIsOver && !PersonMarkersPanel.MouseIsOver) { _leftMousePressed = true; _uiState.SelectedViewModel = _uiState.HoverViewModel; var command = SelectCommandBySelectedViewModel( _uiState.SelectedViewModel, _commandFactory, _uiState); if (command.CanExecute().IsSuccess) { _commandPool.Push(command); } } if (_leftMousePressed && mouseState.LeftButton == ButtonState.Released) { _leftMousePressed = false; } }