public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (!m_AllowDefer)
            {
                if (CheckDefer(map, drawPosition))
                    return false;
            }
            else
            {
                m_AllowDefer = false;
            }

            int displayItemdID = (m_Animated) ? Effect.ItemID + ((Effect.FramesActive / m_AnimData.FrameInterval) % m_AnimData.FrameCount) : Effect.ItemID;

            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                DrawTexture = IO.ArtData.GetStaticTexture(m_DisplayItemID);
                DrawArea = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - World.WorldViews.IsometricRenderer.TileSizeI + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return base.Draw(spriteBatch, drawPosition, mouseOverList, map);
        }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (!m_AllowDefer)
            {
                if (CheckDefer(map, drawPosition))
                    return false;
            }
            else
            {
                m_AllowDefer = false;
            }

            int displayItemdID = 0x4e20 + Effect.FramesActive;

            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                DrawTexture = IO.GumpData.GetGumpXNA(displayItemdID);
                Point offset = m_Offsets[m_DisplayItemID - 20000];
                DrawArea = new Rectangle(offset.X, DrawTexture.Height - 33 + (Entity.Z * 4) + offset.Y, DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return base.Draw(spriteBatch, drawPosition, mouseOverList, map);
        }
Esempio n. 3
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (!m_AllowDefer)
            {
                if (CheckDefer(map, drawPosition))
                    return false;
            }
            else
            {
                m_AllowDefer = false;
            }

            int displayItemdID = (m_Animated) ? Effect.ItemID + ((Effect.FramesActive / m_AnimData.FrameInterval) % m_AnimData.FrameCount) : Effect.ItemID;

            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>();
                DrawTexture = provider.GetItemTexture(m_DisplayItemID);
                DrawArea = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER, DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }

            DrawArea.X = 0 - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * 22);
            DrawArea.Y = 0 + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * 22);

            Rotation = Effect.AngleToTarget;

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return base.Draw(spriteBatch, drawPosition, mouseOverList, map);
        }
Esempio n. 4
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
 {
     if (Entity.NoDraw)
     {
         return false;
     }
     // Update Display texture, if necessary.
     if (Entity.DisplayItemID != m_DisplayItemID)
     {
         m_DisplayItemID = Entity.DisplayItemID;
         DrawTexture = Provider.GetItemTexture(m_DisplayItemID);
         if (DrawTexture == null) // ' no draw ' item.
         {
             return false;
         }
         DrawArea = new Rectangle(DrawTexture.Width / 2 - IsometricRenderer.TILE_SIZE_INTEGER_HALF, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
         PickType = PickType.PickObjects;
         DrawFlip = false;
     }
     if (DrawTexture == null) // ' no draw ' item.
     {
         return false;
     }
     DrawArea.Y = DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER + (Entity.Z * 4);
     HueVector = Utility.GetHueVector(Entity.Hue, Entity.ItemData.IsPartialHue, false, false);
     if (Entity.Amount > 1 && Entity.ItemData.IsGeneric && Entity.DisplayItemID == Entity.ItemID)
     {
         int offset = Entity.ItemData.Unknown4;
         Vector3 offsetDrawPosition = new Vector3(drawPosition.X - 5, drawPosition.Y - 5, 0);
         base.Draw(spriteBatch, offsetDrawPosition, mouseOver, map, roofHideFlag);
     }
     bool drawn = base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
     DrawOverheads(spriteBatch, drawPosition, mouseOver, map, DrawArea.Y - IsometricRenderer.TILE_SIZE_INTEGER_HALF);
     return drawn;
 }
Esempio n. 5
0
 protected override void Pick(MouseOverList mouseOver, VertexPositionNormalTextureHue[] vertexBuffer)
 {
     int x = mouseOver.MousePosition.X - (int)vertexBuffer[0].Position.X;
     int y = mouseOver.MousePosition.Y - (int)vertexBuffer[0].Position.Y;
     if (Provider.IsPointInItemTexture(m_DisplayItemID, x, y, 1))
     {
         mouseOver.AddItem(Entity, vertexBuffer[0].Position);
     }
 }
Esempio n. 6
0
        public static void Render(SpriteBatch3D spriteBatch, MouseOverList mouseOverList, Map map)
        {
            if (m_Views.Count > 0)
            {
                for (int i = 0; i < m_Views.Count; i++)
                {
                    m_Views[i].View.Draw(spriteBatch, m_Views[i].DrawPosition, mouseOverList, map);
                }

                m_Views.Clear();
            }
        }
Esempio n. 7
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
 {
     if (Entity is Mobile)
     {
         Mobile mobile = Entity as Mobile;
         if (!mobile.IsAlive || mobile.IsDisposed || mobile.Body == 0)
         {
             return false;
         }
     }
     m_BaseView.SetAllowDefer();
     return m_BaseView.Draw(spriteBatch, m_DrawPosition, mouseOverList, map);
 }
Esempio n. 8
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            int facing = MirrorFacingForDraw(Entity.Facing);
            int frameIndex = (int)(Entity.Frame * BodyConverter.DeathAnimationFrameCount(Entity.Body));

            AnimationFrame animationFrame = getFrame(Entity.Body, facing, frameIndex, Entity.Hue);

            DrawTexture = animationFrame.Texture;
            DrawArea = new Rectangle(0, 0, DrawTexture.Width, DrawTexture.Height);
            DrawFlip = false;

            return base.Draw(spriteBatch, drawPosition, mouseOverList, map);
        }
Esempio n. 9
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            if (m_NoDraw)
                return false;

            if (m_MustUpdateSurroundings)
            {
                updateSurroundingsAndNormals(Entity.Map);
                m_MustUpdateSurroundings = false;
            }

            if (!m_DrawAs3DStretched)
                return base.Draw(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag);
            else
                return Draw3DStretched(spriteBatch, drawPosition, mouseOverList, map);
        }
Esempio n. 10
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            int facing = MirrorFacingForDraw(Entity.Facing);
            int frameIndex = (int)(Entity.Frame * BodyConverter.DeathAnimationFrameCount(Entity.Body));

            IAnimationFrame animationFrame = getFrame(Entity.Body, facing, frameIndex, Entity.Hue);

            DrawFlip = (MirrorFacingForDraw(Entity.Facing) > 4) ? true : false;

            DrawTexture = animationFrame.Texture;

            DrawArea = new Rectangle(
                animationFrame.Center.X - IsometricRenderer.TILE_SIZE_INTEGER_HALF,
                DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER_HALF + (Entity.Z * 4) + animationFrame.Center.Y, DrawTexture.Width, DrawTexture.Height);

            return base.Draw(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag);
        }
Esempio n. 11
0
 public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
 {
     int displayItemdID = (m_Animated) ? Effect.ItemID + ((Effect.FramesActive / m_AnimData.FrameInterval) % m_AnimData.FrameCount) : Effect.ItemID;
     if (displayItemdID != m_DisplayItemID)
     {
         m_DisplayItemID = displayItemdID;
         DrawTexture = Provider.GetItemTexture(m_DisplayItemID);
         DrawArea = new Rectangle(DrawTexture.Width / 2 - IsometricRenderer.TILE_SIZE_INTEGER_HALF, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER, DrawTexture.Width, DrawTexture.Height);
         PickType = PickType.PickNothing;
         DrawFlip = false;
     }
     DrawArea.X = 0 - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
     DrawArea.Y = 0 + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
     Rotation = Effect.AngleToTarget;
     HueVector = Utility.GetHueVector(Entity.Hue);
     return base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
 }
Esempio n. 12
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            if (Body == 0)
                return false;

            if (roofHideFlag)
            {
                int x = (Entity is Mobile) ? (Entity as Mobile).DestinationPosition.X : Entity.X;
                int y = (Entity is Mobile) ? (Entity as Mobile).DestinationPosition.Y : Entity.Y;
                if (CheckUnderSurface(map, x, y))
                    return false;
            }

            CheckDefer(map, drawPosition);

            return DrawInternal(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag);
        }
Esempio n. 13
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            int displayItemdID = (m_Animated) ? Effect.ItemID + ((Effect.FramesActive / m_AnimData.FrameInterval) % m_AnimData.FrameCount) : Effect.ItemID;

            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                DrawTexture = Provider.GetItemTexture(m_DisplayItemID);
                DrawArea = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
        }
Esempio n. 14
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
 {
     if (m_BaseView.Entity is Mobile)
     {
         Mobile mobile = m_BaseView.Entity as Mobile;
         if (!mobile.IsAlive || mobile.IsDisposed || mobile.Body == 0)
         {
             Entity.Dispose();
             return false;
         }
     }
     /*m_BaseView.SetYClipLine(m_DrawPosition.Y - 22 -
         ((m_BaseView.Entity.Position.Z + m_BaseView.Entity.Position.Z_offset) * 4) +
         ((m_BaseView.Entity.Position.X_offset + m_BaseView.Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF));*/
     bool success = m_BaseView.DrawInternal(spriteBatch, m_DrawPosition, mouseOver, map, roofHideFlag);
     /*m_BaseView.ClearYClipLine();*/
     return success;
 }
Esempio n. 15
0
 void OnClick()
 {
     Directory.CreateDirectory("Chunks");
     IsometricLighting lighting = new IsometricLighting();
     MouseOverList mouseOverNull = new MouseOverList(new MousePicking());
     SpriteBatch3D spritebatch = Service.Get<SpriteBatch3D>();
     RenderTarget2D render = new RenderTarget2D(spritebatch.GraphicsDevice, Width + WidthExtra * 2, Height + HeightExtra * 2 + HeightExtra2);
     Map map = new Map(0);
     for (int chunky = 0; chunky < 10; chunky++)
     {
         for (int chunkx = 0; chunkx < 10; chunkx++)
         {
             spritebatch.GraphicsDevice.SetRenderTarget(render);
             spritebatch.Reset();
             uint cx = (uint)chunkx + 200;
             uint cy = (uint)chunky + 200;
             map.CenterPosition = new Point((int)(cx << 3), (int)(cy << 3));
             MapChunk chunk = map.GetMapChunk(cx, cy);
             chunk.LoadStatics(map.MapData, map);
             int z = 0;
             for (int i = 0; i < 64; i++)
             {
                 int y = (i / 8);
                 int x = (i % 8);
                 int sy = y * 22 + x * 22 + HeightExtra + HeightExtra2;
                 int sx = 22 * 8 - y * 22 + x * 22 + WidthExtra;
                 MapTile tile = chunk.Tiles[i];
                 tile.ForceSort();
                 for (int j = 0; j < tile.Entities.Count; j++)
                 {
                     AEntity e = tile.Entities[j];
                     AEntityView view = e.GetView();
                     view.Draw(spritebatch, new Vector3(sx, sy, 0), mouseOverNull, map, false);
                 }
             }
             spritebatch.SetLightIntensity(lighting.IsometricLightLevel);
             spritebatch.SetLightDirection(lighting.IsometricLightDirection);
             spritebatch.GraphicsDevice.Clear(Color.Transparent);
             spritebatch.FlushSprites(true);
             spritebatch.GraphicsDevice.SetRenderTarget(null);
             render.SaveAsPng(new FileStream($"Chunks/{cy}-{cx}.png", FileMode.Create), render.Width, render.Height);
         }
     }
 }
