public override void Draw(SpriteBatchUI spriteBatch, Point position) { AEntity player = WorldModel.Entities.GetPlayerEntity(); float x = (float)Math.Round((player.Position.X % 256) + player.Position.X_offset) / 256f; float y = (float)Math.Round((player.Position.Y % 256) + player.Position.Y_offset) / 256f; Vector3 playerPosition = new Vector3(x - y, x + y, 0f); float minimapU = (m_GumpTexture.Width / 256f) / 2f; float minimapV = (m_GumpTexture.Height / 256f) / 2f; VertexPositionNormalTextureHue[] v = new VertexPositionNormalTextureHue[4] { new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y, 0), playerPosition + new Vector3(-minimapU, -minimapV, 0), new Vector3(0, 0, 0)), new VertexPositionNormalTextureHue(new Vector3(position.X + Width, position.Y, 0), playerPosition + new Vector3(minimapU, -minimapV, 0), new Vector3(1, 0, 0)), new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y + Height, 0), playerPosition + new Vector3(-minimapU, minimapV, 0), new Vector3(0, 1, 0)), new VertexPositionNormalTextureHue(new Vector3(position.X + Width, position.Y + Height, 0), playerPosition + new Vector3(minimapU, minimapV, 0), new Vector3(1, 1, 0)) }; spriteBatch.Draw(m_GumpTexture, v, Techniques.MiniMap); if (UltimaGame.TotalMS % 500f < 250f) { if (m_PlayerIndicator == null) { m_PlayerIndicator = new Texture2D(spriteBatch.GraphicsDevice, 1, 1); m_PlayerIndicator.SetData<uint>(new uint[1] { 0xFFFFFFFF }); } spriteBatch.Draw2D(m_PlayerIndicator, new Vector3(position.X + Width / 2, position.Y + Height / 2 - 8, 0), Vector3.Zero); } }
public bool Draw2D(Texture2D texture, Vector3 position, Vector3 hue) { m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(position.X + texture.Width, position.Y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(position.X + texture.Width, position.Y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return(DrawSprite(texture, m_AllocatedVertices)); }
public bool Draw2D(Texture2D texture, Vector3 position, Vector3 hue) { m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(position.X + texture.Width, position.Y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(position.X, position.Y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(position.X + texture.Width, position.Y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return DrawSprite(texture, m_AllocatedVertices); }
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); } }
public bool Draw2D(Texture2D texture, Rectangle destRect, Vector3 hue) { m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return(DrawSprite(texture, m_AllocatedVertices)); }
public bool Draw2D(Texture2D texture, Rectangle destRect, Vector3 hue) { m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return DrawSprite(texture, m_AllocatedVertices); }
public bool Draw2D(Texture2D texture, Rectangle destRect, Rectangle sourceRect, Vector3 hue) { float minX = sourceRect.X / (float)texture.Width, maxX = (sourceRect.X + sourceRect.Width) / (float)texture.Width; float minY = sourceRect.Y / (float)texture.Height, maxY = (sourceRect.Y + sourceRect.Height) / (float)texture.Height; m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(minX, minY, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(maxX, minY, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(minX, maxY, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(maxX, maxY, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return(DrawSprite(texture, m_AllocatedVertices)); }
public bool Draw2D(Texture2D texture, Rectangle destRect, Rectangle sourceRect, Vector3 hue) { float minX = sourceRect.X / (float)texture.Width, maxX = (sourceRect.X + sourceRect.Width) / (float)texture.Width; float minY = sourceRect.Y / (float)texture.Height, maxY = (sourceRect.Y + sourceRect.Height) / (float)texture.Height; m_AllocatedVertices[0] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(minX, minY, 0)); m_AllocatedVertices[1] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y, 0), new Vector3(0, 0, 1), new Vector3(maxX, minY, 0)); m_AllocatedVertices[2] = new VertexPositionNormalTextureHue(new Vector3(destRect.X, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(minX, maxY, 0)); m_AllocatedVertices[3] = new VertexPositionNormalTextureHue(new Vector3(destRect.X + destRect.Width, destRect.Y + destRect.Height, 0), new Vector3(0, 0, 1), new Vector3(maxX, maxY, 0)); m_AllocatedVertices[0].Hue = m_AllocatedVertices[1].Hue = m_AllocatedVertices[2].Hue = m_AllocatedVertices[3].Hue = hue; return DrawSprite(texture, m_AllocatedVertices); }
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); } } }
public void DrawStencil(Texture2D texture, VertexPositionNormalTextureHue[] vertices) { // Sanity: do not draw if there is no texture to draw with. if (texture == null) return; // set proper z depth for this shadow. vertices[0].Position.Z = vertices[1].Position.Z = vertices[2].Position.Z = vertices[3].Position.Z = GetNextUniqueZ(); }
/// <summary> /// Draws a quad on screen with the specified texture and vertices. /// </summary> /// <param name="texture"></param> /// <param name="vertices"></param> /// <returns>True if the object was drawn, false otherwise.</returns> public bool DrawSprite(Texture2D texture, VertexPositionNormalTextureHue[] vertices, Techniques effect = Techniques.Default) { bool draw = false; // Sanity: do not draw if there is no texture to draw with. if (texture == null) return false; // Check: only draw if the texture is within the visible area. for (int i = 0; i < 4; i++) // only draws a 2 triangle tristrip. { if (m_ViewportArea.Contains(vertices[i].Position) == ContainmentType.Contains) { draw = true; break; } } if (!draw) return false; // Set the draw position's z value, and increment the z value for the next drawn object. vertices[0].Position.Z = vertices[1].Position.Z = vertices[2].Position.Z = vertices[3].Position.Z = GetNextUniqueZ(); // Get the vertex list for this texture. if none exists, dequeue existing or create a new vertex list. List<VertexPositionNormalTextureHue> vertexList = GetVertexList(texture, effect); // Add the drawn object to the vertex list. for(int i = 0; i < vertices.Length; i++) vertexList.Add(vertices[i]); return true; }
/// <summary> /// Draws a special 'shadow' sprite, automatically skewing the passed vertices. /// </summary> /// <param name="texture">The texture to draw with.</param> /// <param name="vertices">An array of four vertices. Note: modified by this routine.</param> /// <param name="drawPosition">The draw position at which this sprite begins (should be the center of an isometric tile for non-moving sprites).</param> /// <param name="flipVertices">See AEntityView.Draw(); this is equivalent to DrawFlip.</param> /// <param name="z">The z depth at which the shadow sprite should be placed.</param> public void DrawShadow(Texture2D texture, VertexPositionNormalTextureHue[] vertices, Vector2 drawPosition, bool flipVertices, float z) { // Sanity: do not draw if there is no texture to draw with. if (texture == null) return; // set proper z depth for this shadow. vertices[0].Position.Z = vertices[1].Position.Z = vertices[2].Position.Z = vertices[3].Position.Z = z; // skew texture float skewHorizTop = (vertices[0].Position.Y - drawPosition.Y) * .5f; float skewHorizBottom = (vertices[3].Position.Y - drawPosition.Y) * .5f; vertices[0].Position.X -= skewHorizTop; vertices[0].Position.Y -= skewHorizTop; vertices[flipVertices ? 2 : 1].Position.X -= skewHorizTop; vertices[flipVertices ? 2 : 1].Position.Y -= skewHorizTop; vertices[flipVertices ? 1 : 2].Position.X -= skewHorizBottom; vertices[flipVertices ? 1 : 2].Position.Y -= skewHorizBottom; vertices[3].Position.X -= skewHorizBottom; vertices[3].Position.Y -= skewHorizBottom; List<VertexPositionNormalTextureHue> vertexList; vertexList = GetVertexList(texture, Techniques.ShadowSet); for (int i = 0; i < vertices.Length; i++) vertexList.Add(vertices[i]); }
/// <summary> /// Draws a quad on screen with the specified texture and vertices. /// </summary> /// <param name="texture"></param> /// <param name="vertices"></param> /// <returns>True if the object was drawn, false otherwise.</returns> public bool Draw(Texture2D texture, VertexPositionNormalTextureHue[] vertices, Techniques effects = Techniques.Default) { bool draw = false; // Check: do not draw if there is no texture to draw with. if (texture == null) return false; // Check: only draw if the texture is within the visible area. for (int i = 0; i < 4; i++) // only draws a 2 triangle tristrip. { if (ViewportArea.Contains(vertices[i].Position) == ContainmentType.Contains) { draw = true; break; } } if (!draw) return false; // Set the draw position's z value, and increment the z value for the next drawn object. vertices[0].Position.Z = vertices[1].Position.Z = vertices[2].Position.Z = vertices[3].Position.Z = Z++; // Get the vertex list for this texture. if none exists, dequeue or create a new vertex list. List<VertexPositionNormalTextureHue> vertexList; if(m_drawQueue[(int)effects].ContainsKey(texture)) { vertexList = m_drawQueue[(int)effects][texture]; } else { if(m_vertexListQueue.Count > 0) { vertexList = m_vertexListQueue.Dequeue(); vertexList.Clear(); } else { vertexList = new List<VertexPositionNormalTextureHue>(1024); } m_drawQueue[(int)effects].Add(texture, vertexList); } // Add the drawn object to the vertex list. for(int i = 0; i < vertices.Length; i++) vertexList.Add(vertices[i]); return true; }
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. }
protected virtual void Pick(MouseOverList mouseOver, VertexPositionNormalTextureHue[] vertexBuffer) { // override this method if the view should be pickable. }