/// <summary> /// Draw /// </summary> /// <param name="sprite"></param> /// <param name="skeletonMeshRenderer"></param> /// <param name="gameTime"></param> /// <param name="mapShiftX"></param> /// <param name="mapShiftY"></param> /// <param name="centerX"></param> /// <param name="centerY"></param> /// <param name="renderWidth"></param> /// <param name="renderHeight"></param> /// <param name="RenderObjectScaling"></param> /// <param name="mapRenderResolution"></param> /// <param name="TickCount"></param> public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, ReflectionDrawableBoundary drawReflectionInfo, int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution, int TickCount) { Point MousePos = Mouse.GetState().Position; // relative to the window already if ((mouseCursorItemStates & (int)MouseCursorItemStates.LeftPress) != (int)MouseCursorItemStates.LeftPress && (mouseCursorItemStates & (int)MouseCursorItemStates.RightPress) != (int)MouseCursorItemStates.RightPress) // default { base.Draw(sprite, skeletonMeshRenderer, gameTime, -MousePos.X, -MousePos.Y, centerX, centerY, drawReflectionInfo, renderWidth, renderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } else // if left or right press is active, draw pressed state { cursorItemPressedState.Draw(sprite, skeletonMeshRenderer, gameTime, -MousePos.X, -MousePos.Y, centerX, centerY, drawReflectionInfo, renderWidth, renderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } }
public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, ReflectionDrawableBoundary drawReflectionInfo, int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution, int TickCount) { // control minimap render UI position via // Position.X, Position.Y // Draw the main drame base.Draw(sprite, skeletonMeshRenderer, gameTime, 0, 0, centerX, centerY, drawReflectionInfo, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); int minimapPosX = (mapShiftX + (RenderWidth / 2)) / 16; int minimapPosY = (mapShiftY + (RenderHeight / 2)) / 16; item_pixelDot.Draw(sprite, skeletonMeshRenderer, gameTime, -Position.X, -Position.Y, minimapPosX, minimapPosY, drawReflectionInfo, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); //IDXObject lastFrameDrawn = base.LastFrameDrawn; //int minimapMainFrameWidth = lastFrameDrawn.Width; //int minimapMainFrameHeight = lastFrameDrawn.Height; // draw minimap buttons foreach (MapObjects.UIObject.UIObject uiBtn in uiButtons) { BaseDXDrawableItem buttonToDraw = uiBtn.GetBaseDXDrawableItemByState(); // Position drawn is relative to the MinimapItem int drawRelativeX = -(this.Position.X) - uiBtn.X; // Left to right int drawRelativeY = -(this.Position.Y) - uiBtn.Y; // Top to bottom buttonToDraw.Draw(sprite, skeletonMeshRenderer, gameTime, drawRelativeX, drawRelativeY, centerX, centerY, null, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); } }
public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime, int mapShiftX, int mapShiftY, int centerX, int centerY, int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution, int TickCount) { // control minimap render UI position via // Position.X, Position.Y // Draw the main drame base.Draw(sprite, skeletonMeshRenderer, gameTime, 0, 0, centerX, centerY, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); int minimapPosX = (mapShiftX + (RenderWidth / 2)) / 16; int minimapPosY = (mapShiftY + (RenderHeight / 2)) / 16; item_pixelDot.Draw(sprite, skeletonMeshRenderer, gameTime, -Position.X, -Position.Y, minimapPosX, minimapPosY, RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution, TickCount); }
protected override void Draw(GameTime gameTime) { float frameRate = 1 / (float)gameTime.ElapsedGameTime.TotalSeconds; int TickCount = Environment.TickCount; float delta = gameTime.ElapsedGameTime.Milliseconds / 1000f; MouseState mouseState = Mouse.GetState(); int mouseXRelativeToMap = mouseState.X - mapShiftX; int mouseYRelativeToMap = mouseState.Y - mapShiftY; // Clear prior drawings GraphicsDevice.Clear(Color.Black); /////////////////////// DRAW ANIMATION /////////////////////// spriteBatch.Begin( SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, null, null, null, Matrix.CreateScale(renderAnimationScaling)); // Animation dxDrawableItem.Draw(spriteBatch, null, gameTime, mapShiftX, mapShiftY, 0, 0, RENDER_WIDTH, RENDER_HEIGHT, renderAnimationScaling, RenderResolution.Res_All, TickCount); if (dxDrawableItem.LastFrameDrawn != null) { IDXObject lastFrameDrawn = dxDrawableItem.LastFrameDrawn; // Boundary box Rectangle rectBox = new Rectangle( lastFrameDrawn.X - mapShiftX, lastFrameDrawn.Y - mapShiftY, lastFrameDrawn.Width, lastFrameDrawn.Height); DrawBorder(spriteBatch, rectBox, 1, Color.White); } spriteBatch.End(); /////////////////////// /////////////////////// /////////////////////// DRAW DEBUG TEXT /////////////////////// spriteBatch.Begin( SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, null, null, null, Matrix.CreateScale(RENDER_SCALING)); // Debug at the top right corner StringBuilder sb = new StringBuilder(); sb.Append("FPS: ").Append(frameRate).Append(Environment.NewLine); sb.Append("Mouse : X ").Append(mouseXRelativeToMap).Append(", Y ").Append(mouseYRelativeToMap).Append(Environment.NewLine); sb.Append("RMouse: X ").Append(mouseState.X).Append(", Y ").Append(mouseState.Y); spriteBatch.DrawString(font_DebugValues, sb.ToString(), new Vector2(RENDER_WIDTH - 170, 10), Color.White); // Current image render information if (dxDrawableItem.LastFrameDrawn != null) { IDXObject lastFrameDrawn = dxDrawableItem.LastFrameDrawn; string imageRenderInfoText = string.Format("[Path: {0}]{7}[Origin: x = {1}, y = {2}]{8}[Dimension: W = {3}, H = {4}]{9}[Delay: {5}]{10}[Scale: {6}x]", dxDrawableItem.LastFrameDrawn.Tag as string, lastFrameDrawn.X, lastFrameDrawn.Y, lastFrameDrawn.Width, lastFrameDrawn.Height, lastFrameDrawn.Delay, Math.Round(renderAnimationScaling, 2), Environment.NewLine, Environment.NewLine, Environment.NewLine, Environment.NewLine); spriteBatch.DrawString(font_DebugValues, imageRenderInfoText, new Vector2((RENDER_WIDTH / 2) - 100, RENDER_HEIGHT - 100), Color.White); } // Keyboard navigation info if (gameTime.TotalGameTime.TotalSeconds < 3) { spriteBatch.DrawString(font, string.Format("Press [Left] [Right] [Up] [Down] for navigation.{0} [+ -] for zoom", Environment.NewLine), new Vector2(20, 10), Color.White); } spriteBatch.End(); /////////////////////// /////////////////////// base.Draw(gameTime); }