Esempio n. 16
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            int displayItemdID = 0x4e20 + Effect.FramesActive;
            if (displayItemdID > 0x4e29)
            {
                return false;
            }
            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                DrawTexture = Provider.GetUITexture(displayItemdID);
                Point offset = s_Offsets[m_DisplayItemID - 20000];
                DrawArea = new Rectangle(offset.X, DrawTexture.Height - 33 + (Entity.Z * 4) + offset.Y, DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
        }
Esempio n. 17
0
        private bool Draw3DStretched(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            // this is an isometric stretched tile and needs a specialized draw routine.
            m_vertexBufferAlternate[0].Position = drawPosition + m_vertex0_yOffset;
            m_vertexBufferAlternate[1].Position = drawPosition + m_vertex1_yOffset;
            m_vertexBufferAlternate[2].Position = drawPosition + m_vertex2_yOffset;
            m_vertexBufferAlternate[3].Position = drawPosition + m_vertex3_yOffset;

            if (!spriteBatch.DrawSprite(DrawTexture, m_vertexBufferAlternate, s_Technique))
                return false;

            if ((mouseOverList.PickType & PickType) == PickType)
            {
                if (mouseOverList.IsMouseInObjectIsometric(m_vertexBufferAlternate))
                {
                    MouseOverItem item = new MouseOverItem(DrawTexture, m_vertexBufferAlternate[0].Position, Entity);
                    item.Vertices = new Vector3[4] { m_vertexBufferAlternate[0].Position, m_vertexBufferAlternate[1].Position, m_vertexBufferAlternate[2].Position, m_vertexBufferAlternate[3].Position };
                    mouseOverList.Add2DItem(item);
                }
            }

            return true;
        }
Esempio n. 18
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (Entity.NoDraw)
                return false;

            // Update Display texture, if necessary.
            if (Entity.DisplayItemID != m_DisplayItemID)
            {
                m_DisplayItemID = Entity.DisplayItemID;
                IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>();
                DrawTexture = provider.GetItemTexture(m_DisplayItemID);

                if(DrawTexture == null)
                {
                    return false;
                }

                DrawArea = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickObjects;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue, Entity.ItemData.IsPartialHue, false);

            if (Entity.Amount > 1 && Entity.ItemData.IsGeneric && Entity.DisplayItemID == Entity.ItemID)
            {
                int offset = Entity.ItemData.Unknown4;
                Vector3 offsetDrawPosition = new Vector3(drawPosition.X - 5, drawPosition.Y - 5, 0);
                base.Draw(spriteBatch, offsetDrawPosition, mouseOverList, map);
            }
            bool drawn = base.Draw(spriteBatch, drawPosition, mouseOverList, map);

            DrawOverheads(spriteBatch, drawPosition, mouseOverList, map, (int)DrawArea.Y - 22);

            return drawn;
        }
Esempio n. 19
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (Entity.NoDraw)
                return false;

            // Update Display texture, if necessary.
            if (Entity.DisplayItemID != m_DisplayItemID)
            {
                m_DisplayItemID = Entity.DisplayItemID;
                DrawTexture = IO.ArtData.GetStaticTexture(m_DisplayItemID);

                if(DrawTexture == null)
                {
                    return false;
                }

                DrawArea = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - World.WorldViews.IsometricRenderer.TileSizeI + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickObjects;
                DrawFlip = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue, Entity.ItemData.IsPartialHue, false);

            if (Entity.Amount > 1 && Entity.ItemData.IsGeneric)
            {
                int offset = Entity.ItemData.Unknown4;
                Vector3 offsetDrawPosition = new Vector3(drawPosition.X - 5, drawPosition.Y - 5, 0);
                base.Draw(spriteBatch, offsetDrawPosition, mouseOverList, map);
            }
            bool drawn = base.Draw(spriteBatch, drawPosition, mouseOverList, map);

            DrawOverheads(spriteBatch, drawPosition, mouseOverList, map, (int)DrawArea.Y - 22);

            return drawn;
        }
Esempio n. 20
0
        public virtual bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            VertexPositionNormalTextureHue[] vertexBuffer;

            if (Rotation != 0)
            {
                float w = DrawArea.Width / 2f;
                float h = DrawArea.Height / 2f;
                Vector3 center = drawPosition - new Vector3(DrawArea.X - IsometricRenderer.TILE_SIZE_INTEGER + w, DrawArea.Y + h, 0);
                float sinx = (float)Math.Sin(Rotation) * w;
                float cosx = (float)Math.Cos(Rotation) * w;
                float siny = (float)Math.Sin(Rotation) * -h;
                float cosy = (float)Math.Cos(Rotation) * -h;
                // 2   0    
                // |\  |     
                // |  \|     
                // 3   1
                vertexBuffer = VertexPositionNormalTextureHue.PolyBufferFlipped;

                vertexBuffer[0].Position = center;
                vertexBuffer[0].Position.X += cosx - -siny;
                vertexBuffer[0].Position.Y -= sinx + -cosy;

                vertexBuffer[1].Position = center;
                vertexBuffer[1].Position.X += cosx - siny;
                vertexBuffer[1].Position.Y += -sinx + -cosy;

                vertexBuffer[2].Position = center;
                vertexBuffer[2].Position.X += -cosx - -siny;
                vertexBuffer[2].Position.Y += sinx + cosy;

                vertexBuffer[3].Position = center;
                vertexBuffer[3].Position.X += -cosx - siny;
                vertexBuffer[3].Position.Y += sinx + -cosy;
            }
            else
            {
                if (DrawFlip)
                {
                    // 2   0    
                    // |\  |     
                    // |  \|     
                    // 3   1
                    vertexBuffer = VertexPositionNormalTextureHue.PolyBufferFlipped;
                    vertexBuffer[0].Position = drawPosition;
                    vertexBuffer[0].Position.X += DrawArea.X + IsometricRenderer.TILE_SIZE_FLOAT;
                    vertexBuffer[0].Position.Y -= DrawArea.Y;
                    vertexBuffer[0].TextureCoordinate.Y = 0;

                    vertexBuffer[1].Position = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.Y += DrawArea.Height;

                    vertexBuffer[2].Position = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.X -= DrawArea.Width;
                    vertexBuffer[2].TextureCoordinate.Y = 0;

                    vertexBuffer[3].Position = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.X -= DrawArea.Width;

                    /*if (m_YClipLine != 0)
                    {
                        if (m_YClipLine > vertexBuffer[3].Position.Y)
                            return false;
                        else if (m_YClipLine > vertexBuffer[0].Position.Y)
                        {
                            float uvStart = (m_YClipLine - vertexBuffer[0].Position.Y) / DrawTexture.Height;
                            vertexBuffer[0].Position.Y = vertexBuffer[2].Position.Y = m_YClipLine;
                            vertexBuffer[0].TextureCoordinate.Y = vertexBuffer[2].TextureCoordinate.Y = uvStart;
                        }
                    }*/
                }
                else
                {
                    // 0---1    
                    //    /     
                    //  /       
                    // 2---3
                    vertexBuffer = VertexPositionNormalTextureHue.PolyBuffer;
                    vertexBuffer[0].Position = drawPosition;
                    vertexBuffer[0].Position.X -= DrawArea.X;
                    vertexBuffer[0].Position.Y -= DrawArea.Y;
                    vertexBuffer[0].TextureCoordinate.Y = 0;

                    vertexBuffer[1].Position = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.X += DrawArea.Width;
                    vertexBuffer[1].TextureCoordinate.Y = 0;

                    vertexBuffer[2].Position = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.Y += DrawArea.Height;

                    vertexBuffer[3].Position = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.Y += DrawArea.Height;

                    /*if (m_YClipLine != 0)
                    {
                        if (m_YClipLine >= vertexBuffer[3].Position.Y)
                            return false;
                        else if (m_YClipLine > vertexBuffer[0].Position.Y)
                        {
                            float uvStart = (m_YClipLine - vertexBuffer[0].Position.Y) / DrawTexture.Height;
                            vertexBuffer[0].Position.Y = vertexBuffer[1].Position.Y = m_YClipLine;
                            vertexBuffer[0].TextureCoordinate.Y = vertexBuffer[1].TextureCoordinate.Y = uvStart;
                        }
                    }*/
                }
            }

            if (vertexBuffer[0].Hue != HueVector)
                vertexBuffer[0].Hue = vertexBuffer[1].Hue = vertexBuffer[2].Hue = vertexBuffer[3].Hue = HueVector;

            if (!spriteBatch.DrawSprite(DrawTexture, vertexBuffer, s_Technique))
            {
                // the vertex buffer was not on screen, return false (did not draw)
                return false;
            }

            Pick(mouseOverList, vertexBuffer);

            if (IsShadowCastingView)
            {
                spriteBatch.DrawShadow(DrawTexture, vertexBuffer, new Vector2(
                    drawPosition.X + IsometricRenderer.TILE_SIZE_FLOAT_HALF,
                    drawPosition.Y + (Entity.Position.Offset.X + Entity.Position.Offset.Y) * IsometricRenderer.TILE_SIZE_FLOAT_HALF - ((Entity.Position.Z_offset + Entity.Z) * 4) + IsometricRenderer.TILE_SIZE_FLOAT_HALF),
                    DrawFlip, DrawShadowZDepth);
            }

            return true;
        }
Esempio n. 21
0
 /// <summary>
 /// Draws all overheads, starting at [yOffset] pixels above the Entity's anchor point on the ground.
 /// </summary>
 /// <param name="yOffset"></param>
 public void DrawOverheads(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, int yOffset)
 {
     for (int i = 0; i < Entity.Overheads.Count; i++)
     {
         AEntityView view = Entity.Overheads[i].GetView();
         view.DrawArea = new Rectangle((view.DrawTexture.Width / 2) - 22, yOffset + view.DrawTexture.Height, view.DrawTexture.Width, view.DrawTexture.Height);
         OverheadsView.AddView(view, drawPosition);
         yOffset += view.DrawTexture.Height;
     }
 }
