Esempio n. 1
0
        /// <summary>
        /// Draw as object
        /// </summary>
        /// <param name="sprite"></param>
        /// <param name="skeletonMeshRenderer"></param>
        /// <param name="mapShiftX"></param>
        /// <param name="mapShiftY"></param>
        /// <param name="centerX"></param>
        /// <param name="centerY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="TickCount">Ticks since system startup</param>
        public virtual void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
                                 int mapShiftX, int mapShiftY, int centerX, int centerY,
                                 int width, int height, float RenderObjectScaling, RenderResolution mapRenderResolution,
                                 int TickCount)
        {
            int shiftCenteredX = mapShiftX - centerX;
            int shiftCenteredY = mapShiftY - centerY;

            IDXObject drawFrame;

            if (notAnimated)
            {
                drawFrame = frame0;
            }
            else
            {
                drawFrame = GetCurrFrame(TickCount);
            }

            if (IsFrameWithinView(drawFrame, shiftCenteredX, shiftCenteredY, width, height))
            {
                drawFrame.DrawObject(sprite, skeletonMeshRenderer, gameTime,
                                     shiftCenteredX - _Position.X, shiftCenteredY - _Position.Y,
                                     flip);

                this._LastFrameDrawn = drawFrame; // set the last frame drawn
            }
            else
            {
                this._LastFrameDrawn = null;
            }
        }
Esempio n. 2
0
 private bool IsFrameWithinView(IDXObject frame, int shiftCenteredX, int shiftCenteredY, int width, int height)
 {
     return(frame.X - shiftCenteredX + frame.Width > 0 &&
            frame.Y - shiftCenteredY + frame.Height > 0 &&
            frame.X - shiftCenteredX < width &&
            frame.Y - shiftCenteredY < height);
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="frames"></param>
        /// <param name="item_pixelDot"></param>
        public MinimapItem(IDXObject frames, BaseDXDrawableItem item_pixelDot)
            : base(frames, false)
        {
            this.item_pixelDot = item_pixelDot;

            this.Position = new Point(10, 10); // starting position
        }
Esempio n. 4
0
        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)
        {
            if (((int)mapRenderResolution & screenMode) != screenMode || disabledBackground)  // dont draw if the screenMode isnt for this
            {
                return;
            }

            IDXObject drawFrame = GetCurrentFrame(TickCount);
            int       X         = CalculateBackgroundPosX(drawFrame, mapShiftX, centerX, renderWidth, RenderObjectScaling);
            int       Y         = CalculateBackgroundPosY(drawFrame, mapShiftY, centerY, renderHeight, RenderObjectScaling);
            int       _cx       = cx == 0 ? drawFrame.Width : cx;
            int       _cy       = cy == 0 ? drawFrame.Height : cy;

            switch (type)
            {
            case BackgroundType.Regular:
                Draw2D(sprite, skeletonMeshRenderer, gameTime, X, Y, drawFrame);
                break;

            case BackgroundType.HorizontalTiling:
                DrawHorizontalCopies(sprite, skeletonMeshRenderer, gameTime, renderWidth, X, Y, _cx, drawFrame);
                break;

            case BackgroundType.VerticalTiling:
                DrawVerticalCopies(sprite, skeletonMeshRenderer, gameTime, renderHeight, X, Y, _cy, drawFrame);
                break;

            case BackgroundType.HVTiling:
                DrawHVCopies(sprite, skeletonMeshRenderer, gameTime, renderWidth, renderHeight, X, Y, _cx, _cy, drawFrame);
                break;

            case BackgroundType.HorizontalMoving:
                DrawHorizontalCopies(sprite, skeletonMeshRenderer, gameTime, renderWidth, X + (int)bgMoveShiftX, Y, _cx, drawFrame);
                IncreaseShiftX(_cx, TickCount);
                break;

            case BackgroundType.VerticalMoving:
                DrawVerticalCopies(sprite, skeletonMeshRenderer, gameTime, renderHeight, X, Y + (int)bgMoveShiftY, _cy, drawFrame);
                IncreaseShiftY(_cy, TickCount);
                break;

            case BackgroundType.HorizontalMovingHVTiling:
                DrawHVCopies(sprite, skeletonMeshRenderer, gameTime, renderWidth, renderHeight, X + (int)bgMoveShiftX, Y, _cx, _cy, drawFrame);
                IncreaseShiftX(_cx, TickCount);
                break;

            case BackgroundType.VerticalMovingHVTiling:
                DrawHVCopies(sprite, skeletonMeshRenderer, gameTime, renderWidth, renderHeight, X, Y + (int)bgMoveShiftY, _cx, _cy, drawFrame);
                IncreaseShiftX(_cy, TickCount);
                break;

            default:
                break;
            }
        }
