public override void Draw(GameTime gameTime) { Matrix transformMatrix = _cameraMap.SimView; ScreenManager.SpriteBatch.Begin(transformMatrix: transformMatrix); _gridRenderer.Draw(ScreenManager.SpriteBatch, _grid, _images, _cameraMap); Vector2 mousePosition = ScreenManager.InputManager.GetMousePosition(); Vector2 mousePositionWorld = _cameraMap.ConvertScreenToWorld(mousePosition); HexagonAxial axial = mousePositionWorld.PixelToHex(); _gridRenderer.DrawHexagonOutline(ScreenManager.SpriteBatch, axial.HexToPixel(), 2.0f, Color.DeepSkyBlue); _troll.Draw(ScreenManager.SpriteBatch); ScreenManager.SpriteBatch.End(); transformMatrix = _camera1.SimView; ScreenManager.SpriteBatch.Begin(transformMatrix: transformMatrix); ScreenManager.SpriteBatch.DrawCircle(_centerPixel, 5.0f, 10, Color.Red, 2); ScreenManager.SpriteBatch.FillRectangle(_topLeftPixel.X + 10.0f, _topLeftPixel.Y + 10.0f, 265.0f, 105.0f, new Color(Color.Salmon, 0.5f)); ScreenManager.SpriteBatch.FillRectangle(_topRightPixel.X - 340.0f, _topRightPixel.Y, 340.0f, 900.0f, Color.DarkSlateGray); Vector2 mousePosition1 = ScreenManager.InputManager.GetMousePosition(); Vector2 mousePosition2 = _camera1.ConvertScreenToWorld(mousePosition1); Vector2 mousePosition3 = mousePosition2 + _cameraMap.Position; Vector2 mousePosition4 = _camera1.ConvertWorldToScreen(mousePosition2); DrawString(string.Format("Camera Center: [{0} ; {1}]", _cameraMap.Position.X.ToString("0"), _cameraMap.Position.Y.ToString("0")), _topLeftPixel + new Vector2(15.0f, 35.0f), Color.DarkBlue); DrawString(string.Format("Mouse (Real): [{0} ; {1}]", mousePosition1.X.ToString("0"), mousePosition1.Y.ToString("0")), _topLeftPixel + new Vector2(15.0f, 55.0f), Color.DarkBlue); DrawString(string.Format("Mouse (ScreenToWorld): [{0} ; {1}]", mousePosition3.X.ToString("0"), mousePosition3.Y.ToString("0")), _topLeftPixel + new Vector2(15.0f, 75.0f), Color.DarkBlue); DrawString(string.Format("Mouse (WorldToScreen): [{0} ; {1}]", mousePosition4.X.ToString("0"), mousePosition4.Y.ToString("0")), _topLeftPixel + new Vector2(15.0f, 95.0f), Color.DarkBlue); ScreenManager.SpriteBatch.End(); }
private Vector2 DeterminePositionToDraw(Cell cell) { HexagonAxial axial = cell.ToAxial(); Vector2 centerPixel = axial.HexToPixel(); return(centerPixel); }
public void Draw(SpriteBatch spriteBatch) { Vector2 centerPixel = _position.HexToPixel(); Vector2 topLeftPixel = centerPixel - new Vector2(Constants.HALF_HEX_WIDTH, Constants.HALF_HEX_HEIGHT); spriteBatch.Draw(_image, topLeftPixel, Color.White); if (_isSelected) { spriteBatch.DrawCircle(centerPixel, 30.0f, 20, Color.LimeGreen, 5); } }