Esempio n. 22
0
        // TODO: add clothes
        private bool DrawCorpse(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            Item item = (Item)GameObject;

            byte dir    = (byte)((byte)item.Layer & 0x7F & 7);
            bool mirror = false;

            Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped            = mirror;
            Animations.Direction = dir;
            byte animIndex = (byte)GameObject.AnimIndex;


            for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = LayerOrder.UsedLayers[dir, i];

                if (layer == Layer.Mount)
                {
                    continue;
                }
                Graphic graphic;
                Hue     color;

                if (layer == Layer.Invalid)
                {
                    graphic = item.GetGraphicForAnimation();
                    //graphic = item.DisplayedGraphic;
                    Animations.AnimGroup = Animations.GetDieGroupIndex(item.GetGraphicForAnimation(), item.UsedLayer);
                    color = GameObject.Hue;
                }
                else
                {
                    Item itemEquip = item.Equipment[(int)layer];

                    if (itemEquip == null)
                    {
                        continue;
                    }
                    graphic = itemEquip.ItemData.AnimID;

                    if (Animations.EquipConversions.TryGetValue(itemEquip.Graphic, out Dictionary <ushort, EquipConvData> map))
                    {
                        if (map.TryGetValue(itemEquip.ItemData.AnimID, out EquipConvData data))
                        {
                            graphic = data.Graphic;
                        }
                    }

                    color = itemEquip.Hue;
                }

                Animations.AnimID = graphic;
                ref AnimationDirection direction = ref Animations.DataIndex[Animations.AnimID].Groups[Animations.AnimGroup].Direction[Animations.Direction];

                if ((direction.FrameCount == 0 || direction.FramesHashes == null) && !Animations.LoadDirectionGroup(ref direction))
                {
                    return(false);
                }
                direction.LastAccessTime = Engine.Ticks;
                int fc = direction.FrameCount;
                if (fc > 0 && animIndex >= fc)
                {
                    animIndex = (byte)(fc - 1);
                }

                if (animIndex < direction.FrameCount)
                {
                    AnimationFrameTexture frame = Animations.GetTexture(direction.FramesHashes[animIndex]);

                    if (frame == null || frame.IsDisposed)
                    {
                        return(false);
                    }

                    int       drawCenterY = frame.CenterY;
                    const int drawX       = -22;
                    int       drawY       = drawCenterY - 22 - 3;
                    int       x           = drawX + frame.CenterX;
                    int       y           = -drawY - (frame.Height + frame.CenterY) + drawCenterY;
                    Texture   = frame;
                    Bounds    = new Rectangle(x, -y, frame.Width, frame.Height);
                    HueVector = ShaderHuesTraslator.GetHueVector(color);
                    base.Draw(batcher, position, objectList);
                    Pick(frame, Bounds, position, objectList);
                }

                break;
            }
Esempio n. 23
0
        private unsafe bool Draw3DStretched(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            Texture.Ticks = CoreGame.Ticks;

            fixed(SpriteVertex *ptr = _vertex)
            {
                ptr[0].Position = position + _vertex0_yOffset;
                ptr[1].Position = position + _vertex1_yOffset;
                ptr[2].Position = position + _vertex2_yOffset;
                ptr[3].Position = position + _vertex3_yOffset;
            }

            int z = GameObject.Position.Z * 4;

            for (int i = 0; i < 4; i++)
            {
                _vertex[i].Position.Y += z;
            }

            if (IsSelected)
            {
                if (_storedHue == Vector3.Zero)
                {
                    _storedHue = HueVector;
                }
                HueVector = ShaderHuesTraslator.SelectedHue;
            }
            else if (_storedHue != Vector3.Zero)
            {
                HueVector  = _storedHue;
                _storedHue = Vector3.Zero;
            }

            if (HueVector != _vertex[0].Hue)
            {
                _vertex[0].Hue = _vertex[1].Hue = _vertex[2].Hue = _vertex[3].Hue = HueVector;
            }

            if (!spriteBatch.DrawSprite(Texture, _vertex))
            {
                return(false);
            }

            if (objectList.IsMouseInObjectIsometric(_vertex))
            {
                objectList.Add(GameObject, _vertex[0].Position);
            }

            return(true);
        }
Esempio n. 24
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
 {
     CheckDefer(map, drawPosition);
     return(DrawInternal(spriteBatch, drawPosition, mouseOver, map, roofHideFlag));
 }
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            int displayItemdID = (m_Animated) ? Effect.ItemID + ((Effect.FramesActive / m_AnimData.FrameInterval) % m_AnimData.FrameCount) : Effect.ItemID;

            if (displayItemdID != m_DisplayItemID)
            {
                m_DisplayItemID = displayItemdID;
                DrawTexture     = Provider.GetItemTexture(m_DisplayItemID);
                DrawArea        = new Rectangle(DrawTexture.Width / 2 - 22, DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER + (Entity.Z * 4), DrawTexture.Width, DrawTexture.Height);
                PickType        = PickType.PickNothing;
                DrawFlip        = false;
            }

            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);

            return(base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag));
        }
Esempio n. 26
0
        public virtual bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            VertexPositionNormalTextureHue[] vertexBuffer;
            const int tolerance = 0;

            if (Math.Abs(Rotation) > tolerance)
            {
                Vector3 center = drawPosition - new Vector3(DrawArea.X - 44 + DrawArea.Width / 2, DrawArea.Y + DrawArea.Height / 2, 0);
                float   sinx   = (float)Math.Sin(Rotation) * DrawArea.Width / 2f;
                float   cosx   = (float)Math.Cos(Rotation) * DrawArea.Width / 2f;
                float   siny   = (float)Math.Sin(Rotation) * -DrawArea.Height / 2f;
                float   cosy   = (float)Math.Cos(Rotation) * -DrawArea.Height / 2f;
                // 2   0
                // |\  |
                // |  \|
                // 3   1
                vertexBuffer = VertexPositionNormalTextureHue.PolyBufferFlipped;

                vertexBuffer[0].Position    = center;
                vertexBuffer[0].Position.X += cosx - -siny;
                vertexBuffer[0].Position.Y -= sinx + -cosy;

                vertexBuffer[1].Position    = center;
                vertexBuffer[1].Position.X += cosx - siny;
                vertexBuffer[1].Position.Y += -sinx + -cosy;

                vertexBuffer[2].Position    = center;
                vertexBuffer[2].Position.X += -cosx - -siny;
                vertexBuffer[2].Position.Y += sinx + cosy;

                vertexBuffer[3].Position    = center;
                vertexBuffer[3].Position.X += -cosx - siny;
                vertexBuffer[3].Position.Y += sinx + -cosy;
            }
            else
            {
                if (DrawFlip)
                {
                    // 2   0
                    // |\  |
                    // |  \|
                    // 3   1
                    vertexBuffer                = VertexPositionNormalTextureHue.PolyBufferFlipped;
                    vertexBuffer[0].Position    = drawPosition;
                    vertexBuffer[0].Position.X += DrawArea.X + 44;
                    vertexBuffer[0].Position.Y -= DrawArea.Y;

                    vertexBuffer[1].Position    = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.Y += DrawArea.Height;

                    vertexBuffer[2].Position    = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.X -= DrawArea.Width;

                    vertexBuffer[3].Position    = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.X -= DrawArea.Width;
                }
                else
                {
                    // 0---1
                    //    /
                    //  /
                    // 2---3
                    vertexBuffer                = VertexPositionNormalTextureHue.PolyBuffer;
                    vertexBuffer[0].Position    = drawPosition;
                    vertexBuffer[0].Position.X -= DrawArea.X;
                    vertexBuffer[0].Position.Y -= DrawArea.Y;

                    vertexBuffer[1].Position    = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.X += DrawArea.Width;

                    vertexBuffer[2].Position    = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.Y += DrawArea.Height;

                    vertexBuffer[3].Position    = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.Y += DrawArea.Height;
                }
            }

            if (vertexBuffer[0].Hue != HueVector)
            {
                vertexBuffer[0].Hue = vertexBuffer[1].Hue = vertexBuffer[2].Hue = vertexBuffer[3].Hue = HueVector;
            }

            if (!spriteBatch.Draw(DrawTexture, vertexBuffer))
            {
                return(false);
            }

            Pick(mouseOverList, vertexBuffer);

            return(true);
        }
Esempio n. 27
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (!AllowedToDraw || IsDisposed)
            {
                return(false);
            }

            if (Texture == null || Texture.IsDisposed)
            {
                ArtTexture texture = FileManager.Art.GetTexture(Graphic);
                Texture = texture;
                Bounds  = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);

                FrameInfo.Width  = texture.ImageRectangle.Width;
                FrameInfo.Height = texture.ImageRectangle.Height;

                FrameInfo.X = (Texture.Width >> 1) - 22 - texture.ImageRectangle.X;
                FrameInfo.Y = Texture.Height - 44 - texture.ImageRectangle.Y;
            }

            if (_isFoliage)
            {
                if (CharacterIsBehindFoliage)
                {
                    if (AlphaHue != 76)
                    {
                        ProcessAlpha(76);
                    }
                }
                else
                {
                    if (AlphaHue != 0xFF)
                    {
                        ProcessAlpha(0xFF);
                    }
                }
            }

            if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ViewRange)
            {
                HueVector = new Vector3(Constants.OUT_RANGE_COLOR, 1, HueVector.Z);
            }
            else if (World.Player.IsDead && Engine.Profile.Current.EnableBlackWhiteEffect)
            {
                HueVector = new Vector3(Constants.DEAD_RANGE_COLOR, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(Hue);
            }

            //MessageOverHead(batcher, position, Bounds.Y - 44);
            Engine.DebugInfo.MultiRendered++;

            base.Draw(batcher, position, objectList);
            //if (_isFoliage)
            //{
            //    if (_texture == null)
            //    {
            //        _texture = new Texture2D(batcher.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            //        _texture.SetData(new Color[] { Color.Red });
            //    }

            //    batcher.DrawRectangle(_texture, new Rectangle((int)position.X - FrameInfo.X, (int)position.Y - FrameInfo.Y, FrameInfo.Width, FrameInfo.Height), Vector3.Zero);
            //}

            if (ItemData.IsLight)
            {
                Engine.SceneManager.GetScene <GameScene>()
                .AddLight(this, this, (int)position.X + 22, (int)position.Y + 22);
            }

            return(true);
        }
Esempio n. 28
0
 protected virtual void MousePick(MouseOverList list, SpriteVertex[] vertex)
 {
 }
Esempio n. 29
0
 protected override void Pick(MouseOverList mouseOver, VertexPositionNormalTextureHue[] vertexBuffer)
 {
     // TODO: This is called when the tile is not stretched - just drawn as a 44x44 tile.
     // Because this is not written, no flat tiles can ever be picked.
 }