Esempio n. 5
0
        public int CalculateBackgroundPosY(IDXObject frame, int mapShiftY, int centerY, int RenderHeight, float RenderObjectScaling)
        {
            int height = (int)((RenderHeight / 2) / RenderObjectScaling);

            //int height = RenderHeight / 2;

            return((ry * (mapShiftY - centerY + height) / 100) + frame.Y + height);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates an instance of non-animated map item
        /// </summary>
        /// <param name="frame0"></param>
        /// <param name="flip"></param>
        public BaseDXDrawableItem(IDXObject frame0, bool flip)
        {
            this.frame0 = frame0;
            notAnimated = true;
            this.flip   = flip;

            this._Position = new Point(0, 0);
        }
Esempio n. 7
0
        public int CalculateBackgroundPosX(IDXObject frame, int mapShiftX, int centerX, int RenderWidth, float RenderObjectScaling)
        {
            int width = (int)((RenderWidth / 2) / RenderObjectScaling);

            //int width = RenderWidth / 2;

            return((rx * (mapShiftX - centerX + width) / 100) + frame.X + width);
        }
Esempio n. 8
0
 /// <summary>
 /// Creates an instance
 /// </summary>
 /// <param name="frames"></param>
 /// <param name="flip"></param>
 public BaseDXDrawableItem(List <IDXObject> frames, bool flip)
 {
     if (frames.Count == 1) // not animated if its just 1 frame
     {
         this.frame0 = frames[0];
         notAnimated = true;
         this.flip   = flip;
     }
     else
     {
         this.frames = frames;
         notAnimated = false;
         this.flip   = flip;
     }
     this._Position = new Point(0, 0);
 }
Esempio n. 9
0
        private void DrawVerticalCopies(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
                                        int simHeight, int x, int y, int cy, IDXObject frame)
        {
            int height = frame.Height;

            Draw2D(sprite, skeletonMeshRenderer, gameTime, x, y, frame);
            int copyY = y - cy;

            while (copyY + height > 0)
            {
                Draw2D(sprite, skeletonMeshRenderer, gameTime, x, copyY, frame);
                copyY -= cy;
            }
            copyY = y + cy;
            while (copyY < simHeight)
            {
                Draw2D(sprite, skeletonMeshRenderer, gameTime, x, copyY, frame);
                copyY += cy;
            }
        }
Esempio n. 10
0
        private void DrawHorizontalCopies(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
                                          int simWidth, int x, int y, int cx, IDXObject frame)
        {
            int width = frame.Width;

            Draw2D(sprite, skeletonMeshRenderer, gameTime, x, y, frame);
            int copyX = x - cx;

            while (copyX + width > 0)
            {
                Draw2D(sprite, skeletonMeshRenderer, gameTime, copyX, y, frame);
                copyX -= cx;
            }
            copyX = x + cx;
            while (copyX < simWidth)
            {
                Draw2D(sprite, skeletonMeshRenderer, gameTime, copyX, y, frame);
                copyX += cx;
            }
        }
        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);
        }
Esempio n. 12
0
 public MapItem(IDXObject frame0, bool flip)
 {
     this.frame0 = frame0;
     notAnimated = true;
     this.flip   = flip;
 }
Esempio n. 13
0
 public MobItem(MobInstance mobInstance, IDXObject frame0)
     : base(frame0, mobInstance.Flip)
 {
     this.mobInstance = mobInstance;
 }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="cy"></param>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        /// <param name="type"></param>
        /// <param name="a"></param>
        /// <param name="front"></param>
        /// <param name="frame0"></param>
        /// <param name="screenMode">The screen resolution to display this background object. (0 = all res)</param>
        public BackgroundItem(int cx, int cy, int rx, int ry, BackgroundType type, int a, bool front, IDXObject frame0, bool flip, int screenMode)
            : base(frame0, flip)
        {
            int CurTickCount = Environment.TickCount;

            this.LastShiftIncreaseX = CurTickCount;
            this.LastShiftIncreaseY = CurTickCount;
            this.rx         = rx;
            this.cx         = cx;
            this.ry         = ry;
            this.cy         = cy;
            this.type       = type;
            this.a          = a;
            this.front      = front;
            this.screenMode = screenMode;

            color = new Color(0xFF, 0xFF, 0xFF, a);

            if (frame0.Height <= 1 && frame0.Width <= 1)
            {
                this.disabledBackground = true; // removed from Map.wz/bg, but entry still presist in maps
            }
            else
            {
                this.disabledBackground = false;
            }

            CheckBGData();
        }
Esempio n. 15
0
 public void RemoveMesh(IDXObject obj)
 {
     DXObjects.Remove(obj);
     Scene.SceneChanged = true;
 }
Esempio n. 16
0
 public TooltipItem(ToolTipInstance npcInstance, IDXObject frame0)
     : base(frame0, false)
 {
     this.tooltipInstance = npcInstance;
 }
Esempio n. 17
0
 public ReactorItem(ReactorInstance reactorInstance, IDXObject frame0)
     : base(frame0, reactorInstance.Flip)
 {
     this.reactorInstance = reactorInstance;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="cx"></param>
        /// <param name="cy"></param>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        /// <param name="type"></param>
        /// <param name="a"></param>
        /// <param name="front"></param>
        /// <param name="frame0"></param>
        /// <param name="screenMode">The screen resolution to display this background object. (0 = all res)</param>
        public BackgroundItem(int cx, int cy, int rx, int ry, BackgroundType type, int a, bool front, IDXObject frame0, bool flip, int screenMode)
            : base(frame0, flip)
        {
            LastShiftIncreaseX = Environment.TickCount;
            LastShiftIncreaseY = Environment.TickCount;
            this.rx            = rx;
            this.cx            = cx;
            this.ry            = ry;
            this.cy            = cy;
            this.type          = type;
            this.a             = a;
            this.front         = front;
            this.screenMode    = screenMode;

            color = new Color(0xFF, 0xFF, 0xFF, a);
        }
Esempio n. 19
0
 public void AddMesh(IDXObject obj)
 {
     DXObjects.Add(obj);
     Scene.SceneChanged = true;
 }
Esempio n. 20
0
 public NpcItem(NpcInstance npcInstance, IDXObject frame0)
     : base(frame0, npcInstance.Flip)
 {
     this.npcInstance = npcInstance;
 }
Esempio n. 21
0
 public void Draw2D(SpriteBatch sprite, SkeletonMeshRenderer skeletonRenderer, GameTime gameTime, int x, int y, IDXObject frame)
 {
     frame.DrawBackground(sprite, skeletonRenderer, gameTime, x, y, Color, flip);
 }
 public PortalItem(PortalInstance portalInstance, IDXObject frame0)
     : base(frame0, false)
 {
     this.portalInstance = portalInstance;
 }