Exemple #1
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;
 }
        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);
        }
        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);
        }
        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 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();
            }
        }
Exemple #6
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);
        }
 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);
 }
Exemple #8
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);
        }
        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);
        }
Exemple #10
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);
        }
Exemple #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);
 }
Exemple #12
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;
 }
        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);
        }
        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);
        }
Exemple #15
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;
        }
Exemple #16
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;
        }
Exemple #17
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;
        }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
        {
            if (roofHideFlag && CheckUnderSurface(map, Entity.DestinationPosition.X, Entity.DestinationPosition.Y))
                return false;
            if (Entity.Body == 0)
                return false;

            CheckDefer(map, drawPosition);

            return DrawInternal(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag);
        }
Exemple #19
0
 public IsometricRenderer()
 {
     m_SpriteBatch = Service.Get<SpriteBatch3D>();
     Lighting = new IsometricLighting();
 }
 public IsometricRenderer()
 {
     m_spriteBatch = ServiceRegistry.GetService<SpriteBatch3D>();
 }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, Map map, bool roofHideFlag)
        {
            CheckDefer(map, drawPosition);

            return DrawInternal(spriteBatch, drawPosition, mouseOver, map, roofHideFlag);
        }
Exemple #22
0
 bool Draw3DStretched(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOver, 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, Technique))
     {
         return false;
     }
     if ((mouseOver.PickType & PickType) == PickType)
     {
         if (mouseOver.IsMouseInObjectIsometric(m_vertexBufferAlternate))
         {
             mouseOver.AddItem(Entity, m_vertexBufferAlternate[0].Position);
         }
     }
     return true;
 }
 public SpriteBatchUI(Game game)
 {
     m_SpriteBatch = new SpriteBatch3D(game);
 }
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
 {
     m_BaseView.SetAllowDefer();
     return m_BaseView.Draw(spriteBatch, m_DrawPosition, mouseOverList, map);
 }
Exemple #25
0
        public override bool DrawInternal(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, 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) ? true : false;

            InternalSetupLayers();
            int drawCenterY = 0;
            if (m_MobileLayers[0].Frame != null)
            {
                drawCenterY = m_MobileLayers[0].Frame.Center.Y;
            }
            else
            {
                drawCenterY = -(drawCenterY + IsometricRenderer.TILE_SIZE_INTEGER);
            }

            int drawX, 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;

            // 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 = (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);

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

            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 ? true : false : false;
            DrawOverheads(spriteBatch, overheadDrawPosition, mouseOverList, map, isMounted ? yOffset + 16 : yOffset);

            return true;
        }
Exemple #26
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;
        }
Exemple #27
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;
     }
 }
Exemple #28
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;
 }
Exemple #29
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;
        }
Exemple #30
0
        public virtual bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            VertexPositionNormalTextureHue[] vertexBuffer;

            if (Rotation != 0)
            {
                Vector3 center = drawPosition - new Vector3(DrawArea.X - World.WorldViews.IsometricRenderer.TileSizeI + DrawArea.Width / 2, DrawArea.Y + DrawArea.Height / 2, 0);
                float sinx = (float)System.Math.Sin(Rotation) * DrawArea.Width / 2f;
                float cosx = (float)System.Math.Cos(Rotation) * DrawArea.Width / 2f;
                float siny = (float)System.Math.Sin(Rotation) * -DrawArea.Height / 2f;
                float cosy = (float)System.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 + World.WorldViews.IsometricRenderer.TileSizeF;
                    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, s_Technique))
            {
                return false;
            }

            Pick(mouseOverList, vertexBuffer);

            return true;
        }
 public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map, bool roofHideFlag)
 {
     HueVector = Utility.GetHueVector(Entity.Hue);
     return base.Draw(spriteBatch, drawPosition, mouseOverList, map, roofHideFlag);
 }