Esempio n. 30
0
        //private static readonly Lazy<BlendState> _checkerBlend = new Lazy<BlendState>(() =>
        //{
        //    BlendState state = new BlendState();

        //    state.AlphaSourceBlend = state.ColorSourceBlend = Microsoft.Xna.Framework.Graphics.Blend.SourceAlpha;
        //    state.AlphaDestinationBlend = state.ColorDestinationBlend = Microsoft.Xna.Framework.Graphics.Blend.InverseSourceAlpha;

        //    return state;
        //});


        public virtual bool Draw(Batcher2D batcher, Vector3 position, MouseOverList list)
        {
            Texture.Ticks = Engine.Ticks;
            SpriteVertex[] vertex;

            if (Rotation != 0.0f)
            {
                float   w      = Bounds.Width / 2f;
                float   h      = Bounds.Height / 2f;
                Vector3 center = position - new Vector3(Bounds.X - 44 + w, Bounds.Y + h, 0);
                float   sinx   = (float)Math.Sin(Rotation) * w;
                float   cosx   = (float)Math.Cos(Rotation) * w;
                float   siny   = (float)Math.Sin(Rotation) * h;
                float   cosy   = (float)Math.Cos(Rotation) * h;

                vertex                = SpriteVertex.PolyBufferFlipped;
                vertex[0].Position    = center;
                vertex[0].Position.X += cosx - -siny;
                vertex[0].Position.Y -= sinx + -cosy;
                vertex[1].Position    = center;
                vertex[1].Position.X += cosx - siny;
                vertex[1].Position.Y += -sinx + -cosy;
                vertex[2].Position    = center;
                vertex[2].Position.X += -cosx - -siny;
                vertex[2].Position.Y += sinx + cosy;
                vertex[3].Position    = center;
                vertex[3].Position.X += -cosx - siny;
                vertex[3].Position.Y += sinx + -cosy;
            }
            else if (IsFlipped)
            {
                vertex                        = SpriteVertex.PolyBufferFlipped;
                vertex[0].Position            = position;
                vertex[0].Position.X         += Bounds.X + 44f;
                vertex[0].Position.Y         -= Bounds.Y;
                vertex[0].TextureCoordinate.Y = 0;
                vertex[1].Position            = vertex[0].Position;
                vertex[1].Position.Y         += Bounds.Height;
                vertex[2].Position            = vertex[0].Position;
                vertex[2].Position.X         -= Bounds.Width;
                vertex[2].TextureCoordinate.Y = 0;
                vertex[3].Position            = vertex[1].Position;
                vertex[3].Position.X         -= Bounds.Width;
            }
            else
            {
                vertex                        = SpriteVertex.PolyBuffer;
                vertex[0].Position            = position;
                vertex[0].Position.X         -= Bounds.X;
                vertex[0].Position.Y         -= Bounds.Y;
                vertex[0].TextureCoordinate.Y = 0;
                vertex[1].Position            = vertex[0].Position;
                vertex[1].Position.X         += Bounds.Width;
                vertex[1].TextureCoordinate.Y = 0;
                vertex[2].Position            = vertex[0].Position;
                vertex[2].Position.Y         += Bounds.Height;
                vertex[3].Position            = vertex[1].Position;
                vertex[3].Position.Y         += Bounds.Height;
            }

            if (DrawTransparent)
            {
                int dist    = Distance;
                int maxDist = Engine.Profile.Current.CircleOfTransparencyRadius + 1;

                if (dist <= maxDist)
                {
                    HueVector.Z = 1f - (dist / (float)maxDist);
                }
                else
                {
                    HueVector.Z = 1f - AlphaHue / 255f;
                }
            }
            else
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            if (Engine.Profile.Current.HighlightGameObjects)
            {
                if (IsSelected)
                {
                    if (_storedHue == Vector3.Zero)
                    {
                        _storedHue = HueVector;
                    }
                    HueVector = ShaderHuesTraslator.SelectedHue;
                }
                else if (_storedHue != Vector3.Zero)
                {
                    HueVector  = _storedHue;
                    _storedHue = Vector3.Zero;
                }
            }

            if (vertex[0].Hue != HueVector)
            {
                vertex[0].Hue = vertex[1].Hue = vertex[2].Hue = vertex[3].Hue = HueVector;
            }

            //if (HasShadow)
            //{
            //    SpriteVertex[] vertexS = new SpriteVertex[4]
            //    {
            //        vertex[0],
            //        vertex[1],
            //        vertex[2],
            //        vertex[3]
            //    };

            //    batcher.DrawShadow(Texture, vertexS, new Vector2(position.X + 22, position.Y + GameObject.Offset.Y - GameObject.Offset.Z + 22), IsFlipped, ShadowZDepth);
            //}

            //if (DrawTransparent)
            //{
            //    batcher.SetBlendState(_checkerBlend.Value);
            //    batcher.DrawSprite(Texture, vertex);
            //    batcher.SetBlendState(null, true);

            //    batcher.SetStencil(_stencil.Value);
            //    batcher.DrawSprite(Texture, vertex);
            //    batcher.SetStencil(null);
            //}
            //else
            //{
            //    batcher.DrawSprite(Texture, vertex);
            //}

            //if (DrawTransparent)
            //{
            //    vertex[0].Hue.Z = vertex[1].Hue.Z = vertex[2].Hue.Z = vertex[3].Hue.Z = 0.5f;

            //    batcher.SetStencil(_stencil.Value);
            //    batcher.DrawSprite(Texture, vertex);
            //    batcher.SetStencil(null);
            //}
            if (!batcher.DrawSprite(Texture, vertex))
            {
                return(false);
            }


            MousePick(list, vertex);

            return(true);
        }
Esempio n. 31
0
 protected override void MousePick(MouseOverList list, SpriteVertex[] vertex)
 {
 }
Esempio n. 32
0
 public static void Draw(SpriteBatch3D spriteBatch, MouseOverList objectList)
 {
     DrawOverheads(spriteBatch, objectList);
     DrawDamages(spriteBatch, objectList);
 }
Esempio n. 33
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            MovingEffect effect = (MovingEffect)GameObject;

            position.X += effect.Offset.X;
            position.Y += effect.Offset.Y + effect.Offset.Z;



            if (effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = Art.GetStaticTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle(0, 0, Texture.Width, Texture.Height);
                //Bounds = new Rectangle(Texture.Width / 2 - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            //Bounds.X = (int)-effect.Offset.X;
            //Bounds.Y = (int)(effect.Offset.Z - effect.Offset.Y);

            //Bounds.X = -(int) ((effect.Offset.X - effect.Offset.Y) * 22);
            //Bounds.Y = (int) ((effect.Offset.Z * 4 /*- effect.Position.Z * 4*/ ) ) - (int) ((effect.Offset.X + effect.Offset.Y) * 22);
            Rotation  = effect.AngleToTarget;
            HueVector = RenderExtentions.GetHueVector(GameObject.Hue);

            return(base.Draw(spriteBatch, position, objectList));
        }
Esempio n. 34
0
        private void DrawTextOverheads(Batcher2D batcher, MouseOverList list)
        {
            if (_firstNode != null)
            {
                int skip = 0;

                for (TextOverhead overhead = _firstNode; overhead != null; overhead = (TextOverhead)overhead.Right)
                {
                    GameObject owner = overhead.Parent;

                    if (owner == null || overhead.IsDisposed || owner.IsDisposed)
                    {
                        continue;
                    }

                    Vector3 position = owner.RealScreenPosition;

                    if (owner is Mobile m)
                    {
                        GetAnimationDimensions(m, 0xFF, out int height, out int centerY);

                        position = new Vector3
                        {
                            X = position.X + m.Offset.X,
                            Y = position.Y + (m.Offset.Y - m.Offset.Z) - (height + centerY + 8),
                            Z = position.Z
                        };
                    }
                    else if (owner.Texture != null)
                    {
                        position.Y -= (owner.Texture.Height >> 1);
                    }


                    Rectangle current = new Rectangle((int)position.X - overhead.Bounds.X, (int)position.Y - overhead.Bounds.Y, overhead.Bounds.Width, overhead.Bounds.Height);

                    if (skip == 0)
                    {
                        for (TextOverhead ov = (TextOverhead)overhead.Right; ov != null; ov = (TextOverhead)ov.Right)
                        {
                            Vector3 pos2 = ov.Parent.RealScreenPosition;

                            if (ov.Parent is Mobile mm)
                            {
                                GetAnimationDimensions(mm, 0xFF, out int height, out int centerY);

                                pos2 = new Vector3
                                {
                                    X = pos2.X + mm.Offset.X,
                                    Y = pos2.Y + (mm.Offset.Y - mm.Offset.Z) - (height + centerY + 8),
                                    Z = pos2.Z
                                };
                            }

                            Rectangle next = new Rectangle((int)pos2.X - ov.Bounds.X, (int)pos2.Y - ov.Bounds.Y, ov.Bounds.Width, ov.Bounds.Height);

                            overhead.IsOverlapped = current.Intersects(next);

                            if (overhead.IsOverlapped)
                            {
                                bool startSkip = false;
                                foreach (TextOverhead parentOverhead in owner.Overheads)
                                {
                                    parentOverhead.IsOverlapped = true;

                                    if (parentOverhead == overhead)
                                    {
                                        startSkip = true;
                                    }
                                    else if (startSkip)
                                    {
                                        skip++;
                                    }
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        skip--;
                    }

                    overhead.Draw(batcher, position, list);
                }


                GameObject last = _firstNode;

                while (last != null)
                {
                    GameObject temp = last.Right;

                    last.Left  = null;
                    last.Right = null;

                    last = temp;
                }

                _firstNode.Left = _firstNode.Right = null;
                _firstNode      = null;
            }
        }
Esempio n. 35
0
        //private static Texture2D _edge;


        private void Pick(SpriteTexture texture, Rectangle area, Vector3 drawPosition, MouseOverList list)
        {
            int x;

            if (IsFlipped)
            {
                x = (int)drawPosition.X + area.X + 44 - list.MousePosition.X;
            }
            else
            {
                x = list.MousePosition.X - (int)drawPosition.X + area.X;
            }
            int y = list.MousePosition.Y - ((int)drawPosition.Y - area.Y);

            if (texture.Contains(x, y))
            {
                list.Add(this, drawPosition);
            }
        }
Esempio n. 36
0
        private bool Draw3DStretched(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            // this is an isometric stretched tile and needs a specialized draw routine.
            m_vertexBufferAlternate[0].Position = drawPosition + m_vertex0_yOffset;
            m_vertexBufferAlternate[1].Position = drawPosition + m_vertex1_yOffset;
            m_vertexBufferAlternate[2].Position = drawPosition + m_vertex2_yOffset;
            m_vertexBufferAlternate[3].Position = drawPosition + m_vertex3_yOffset;

            if (!spriteBatch.DrawSprite(DrawTexture, m_vertexBufferAlternate, s_Technique))
            {
                return(false);
            }

            if ((mouseOverList.PickType & PickType) == PickType)
            {
                if (mouseOverList.IsMouseInObjectIsometric(m_vertexBufferAlternate))
                {
                    MouseOverItem item = new MouseOverItem(DrawTexture, m_vertexBufferAlternate[0].Position, Entity);
                    item.Vertices = new Vector3[4] {
                        m_vertexBufferAlternate[0].Position, m_vertexBufferAlternate[1].Position, m_vertexBufferAlternate[2].Position, m_vertexBufferAlternate[3].Position
                    };
                    mouseOverList.Add2DItem(item);
                }
            }

            return(true);
        }
Esempio n. 37
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            var displayItemdID = 0x4e20 + Effect.FramesActive;

            if (displayItemdID > 0x4e29)
            {
                return(false);
            }
            if (displayItemdID != _displayItemID)
            {
                _displayItemID = displayItemdID;
                DrawTexture    = Provider.GetUITexture(displayItemdID);
                var offset = _offsets[_displayItemID - 20000];
                DrawArea = new RectInt(offset.x, DrawTexture.Height - 33 + (Entity.Z * 4) + offset.y, DrawTexture.Width, DrawTexture.Height);
                PickType = PickType.PickNothing;
                DrawFlip = false;
            }
            // Update hue vector.
            HueVector = Utility.GetHueVector(Entity.Hue);
            return(base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag));
        }
Esempio n. 38
0
        // ============================================================================================================
        // draw
        // ============================================================================================================

        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            if (Entity.IsDisposed)
            {
                return(false);
            }
            // get a z index underneath all this mobile's sprite layers. We will place the shadow on this z index.
            DrawShadowZDepth = spriteBatch.GetNextUniqueZ();
            // get running moving and sitting booleans, which are used when drawing mobiles but not corpses.
            bool isRunning = false, isMoving = false, isSitting = false;

            if (Entity is Mobile)
            {
                isRunning = (Entity as Mobile).IsRunning;
                isMoving  = (Entity as Mobile).IsMoving;
                isSitting = (Entity as Mobile).IsSitting;
            }
            // flip the facing (anim directions are reversed from the client-server protocol's directions).
            DrawFlip = (MirrorFacingForDraw(Facing) > 4);
            InternalSetupLayers();
            if (m_MobileLayers[0].Frame == null)
            {
                m_MobileLayers[0].Frame = AnimationFrame.NullFrame;
            }
            int drawCenterY = m_MobileLayers[0].Frame.Center.Y;
            int drawX;
            int drawY;

            if (DrawFlip)
            {
                drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
                drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
            }
            else
            {
                drawX = -IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
                drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
            }
            if (isSitting)
            {
                drawX -= 1;
                drawY -= 6 + (Entity as Mobile).ChairData.SittingPixelOffset;
                if (Facing == Direction.North || Facing == Direction.West)
                {
                    drawY -= 16;
                }
            }
            IsShadowCastingView = !isSitting;
            int yOffset = 0;

            for (int i = 0; i < m_LayerCount; i++)
            {
                if (m_MobileLayers[i].Frame != null)
                {
                    AAnimationFrame frame = m_MobileLayers[i].Frame;
                    int             x     = (drawX + frame.Center.X);
                    int             y     = -drawY - (frame.Texture.Height + frame.Center.Y) + drawCenterY;
                    if (yOffset > y)
                    {
                        yOffset = y;
                    }
                    DrawTexture = frame.Texture;
                    DrawArea    = new Rectangle(x, -y, DrawTexture.Width, DrawTexture.Height);
                    HueVector   = Utility.GetHueVector(m_MobileLayers[i].Hue);
                    base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
                    MobilePick(mouseOver, drawPosition, DrawArea, frame);
                }
            }

            Vector3 overheadDrawPosition = new Vector3(drawPosition.X + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF),
                                                       drawPosition.Y - (int)((Entity.Position.Z_offset + Entity.Z) * 4),
                                                       drawPosition.Z);

            if (m_MobileLayers[0].Frame != null)
            {
                yOffset = m_MobileLayers[0].Frame.Texture.Height + drawY - (int)((Entity.Z + Entity.Position.Z_offset) * 4);
            }
            else
            {
                yOffset = -(yOffset + IsometricRenderer.TILE_SIZE_INTEGER);
            }

            // this is where we would draw the reverse of the chair texture.

            bool isMounted = (Entity is Mobile) && (Entity as Mobile).IsMounted;

            DrawOverheads(spriteBatch, overheadDrawPosition, mouseOver, map, isMounted ? yOffset + 16 : yOffset);

            return(true);
        }
Esempio n. 39
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            if (AnimationGraphic == Graphic.INVALID)
            {
                return(false);
            }

            Hue hue = Hue;

            if (Source is Item i)
            {
                if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(AnimationGraphic))
                {
                    AnimIndex = 0;
                }
                else if (Engine.Profile.Current.FieldsType == 2)
                {
                    if (StaticFilters.IsFireField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0020;
                    }
                    else if (StaticFilters.IsParalyzeField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0058;
                    }
                    else if (StaticFilters.IsEnergyField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0070;
                    }
                    else if (StaticFilters.IsPoisonField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0044;
                    }
                    else if (StaticFilters.IsWallOfStone(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x038A;
                    }
                }
                else if (i.IsHidden)
                {
                    hue = 0x038E;
                }
            }

            if ((AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && AnimationGraphic != Graphic.INVALID)
            {
                _displayedGraphic = AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(AnimationGraphic);
                Bounds            = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X = (Texture.Width >> 1) - 22 - (int)Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(Offset.Z - Offset.Y);

            StaticTiles data = FileManager.TileData.StaticData[_displayedGraphic];

            bool isPartial     = data.IsPartialHue;
            bool isTransparent = data.IsTranslucent;

            if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ViewRange)
            {
                HueVector = new Vector3(0x038E, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(hue, isPartial, isTransparent ? .5f : 0, false);
            }

            switch (Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                batcher.SetBlendState(_multiplyBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                batcher.SetBlendState(_screenBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                batcher.SetBlendState(_screenLessBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                batcher.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                batcher.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            default:
                base.Draw(batcher, position, objectList);
                break;
            }

            Engine.DebugInfo.EffectsRendered++;

            return(true);
        }
Esempio n. 40
0
 internal override bool Draw(SpriteBatch3D sb, Vector3 drawPosition, MouseOverList molist, PickTypes pickType, int maxAlt)
 {
     return base.Draw(sb, drawPosition, molist, pickType, maxAlt);
 }
Esempio n. 41
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            AnimatedItemEffect effect = (AnimatedItemEffect)GameObject;

            if (effect.AnimationGraphic == Graphic.Invalid)
            {
                return(false);
            }

            if ((effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && effect.AnimationGraphic != Graphic.Invalid)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = Art.GetStaticTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X = (Texture.Width >> 1) - 22 - (int)effect.Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(effect.Offset.Z - effect.Offset.Y);

            ulong flags = TileData.StaticData[_displayedGraphic].Flags;


            bool isPartial     = TileData.IsPartialHue(flags);
            bool isTransparent = TileData.IsTransparent(flags);

            HueVector = ShaderHuesTraslator.GetHueVector(effect.Hue, isPartial, isTransparent ? .5f : 0, false);

            switch (effect.Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                batcher.SetBlendState(_multiplyBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                batcher.SetBlendState(_screenBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                batcher.SetBlendState(_screenLessBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                batcher.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                batcher.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            default:
                base.Draw(batcher, position, objectList);
                break;
            }


            return(true);
        }
Esempio n. 42
0
        private void render(out Vector2 renderOffset)
        {
            // Prerender objects
            _spriteBatch.Prepare(false, false);
            MapObjectPrerendered.RenderObjects(_spriteBatch);

            // ClientVars.EngineVars.RenderSize = 20;

            int RenderBeginX = CenterPosition.X - (ClientVars.EngineVars.RenderSize / 2);
            int RenderBeginY = CenterPosition.Y - (ClientVars.EngineVars.RenderSize / 2);
            int RenderEndX = RenderBeginX + ClientVars.EngineVars.RenderSize;
            int RenderEndY = RenderBeginY + ClientVars.EngineVars.RenderSize;

            renderOffset.X = (ClientVars.EngineVars.BackBufferWidth >> 1) - 22;
            renderOffset.X -= (int)((CenterPosition.X_offset - CenterPosition.Y_offset) * 22);
            renderOffset.X -= (RenderBeginX - RenderBeginY) * 22;

            renderOffset.Y = ((ClientVars.EngineVars.BackBufferHeight - (ClientVars.EngineVars.RenderSize * 44)) >> 1);
            renderOffset.Y += (CenterPosition.Z * 4) + (int)(CenterPosition.Z_offset * 4);
            renderOffset.Y -= (int)((CenterPosition.X_offset + CenterPosition.Y_offset) * 22);
            renderOffset.Y -= (RenderBeginX + RenderBeginY) * 22;

            ObjectsRendered = 0; // Count of objects rendered for statistics and debug
            MouseOverList overList = new MouseOverList(); // List of items for mouse over
            overList.MousePosition = _input.MousePosition;
            List<MapObject> mapObjects;
            Vector3 drawPosition = new Vector3();

            for (int ix = RenderBeginX; ix < RenderEndX; ix++)
            {
                drawPosition.X = (ix - RenderBeginY) * 22 + renderOffset.X;
                drawPosition.Y = (ix + RenderBeginY) * 22 + renderOffset.Y;

                DrawTerrain = true;

                for (int iy = RenderBeginY; iy < RenderEndY; iy++)
                {
                    MapTile tile = Map.GetMapTile(ix, iy, true);
                    if (tile == null)
                        continue;

                    mapObjects = tile.Items;
                    for (int i = 0; i < mapObjects.Count; i++)
                    {
                        if (mapObjects[i].Draw(_spriteBatch, drawPosition, overList, PickType, _maxItemAltitude))
                            ObjectsRendered++;
                    }
                    tile.ClearTemporaryObjects();

                    drawPosition.X -= 22f;
                    drawPosition.Y += 22f;
                }
            }

            // Update the MouseOver objects
            _overObject = overList.GetForemostMouseOverItem(_input.MousePosition);
            _overGround = overList.GetForemostMouseOverItem<MapObjectGround>(_input.MousePosition);

            // Draw the objects we just send to the spritebatch.
            _spriteBatch.Prepare(true, true);
            _spriteBatch.Flush();
        }
Esempio n. 43
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
 {
     m_BaseView.SetAllowDefer();
     return(m_BaseView.Draw(spriteBatch, m_DrawPosition, mouseOverList, map));
 }
Esempio n. 44
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
 {
     HueVector = Utility.GetHueVector(Entity.Hue, false, false, true);
     return(base.Draw(spriteBatch, drawPosition, mouseOver, map, roofHideFlag));
 }
Esempio n. 45
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            if (!m_AllowDefer)
            {
                if (CheckDefer(map, drawPosition))
                    return false;
            }
            else
            {
                m_AllowDefer = false;
            }

            DrawFlip = (MirrorFacingForDraw(Entity.Facing) > 4) ? true : false;

            if (Entity.IsMoving)
            {
                if (Entity.IsRunning)
                    m_Animation.Animate(MobileAction.Run);
                else
                    m_Animation.Animate(MobileAction.Walk);
            }
            else
            {
                if (!m_Animation.IsAnimating)
                    m_Animation.Animate(MobileAction.Stand);
            }

            InternalSetupLayers();

            int drawCenterX = m_MobileLayers[0].Frame.Center.X;
            int drawCenterY = m_MobileLayers[0].Frame.Center.Y;

            int drawX, drawY;
            if (DrawFlip)
            {
                drawX = drawCenterX - IsometricRenderer.TILE_SIZE_INTEGER_HALF + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
                drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
            }
            else
            {
                drawX = drawCenterX - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
                drawY = drawCenterY + (int)((Entity.Position.Z_offset + Entity.Z) * 4) - IsometricRenderer.TILE_SIZE_INTEGER_HALF - (int)((Entity.Position.X_offset + Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF);
            }

            // get the maximum y-extent of this object so we can correctly place overheads.
            int yOffset = 0;

            for (int i = 0; i < m_LayerCount; i++)
            {
                if (m_MobileLayers[i].Frame != null)
                {
                    float x = -drawCenterX + (drawX + m_MobileLayers[i].Frame.Center.X);
                    float y = -drawY - (m_MobileLayers[i].Frame.Texture.Height + m_MobileLayers[i].Frame.Center.Y) + drawCenterY;

                    if (yOffset > y)
                        yOffset = (int)y;

                    DrawTexture = m_MobileLayers[i].Frame.Texture;
                    DrawArea = new Rectangle((int)x, (int)-y, DrawTexture.Width, DrawTexture.Height);
                    HueVector = Utility.GetHueVector(m_MobileLayers[i].Hue);

                    Rectangle screenDest = new Rectangle(
                        DrawFlip ? (int)drawPosition.X + DrawArea.X - DrawArea.Width + IsometricRenderer.TILE_SIZE_INTEGER : (int)drawPosition.X - DrawArea.X,
                        (int)drawPosition.Y - DrawArea.Y,
                        DrawFlip ? DrawArea.Width : DrawArea.Width,
                        DrawArea.Height);

                    base.Draw(spriteBatch, drawPosition, mouseOverList, map);
                }
            }

            Vector3 overheadDrawPosition = new Vector3(drawPosition.X + (int)((Entity.Position.X_offset - Entity.Position.Y_offset) * IsometricRenderer.TILE_SIZE_INTEGER_HALF),
                drawPosition.Y - (int)((Entity.Position.Z_offset + Entity.Z) * 4),
                drawPosition.Z);

            if (m_MobileLayers[0].Frame != null)
            {
                yOffset = m_MobileLayers[0].Frame.Texture.Height + drawY - (int)((Entity.Z + Entity.Position.Z_offset) * 4);
            }
            else
            {
                yOffset = -(yOffset + IsometricRenderer.TILE_SIZE_INTEGER);
            }

            DrawOverheads(spriteBatch, overheadDrawPosition, mouseOverList, map, (int)yOffset);

            return true;
        }
Esempio n. 46
0
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
 {
     m_BaseView.SetAllowDefer();
     return m_BaseView.Draw(spriteBatch, m_DrawPosition, mouseOverList, map);
 }
Esempio n. 47
0
 /// <summary>
 /// Used by DeferredView to draw an object without first determining if it should be deferred.
 /// Should only be implemented for those views that call CheckDefer(), Otherwise, using only
 /// Draw() will suffice. See MobileView for an example of use.
 /// </summary>
 public virtual bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
 {
     return false;
 }
Esempio n. 48
0
        //public MobileView(Mobile mobile) : base(mobile)
        //{

        //}

        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            //mobile.AnimIndex = 0;

            bool mirror = false;
            byte dir    = (byte)GetDirectionForAnimation();

            FileManager.Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;
            SetupLayers(dir, this, out int mountOffset);

            if (Graphic == 0)
            {
                return(false);
            }

            AnimationFrameTexture bodyFrame = FileManager.Animations.GetTexture(_frames[0].Hash);

            if (bodyFrame == null)
            {
                return(false);
            }

            int drawCenterY = bodyFrame.CenterY;
            int drawX;
            int drawY = mountOffset + drawCenterY + (int)(Offset.Z / 4) - 22 - (int)(Offset.Y - Offset.Z - 3);

            if (IsFlipped)
            {
                drawX = -22 + (int)Offset.X;
            }
            else
            {
                drawX = -22 - (int)Offset.X;
            }


            /*if (_frames[0].IsSitting)
             * {
             *  int x1 = 0, y1 = 0;
             *  FileManager.Animations.FixSittingDirection(ref dir, ref mirror, ref x1, ref y1);
             * }*/

            FrameInfo = Rectangle.Empty;
            Rectangle rect = Rectangle.Empty;

            Hue hue = 0, targetColor = 0;

            if (Engine.Profile.Current.HighlightMobilesByFlags)
            {
                if (IsPoisoned)
                {
                    hue = 0x0044;
                }

                if (IsParalyzed)
                {
                    hue = 0x014C;
                }

                if (NotorietyFlag != NotorietyFlag.Invulnerable && IsYellowHits)
                {
                    hue = 0x0030;
                }
            }

            bool isAttack     = Serial == World.LastAttack;
            bool isUnderMouse = IsSelected && (TargetManager.IsTargeting || World.Player.InWarMode);
            bool needHpLine   = false;

            if (this != World.Player && (isAttack || isUnderMouse || TargetManager.LastGameObject == Serial))
            {
                targetColor = Notoriety.GetHue(NotorietyFlag);

                if (isAttack || this == TargetManager.LastGameObject)
                {
                    Engine.UI.SetTargetLineGump(this);

                    //if (TargetLineGump.TTargetLineGump?.Mobile != this)
                    //{
                    //    if (TargetLineGump.TTargetLineGump == null || TargetLineGump.TTargetLineGump.IsDisposed)
                    //    {
                    //        TargetLineGump.TTargetLineGump = new TargetLineGump();
                    //        Engine.UI.Add(TargetLineGump.TTargetLineGump);
                    //    }
                    //    else
                    //    {
                    //        TargetLineGump.TTargetLineGump.SetMobile(this);
                    //    }
                    //}

                    needHpLine = true;
                }

                if (isAttack || isUnderMouse)
                {
                    hue = targetColor;
                }
            }

            for (int i = 0; i < _layerCount; i++)
            {
                ViewLayer             vl    = _frames[i];
                AnimationFrameTexture frame = FileManager.Animations.GetTexture(vl.Hash);

                if (frame.IsDisposed)
                {
                    continue;
                }
                int x = drawX + frame.CenterX;
                int y = -drawY - (frame.Height + frame.CenterY) + drawCenterY - vl.OffsetY;

                int yy = -(frame.Height + frame.CenterY + 3);
                int xx = -frame.CenterX;

                if (mirror)
                {
                    xx = -(frame.Width - frame.CenterX);
                }

                if (xx < rect.X)
                {
                    rect.X = xx;
                }

                if (yy < rect.Y)
                {
                    rect.Y = yy;
                }

                if (rect.Width < xx + frame.Width)
                {
                    rect.Width = xx + frame.Width;
                }

                if (rect.Height < yy + frame.Height)
                {
                    rect.Height = yy + frame.Height;
                }

                Texture = frame;
                Bounds  = new Rectangle(x, -y, frame.Width, frame.Height);

                if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ViewRange)
                {
                    HueVector = new Vector3(Constants.OUT_RANGE_COLOR, 1, HueVector.Z);
                }
                else if (World.Player.IsDead && Engine.Profile.Current.EnableBlackWhiteEffect)
                {
                    HueVector = new Vector3(Constants.DEAD_RANGE_COLOR, 1, HueVector.Z);
                }
                else
                {
                    HueVector = ShaderHuesTraslator.GetHueVector(this.IsHidden ? 0x038E : hue == 0 ? vl.Hue : hue, vl.IsPartial, 0, false);
                }

                base.Draw(batcher, position, objectList);
                Pick(frame, Bounds, position, objectList);
            }

            FrameInfo.X      = Math.Abs(rect.X);
            FrameInfo.Y      = Math.Abs(rect.Y);
            FrameInfo.Width  = FrameInfo.X + rect.Width;
            FrameInfo.Height = FrameInfo.Y + rect.Height;


            //if (needHpLine)
            //{
            //    //position.X += Engine.Profile.Current.GameWindowPosition.X + 9;
            //    //position.Y += Engine.Profile.Current.GameWindowPosition.Y + 30;

            //    //TargetLineGump.TTargetLineGump.X = (int)(position.X /*+ 22*/ + Offset.X);
            //    //TargetLineGump.TTargetLineGump.Y = (int)(position.Y /*+ 22 + (mobile.IsMounted ? 22 : 0) */+ Offset.Y - Offset.Z - 3);
            //    //TargetLineGump.TTargetLineGump.BackgroudHue = targetColor;

            //    //if (IsPoisoned)
            //    //    TargetLineGump.TTargetLineGump.HpHue = 63;
            //    //else if (IsYellowHits)
            //    //    TargetLineGump.TTargetLineGump.HpHue = 53;

            //    //else
            //    //    TargetLineGump.TTargetLineGump.HpHue = 90;

            //    Engine.UI.SetTargetLineGumpHue(targetColor);
            //}

            //if (_edge == null)
            //{
            //    _edge = new Texture2D(batcher.GraphicsDevice, 1, 1);
            //    _edge.SetData(new Color[] { Color.LightBlue });
            //}

            //batcher.DrawRectangle(_edge, GetOnScreenRectangle(), Vector3.Zero);
            Engine.DebugInfo.MobilesRendered++;
            return(true);
        }
Esempio n. 49
0
 protected void Pick(MouseOverList mouseOverList, VertexPositionNormalTextureHue[] vertexBuffer)
 {
     if ((mouseOverList.PickType & PickType) == PickType)
     {
         if (((!DrawFlip) && mouseOverList.IsMouseInObject(vertexBuffer[0].Position, vertexBuffer[3].Position)) ||
             ((DrawFlip) && mouseOverList.IsMouseInObject(vertexBuffer[2].Position, vertexBuffer[1].Position)))
         {
             MouseOverItem item;
             if (!DrawFlip)
             {
                 item = new MouseOverItem(DrawTexture, vertexBuffer[0].Position, Entity);
                 item.Vertices = new Vector3[4] { vertexBuffer[0].Position, vertexBuffer[1].Position, vertexBuffer[2].Position, vertexBuffer[3].Position };
             }
             else
             {
                 item = new MouseOverItem(DrawTexture, vertexBuffer[2].Position, Entity);
                 item.Vertices = new Vector3[4] { vertexBuffer[2].Position, vertexBuffer[0].Position, vertexBuffer[3].Position, vertexBuffer[1].Position };
                 item.FlippedTexture = true;
             }
             mouseOverList.Add2DItem(item);
         }
     }
 }
Esempio n. 50
0
 public void UpdateOverEntities(MouseOverList list, Point mousePosition)
 {
     m_overObject = list.GetForemostMouseOverItem(mousePosition);
     m_overGround = list.GetForemostMouseOverItem<Ground>(mousePosition);
 }
Esempio n. 51
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (!AllowedToDraw || IsDisposed)
            {
                return(false);
            }

            Texture.Ticks = Engine.Ticks;

            if (IsSelected && _text.Hue != 0x0035)
            {
                _text.Hue = 0x0035;
                _text.CreateTexture();
                Texture = _text.Texture;
            }
            else if (!IsSelected && Hue != _text.Hue)
            {
                _text.Hue = Hue;
                _text.CreateTexture();
                Texture = _text.Texture;
            }


            HueVector = ShaderHuesTraslator.GetHueVector(0);

            if (EdgeDetection)
            {
                GameScene gs = Engine.SceneManager.GetScene <GameScene>();

                int width  = Texture.Width - Bounds.X;
                int height = Texture.Height - Bounds.Y;

                if (position.X < Bounds.X)
                {
                    position.X = Bounds.X;
                }
                else if (position.X > Engine.Profile.Current.GameWindowSize.X * gs.Scale - width)
                {
                    position.X = Engine.Profile.Current.GameWindowSize.X * gs.Scale - width;
                }

                if (position.Y - Bounds.Y < 0)
                {
                    position.Y = Bounds.Y;
                }
                else if (position.Y > Engine.Profile.Current.GameWindowSize.Y * gs.Scale - height)
                {
                    position.Y = Engine.Profile.Current.GameWindowSize.Y * gs.Scale - height;
                }
            }

            bool ok = base.Draw(batcher, position, objectList);


            if (_edge == null)
            {
                _edge = new Texture2D(batcher.GraphicsDevice, 1, 1);
                _edge.SetData(new Color[] { Color.LightBlue });
            }

            batcher.DrawRectangle(_edge, new Rectangle((int)position.X - Bounds.X, (int)position.Y - Bounds.Y, _text.Width, _text.Height), Vector3.Zero);

            return(ok);
        }
Esempio n. 52
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
            AnimatedItemEffect effect = (AnimatedItemEffect)GameObject;

            if (effect.AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed)
            {
                _displayedGraphic = effect.AnimationGraphic;
                Texture           = Art.GetStaticTexture(effect.AnimationGraphic);
                Bounds            = new Rectangle(Texture.Width / 2 - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X  = Texture.Width / 2 - 22 - (int)effect.Offset.X;
            Bounds.Y  = Texture.Height - 44 + (int)(effect.Offset.Z - effect.Offset.Y);
            HueVector = RenderExtentions.GetHueVector(GameObject.Hue);

            return(base.Draw(spriteBatch, position, objectList));
        }
Esempio n. 53
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (GameObject.IsDisposed)
            {
                return(false);
            }
#if !ORIONSORT
            ShadowZDepth = spriteBatch.GetZ();
#endif
            Mobile mobile = (Mobile)GameObject;
            bool   mirror = false;
            byte   dir    = (byte)mobile.GetDirectionForAnimation();
            Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;
            int mountOffset = 0;
            SetupLayers(dir, ref mobile, ref mountOffset);
            ref TextureAnimationFrame bodyFrame = ref _frames[0].Frame;
Esempio n. 54
0
        public virtual bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            VertexPositionNormalTextureHue[] vertexBuffer;

            if (Rotation != 0)
            {
                float   w      = DrawArea.Width / 2f;
                float   h      = DrawArea.Height / 2f;
                Vector3 center = drawPosition - new Vector3(DrawArea.X - IsometricRenderer.TILE_SIZE_INTEGER + w, DrawArea.Y + h, 0);
                float   sinx   = (float)Math.Sin(Rotation) * w;
                float   cosx   = (float)Math.Cos(Rotation) * w;
                float   siny   = (float)Math.Sin(Rotation) * -h;
                float   cosy   = (float)Math.Cos(Rotation) * -h;
                // 2   0
                // |\  |
                // |  \|
                // 3   1
                vertexBuffer = VertexPositionNormalTextureHue.PolyBufferFlipped;

                vertexBuffer[0].Position    = center;
                vertexBuffer[0].Position.X += cosx - -siny;
                vertexBuffer[0].Position.Y -= sinx + -cosy;

                vertexBuffer[1].Position    = center;
                vertexBuffer[1].Position.X += cosx - siny;
                vertexBuffer[1].Position.Y += -sinx + -cosy;

                vertexBuffer[2].Position    = center;
                vertexBuffer[2].Position.X += -cosx - -siny;
                vertexBuffer[2].Position.Y += sinx + cosy;

                vertexBuffer[3].Position    = center;
                vertexBuffer[3].Position.X += -cosx - siny;
                vertexBuffer[3].Position.Y += sinx + -cosy;
            }
            else
            {
                if (DrawFlip)
                {
                    // 2   0
                    // |\  |
                    // |  \|
                    // 3   1
                    vertexBuffer                        = VertexPositionNormalTextureHue.PolyBufferFlipped;
                    vertexBuffer[0].Position            = drawPosition;
                    vertexBuffer[0].Position.X         += DrawArea.X + IsometricRenderer.TILE_SIZE_FLOAT;
                    vertexBuffer[0].Position.Y         -= DrawArea.Y;
                    vertexBuffer[0].TextureCoordinate.Y = 0;

                    vertexBuffer[1].Position    = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.Y += DrawArea.Height;

                    vertexBuffer[2].Position            = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.X         -= DrawArea.Width;
                    vertexBuffer[2].TextureCoordinate.Y = 0;

                    vertexBuffer[3].Position    = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.X -= DrawArea.Width;

                    /*if (m_YClipLine != 0)
                     * {
                     *  if (m_YClipLine > vertexBuffer[3].Position.Y)
                     *      return false;
                     *  else if (m_YClipLine > vertexBuffer[0].Position.Y)
                     *  {
                     *      float uvStart = (m_YClipLine - vertexBuffer[0].Position.Y) / DrawTexture.Height;
                     *      vertexBuffer[0].Position.Y = vertexBuffer[2].Position.Y = m_YClipLine;
                     *      vertexBuffer[0].TextureCoordinate.Y = vertexBuffer[2].TextureCoordinate.Y = uvStart;
                     *  }
                     * }*/
                }
                else
                {
                    // 0---1
                    //    /
                    //  /
                    // 2---3
                    vertexBuffer                        = VertexPositionNormalTextureHue.PolyBuffer;
                    vertexBuffer[0].Position            = drawPosition;
                    vertexBuffer[0].Position.X         -= DrawArea.X;
                    vertexBuffer[0].Position.Y         -= DrawArea.Y;
                    vertexBuffer[0].TextureCoordinate.Y = 0;

                    vertexBuffer[1].Position            = vertexBuffer[0].Position;
                    vertexBuffer[1].Position.X         += DrawArea.Width;
                    vertexBuffer[1].TextureCoordinate.Y = 0;

                    vertexBuffer[2].Position    = vertexBuffer[0].Position;
                    vertexBuffer[2].Position.Y += DrawArea.Height;

                    vertexBuffer[3].Position    = vertexBuffer[1].Position;
                    vertexBuffer[3].Position.Y += DrawArea.Height;

                    /*if (m_YClipLine != 0)
                     * {
                     *  if (m_YClipLine >= vertexBuffer[3].Position.Y)
                     *      return false;
                     *  else if (m_YClipLine > vertexBuffer[0].Position.Y)
                     *  {
                     *      float uvStart = (m_YClipLine - vertexBuffer[0].Position.Y) / DrawTexture.Height;
                     *      vertexBuffer[0].Position.Y = vertexBuffer[1].Position.Y = m_YClipLine;
                     *      vertexBuffer[0].TextureCoordinate.Y = vertexBuffer[1].TextureCoordinate.Y = uvStart;
                     *  }
                     * }*/
                }
            }

            if (vertexBuffer[0].Hue != HueVector)
            {
                vertexBuffer[0].Hue = vertexBuffer[1].Hue = vertexBuffer[2].Hue = vertexBuffer[3].Hue = HueVector;
            }

            if (!spriteBatch.DrawSprite(DrawTexture, vertexBuffer, s_Technique))
            {
                // the vertex buffer was not on screen, return false (did not draw)
                return(false);
            }

            Pick(mouseOverList, vertexBuffer);

            if (IsShadowCastingView)
            {
                spriteBatch.DrawShadow(DrawTexture, vertexBuffer, new Vector2(
                                           drawPosition.X + IsometricRenderer.TILE_SIZE_FLOAT_HALF,
                                           drawPosition.Y + (Entity.Position.Offset.X + Entity.Position.Offset.Y) * IsometricRenderer.TILE_SIZE_FLOAT_HALF - ((Entity.Position.Z_offset + Entity.Z) * 4) + IsometricRenderer.TILE_SIZE_FLOAT_HALF),
                                       DrawFlip, DrawShadowZDepth);
            }

            return(true);
        }
Esempio n. 55
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            CheckDefer(map, drawPosition);

            return DrawInternal(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
        }
Esempio n. 56
0
 /// <summary>
 /// Used by DeferredView to draw an object without first determining if it should be deferred.
 /// Should only be implemented for those views that call CheckDefer(), Otherwise, using only
 /// Draw() will suffice. See MobileView for an example of use.
 /// </summary>
 public virtual bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
 {
     return(false);
 }
Esempio n. 57
0
        private void DrawEntities(Map map, Position3D center, MousePicking mousePicking, out Vector2 renderOffset)
        {
            if (center == null)
            {
                renderOffset = new Vector2();
                return;
            }

            // reset the spritebatch Z
            m_SpriteBatch.Reset();
            // set the lighting variables.
            m_SpriteBatch.SetLightIntensity(Lighting.IsometricLightLevel);
            m_SpriteBatch.SetLightDirection(Lighting.IsometricLightDirection);

            // get variables that describe the tiles drawn in the viewport: the first tile to draw,
            // the offset to that tile, and the number of tiles drawn in the x and y dimensions.
            Point firstTile, renderDimensions;
            int overDrawTilesOnSides = 3;
            int overDrawTilesAtTopAndBottom = 6;
            int overDrawAdditionalTilesOnBottom = 10;
            CalculateViewport(center, overDrawTilesOnSides, overDrawTilesAtTopAndBottom, out firstTile, out renderOffset, out renderDimensions);

            CountEntitiesRendered = 0; // Count of objects rendered for statistics and debug

            MouseOverList overList = new MouseOverList(mousePicking); // List of entities mouse is over.
            List<AEntity> deferredToRemove = new List<AEntity>();

            for (int y = 0; y < renderDimensions.Y * 2 + 1 + overDrawAdditionalTilesOnBottom; y++)
            {
                Vector3 drawPosition = new Vector3();
                drawPosition.X = (firstTile.X - firstTile.Y + (y % 2)) * TILE_SIZE_FLOAT_HALF + renderOffset.X;
                drawPosition.Y = (firstTile.X + firstTile.Y + y) * TILE_SIZE_FLOAT_HALF + renderOffset.Y;

                Point firstTileInRow = new Point(firstTile.X + ((y + 1) / 2), firstTile.Y + (y / 2));

                for (int x = 0; x < renderDimensions.X + 1; x++)
                {
                    MapTile tile = map.GetMapTile(firstTileInRow.X - x, firstTileInRow.Y + x);
                    if (tile == null)
                    {
                        drawPosition.X -= TILE_SIZE_FLOAT;
                        continue;
                    }

                    List<AEntity> entities = tile.Entities;
                    bool draw = true;
                    for (int i = 0; i < entities.Count; i++)
                    {
                        if (entities[i] is DeferredEntity)
                            deferredToRemove.Add(entities[i]);

                        if (!m_DrawTerrain)
                        {
                            if ((entities[i] is Ground) || (entities[i].Z > tile.Ground.Z))
                                draw = false;
                        }

                        if ((entities[i].Z >= m_DrawMaxItemAltitude || (m_DrawMaxItemAltitude != 255 && entities[i] is Item && (entities[i] as Item).ItemData.IsRoof)) && !(entities[i] is Ground))
                        {
                            continue;
                        }

                        if (draw)
                        {
                            AEntityView view = entities[i].GetView();
                            if (view != null)
                            {
                                if (view.Draw(m_SpriteBatch, drawPosition, overList, map, !m_UnderSurface))
                                    CountEntitiesRendered++;
                            }
                        }
                    }

                    foreach (AEntity deferred in deferredToRemove)
                        tile.OnExit(deferred);
                    deferredToRemove.Clear();

                    drawPosition.X -= TILE_SIZE_FLOAT;
                }
            }

            OverheadsView.Render(m_SpriteBatch, overList, map, m_UnderSurface);

            // Update the MouseOver objects
            mousePicking.UpdateOverEntities(overList, mousePicking.Position);

            // Draw the objects we just send to the spritebatch.
            m_SpriteBatch.GraphicsDevice.SetRenderTarget(m_RenderTargetSprites);
            m_SpriteBatch.GraphicsDevice.Clear(Color.Black);
            m_SpriteBatch.FlushSprites(true);
            m_SpriteBatch.GraphicsDevice.SetRenderTarget(null);
        }
Esempio n. 58
0
        private bool DrawCorpse(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            byte dir    = (byte)((byte)Layer & 0x7F & 7);
            bool mirror = false;

            FileManager.Animations.GetAnimDirection(ref dir, ref mirror);
            IsFlipped = mirror;
            FileManager.Animations.Direction = dir;
            byte animIndex = (byte)AnimIndex;


            for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = LayerOrder.UsedLayers[dir, i];

                if (layer == Layer.Mount)
                {
                    continue;
                }
                Graphic graphic;
                Hue     color;

                if (layer == Layer.Invalid)
                {
                    graphic = GetGraphicForAnimation();
                    //graphic = item.DisplayedGraphic;
                    FileManager.Animations.AnimGroup = FileManager.Animations.GetDieGroupIndex(GetGraphicForAnimation(), UsedLayer);
                    color = Hue;
                }
                else if (HasEquipment)
                {
                    Item itemEquip = Equipment[(int)layer];

                    if (itemEquip == null)
                    {
                        continue;
                    }
                    graphic = itemEquip.ItemData.AnimID;

                    if (FileManager.Animations.EquipConversions.TryGetValue(itemEquip.Graphic, out Dictionary <ushort, EquipConvData> map))
                    {
                        if (map.TryGetValue(itemEquip.ItemData.AnimID, out EquipConvData data))
                        {
                            graphic = data.Graphic;
                        }
                    }

                    color = itemEquip.Hue;
                }
                else
                {
                    continue;
                }

                FileManager.Animations.AnimID = graphic;
                ref var index = ref FileManager.Animations.DataIndex[FileManager.Animations.AnimID];
                ref AnimationDirection direction = ref index.Groups[FileManager.Animations.AnimGroup].Direction[FileManager.Animations.Direction];
Esempio n. 59
0
        public virtual bool Draw(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList list)
        {
            if (Texture == null || Texture.IsDisposed || !AllowedToDraw || GameObject.IsDisposed)
            {
                return(false);
            }
            Texture.Ticks = CoreGame.Ticks;
            SpriteVertex[] vertex;

            if (Rotation != 0.0f)
            {
                float   w      = Bounds.Width / 2f;
                float   h      = Bounds.Height / 2f;
                Vector3 center = position - new Vector3(Bounds.X - 44 + w, Bounds.Y + h, 0);
                float   sinx   = (float)Math.Sin(Rotation) * w;
                float   cosx   = (float)Math.Cos(Rotation) * w;
                float   siny   = (float)Math.Sin(Rotation) * h;
                float   cosy   = (float)Math.Cos(Rotation) * h;
                vertex                = SpriteVertex.PolyBufferFlipped;
                vertex[0].Position    = center;
                vertex[0].Position.X += cosx - -siny;
                vertex[0].Position.Y -= sinx + -cosy;
                vertex[1].Position    = center;
                vertex[1].Position.X += cosx - siny;
                vertex[1].Position.Y += -sinx + -cosy;
                vertex[2].Position    = center;
                vertex[2].Position.X += -cosx - -siny;
                vertex[2].Position.Y += sinx + cosy;
                vertex[3].Position    = center;
                vertex[3].Position.X += -cosx - siny;
                vertex[3].Position.Y += sinx + -cosy;
            }
            else if (IsFlipped)
            {
                vertex                        = SpriteVertex.PolyBufferFlipped;
                vertex[0].Position            = position;
                vertex[0].Position.X         += Bounds.X + 44f;
                vertex[0].Position.Y         -= Bounds.Y;
                vertex[0].TextureCoordinate.Y = 0;
                vertex[1].Position            = vertex[0].Position;
                vertex[1].Position.Y         += Bounds.Height;
                vertex[2].Position            = vertex[0].Position;
                vertex[2].Position.X         -= Bounds.Width;
                vertex[2].TextureCoordinate.Y = 0;
                vertex[3].Position            = vertex[1].Position;
                vertex[3].Position.X         -= Bounds.Width;
            }
            else
            {
                vertex                        = SpriteVertex.PolyBuffer;
                vertex[0].Position            = position;
                vertex[0].Position.X         -= Bounds.X;
                vertex[0].Position.Y         -= Bounds.Y;
                vertex[0].TextureCoordinate.Y = 0;
                vertex[1].Position            = vertex[0].Position;
                vertex[1].Position.X         += Bounds.Width;
                vertex[1].TextureCoordinate.Y = 0;
                vertex[2].Position            = vertex[0].Position;
                vertex[2].Position.Y         += Bounds.Height;
                vertex[3].Position            = vertex[1].Position;
                vertex[3].Position.Y         += Bounds.Height;
            }

            if (IsSelected)
            {
                if (_storedHue == Vector3.Zero)
                {
                    _storedHue = HueVector;
                }
                HueVector = RenderExtentions.SelectedHue;
            }
            else if (_storedHue != Vector3.Zero)
            {
                HueVector  = _storedHue;
                _storedHue = Vector3.Zero;
            }

            if (vertex[0].Hue != HueVector)
            {
                vertex[0].Hue = vertex[1].Hue = vertex[2].Hue = vertex[3].Hue = HueVector;
            }

            //if (HasShadow)
            //{
            //    SpriteVertex[] vertexS = new SpriteVertex[4]
            //    {
            //        vertex[0],
            //        vertex[1],
            //        vertex[2],
            //        vertex[3]
            //    };

            //    spriteBatch.DrawShadow(Texture, vertexS, new Vector2(position.X + 22, position.Y + GameObject.Offset.Y - GameObject.Offset.Z + 22), IsFlipped, ShadowZDepth);
            //}

            if (!spriteBatch.DrawSprite(Texture, vertex))
            {
                return(false);
            }
            MousePick(list, vertex);

            return(true);
        }
Esempio n. 60
0
        private void DrawTextOverheads(Batcher2D batcher, MouseOverList list)
        {
            if (_firstNode != null)
            {
                //for (int i = 0; i < _allOverheads.Count; i++)

                for (TextOverhead overhead = _firstNode; overhead != null; overhead = (TextOverhead)overhead.Right)
                {
                    // TextOverhead overhead = _allOverheads[i].Item1;
                    GameObject owner = overhead.Parent;

                    if (overhead.IsDisposed || owner.IsDisposed)
                    {
                        //_allOverheads.RemoveAt(i--);
                        continue;
                    }


                    Vector3 position = owner.RealScreenPosition; // _allOverheads[i].Item2;

                    if (owner is Mobile m)
                    {
                        GetAnimationDimensions(m, 0xFF, out int height, out int centerY);

                        position = new Vector3
                        {
                            X = position.X + m.Offset.X,
                            Y = position.Y + (m.Offset.Y - m.Offset.Z) - (height + centerY + 8),
                            Z = position.Z
                        };
                    }
                    //else if (owner is Static st)
                    //    position.Y -= st.ItemData.Height /*((ArtTexture)st.View.Texture).ImageRectangle.Height / 2*/;

                    View      v       = overhead.View;
                    Rectangle current = new Rectangle((int)position.X - v.Bounds.X, (int)position.Y - v.Bounds.Y, v.Bounds.Width, v.Bounds.Height);

                    for (TextOverhead ov = (TextOverhead)overhead.Right; ov != null; ov = (TextOverhead)ov.Right)
                    //for (int j = i + 1; j < _allOverheads.Count; j++)
                    {
                        //var a = _allOverheads[j];
                        //TextOverhead ov = a.Item1;
                        View    b    = ov.View;
                        Vector3 pos2 = ov.RealScreenPosition; // a.Item2;

                        if (ov.Parent is Mobile mm)
                        {
                            GetAnimationDimensions(mm, 0xFF, out int height, out int centerY);

                            pos2 = new Vector3
                            {
                                X = pos2.X + mm.Offset.X,
                                Y = pos2.Y + (mm.Offset.Y - mm.Offset.Z) - (height + centerY + 8),
                                Z = pos2.Z
                            };
                        }

                        Rectangle next = new Rectangle((int)pos2.X - b.Bounds.X, (int)pos2.Y - b.Bounds.Y, b.Bounds.Width, b.Bounds.Height);

                        if (overhead.IsOverlapped = current.Intersects(next))
                        {
                            break;
                        }
                    }

                    v.Draw(batcher, position, list);
                }

                //_allOverheads.Clear();

                GameObject last = _firstNode;

                while (last != null)
                {
                    GameObject temp = last.Right;

                    last.Left  = null;
                    last.Right = null;

                    last = temp;
                }

                _firstNode = null;
            }
        }