Ejemplo n.º 1
0
        // --------------------------------------------------------------------
        // Tell a Direct3D.Sprite object how to render this sprite
        // --------------------------------------------------------------------
        public void Draw(Direct3D.Sprite renderer, Camera camera)
        {
            // calculate the actual width and height:
            float w = XScale * Width;
            float h = YScale * Height;

            // calculate the actual anchor point in sprite coordinates:
            DirectX.Vector2 scaledanchor = anchor;
            scaledanchor.X *= w;
            scaledanchor.Y *= h;

            DirectX.Vector2 newoffset = offset;
            newoffset.X -= scaledanchor.X;
            newoffset.Y -= scaledanchor.Y;


            renderer.Draw(
                texture,
                rect,
                scaling,
                scaledanchor,
                angle,
                newoffset - camera.Offset,
                color);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Move the pendulum
        /// </summary>
        /// <param name="timer">The timer.</param>
        public void Move(Timer timer)
        {
            var rotation = (float)(_maxAngle * Math.Cos(Math.Sqrt(9.81 / _length) * timer.Time()));

            _sprite.Begin(Direct3D.SpriteFlags.AlphaBlend);
            _sprite.Transform =
                Matrix.Transformation2D(
                    new Vector2((float)(_sWidth / 2.0), 0.0f),      //scaling centre
                    0.0f,                                           //scaling ratio
                    new Vector2(_length / 5.0f, _length / 5.0f),    //scaling
                    new Vector2((float)(_sWidth / 2.0), 0),         //rotation centre
                    rotation,                                       //rotation
                    new Vector2(0.0f, 0.0f));                       //translation

            _sprite.Draw(_texture, Rectangle.Empty, new Vector3(50, 0.0f, 0.0f), new Vector3((float)(_sWidth / 2.0), 0, 0.0f), Color.White);
            _sprite.End();
            if (Math.Abs(_maxAngle - 0.0) < 0.001)
            {
                _sound.Pan    = 0;
                _sound.Volume = 0;
            }
            else
            {
                _sound.Pan    = -(int)(10000 * (float)((rotation / _maxAngle) * .5));
                _sound.Volume = (int)(-1000 * (Math.Abs(rotation) / (_maxAngle)));
            }
        }
Ejemplo n.º 3
0
        private bool render_image(Microsoft.DirectX.Direct3D.Sprite sprite, Texture texture, Point hot, double fRadian, int nXDest, int nYDest, int nDestWidth, int nDestHeight, int nXSource, int nYSource, int nSourceWidth, int nSourceHeight, int cbAlpha)
        {
            const double M_PI = 3.14159265358979323846;

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

            if (fRadian == M_PI)
            {
                float degrees1 = (float)(fRadian * (180 / M_PI));
            }

            float degrees = (float)(fRadian * (180 / M_PI));

            System.Drawing.Rectangle srcRectangle = new System.Drawing.Rectangle(nXSource, nYSource, nSourceWidth, nSourceHeight);
            //Color color = Color.FromArgb( cbAlpha, Color.White );

            sprite.Begin(SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
            //sprite.Draw(_Texture, srcRectangle, Vector3.Empty, new Vector3(nXDest, nYDest, 0), cbAlpha );

            //_Sprite.Transform = Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);

            //sprite.Transform = Matrix.Translation(-nSourceWidth / 2, -nSourceHeight / 2, 0);
            //sprite.Transform *= Matrix.RotationZ((float)fRadian);
            //sprite.Transform *= Matrix.Translation(nSourceWidth / 2, nSourceHeight / 2, 0);
            //sprite.Transform *= Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);
            //sprite.Transform *= Matrix.Translation(nXDest, nYDest, 0);

            //sprite.Transform = Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);
            //sprite.Transform *= Matrix.Translation(-nDestWidth / 2, -nDestWidth / 2, 0);
            //sprite.Transform = Matrix.RotationZ((float)fRadian);
            //sprite.Transform *= Matrix.Translation(nDestWidth / 2, nDestWidth / 2, 0);
            //sprite.Transform *= Matrix.Translation(nXDest, nYDest, 0);

            sprite.Transform = Matrix.RotationZ((float)fRadian) * Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f) * Matrix.Translation(nXDest, nYDest, 0);

            sprite.Draw(texture, srcRectangle, new Vector3((int)hot.x_, (int)hot.y_, 0), new Vector3(0, 0, 0), System.Drawing.Color.FromArgb(cbAlpha, System.Drawing.Color.White).ToArgb());
            //sprite.Draw(texture, srcRectangle, new Vector3(0, 0, 0), new Vector3(0, 0, 0), System.Drawing.Color.FromArgb(cbAlpha, System.Drawing.Color.White).ToArgb());

            //_Sprite.Draw(_Texture, Vector3.Empty, new Vector3(nXDest, nYDest, 0), Color.White.ToArgb());
            sprite.End();

            //sprite.Begin(SpriteFlags.None);
            //sprite.Draw2D(_Texture, Rectangle.Empty, Rectangle.Empty,
            //              new Point(5, 5), Color.White);
            //sprite.End();

            return(true);
        }
        /// <summary>
        /// Draws a texture to the screen.
        /// </summary>
        /// <param name="id">Id of the texture to draw.</param>
        /// <param name="x">X position to draw at.</param>
        /// <param name="y">Y position to draw at.</param>
        /// <param name="scalex">X scale.</param>
        /// <param name="scaley">Y scale.</param>
        /// <param name="section">Section of the image to draw (Use Rectangle.Empty for the whole surface).</param>
        /// <param name="rotx">X position on the texture to rotate around.</param>
        /// <param name="roty">Y position on the texture to rotate around.</param>
        /// <param name="rot">Amount to rotate by (in radians).</param>
        /// <param name="color">Color to modulate the image with (use Color.ToArgb()).</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool Draw(int id, int x, int y,
                         float scalex, float scaley, System.Drawing.Rectangle section,
                         int rotx, int roty, float rot, int color)
        {
            // Make sure the id is in range.
            Debug.Assert((id > -1 && id < textures.Count), "id is out of range");

            // Make sure the sprite was created.
            if (sprite == null)
            {
                return(false);
            }

            // Initialize to Identity.
            Matrix result = Matrix.Identity;

            // Scale the sprite.
            Matrix scale = Matrix.Scaling(scalex, scaley, 1.0f);

            result *= scale;

            // Rotate the sprite.
            Matrix translate = Matrix.Translation(-rotx, -roty, 0.0f);

            result *= translate;

            Matrix rotate = Matrix.RotationZ(rot);

            result *= rotate;

            translate = Matrix.Translation(rotx, roty, 0.0f);
            result   *= translate;

            // Translate the sprite.
            translate = Matrix.Translation(x, y, 0.0f);
            result   *= translate;

            // Apply the transform.
            sprite.Transform = result;

            // Draw the sprite.
            sprite.Draw(((TEXTURE)textures[id]).texture, section, Vector3.Empty, Vector3.Empty, System.Drawing.Color.FromArgb(color));

            // Move the world back to identity.
            sprite.Transform = Matrix.Identity;

            // success.
            return(true);
        }
Ejemplo n.º 5
0
        public void WriteScore(D3D.Device device, int score)
        {
            Rectangle nixiePosition = new Rectangle(nixiesTileSet.XOrigin, nixiesTileSet.YOrigin, nixiesTileSet.ExtentX * 2, nixiesTileSet.ExtentY * 2);
            int       digit;

            using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
                d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
                for (int digitCount = 1; digitCount <= maxScoreDigits; digitCount++)
                {
                    digit           = score % 10;
                    score          /= 10;
                    nixiePosition.X = nixiesTileSet.XOrigin + (digit % nixiesTileSet.NumberFrameColumns) * nixiesTileSet.ExtentX * 2;
                    nixiePosition.Y = nixiesTileSet.YOrigin; //we know it's only one row
                    Vector3 position = new Vector3((float)this.Width / 2 - digitCount * nixiesTileSet.ExtentX * 2,
                                                   (float)this.Height - 60f, 0f);
                    d3dSprite.Draw(nixiesTileSet.Texture, nixiePosition,
                                   new Vector3(), position, Color.FromArgb(255, 255, 255, 255));
                }
                d3dSprite.End();
            }
        }
Ejemplo n.º 6
0
        //绘画图片
        public bool DrawImage(Device pD3DDevice, CPoint ptRotationOffset, double fRadian, char chDirection, int nXDest, int nYDest, int nDestWidth, int nDestHeight, int nXSource, int nYSource, int nSourceWidth, int nSourceHeight, int cbAlpha)
        {
            if (_Sprite == null)
            {
                return(false);
            }

            if (fRadian == FishDefine.M_PI)
            {
                float degrees1 = (float)(fRadian * (180 / FishDefine.M_PI));
            }

            float degrees = (float)(fRadian * (180 / FishDefine.M_PI));

            Rectangle srcRectangle = new Rectangle(nXSource, nYSource, nSourceWidth, nSourceHeight);

            //Color color = Color.FromArgb( cbAlpha, Color.White );

            _Sprite.Begin(SpriteFlags.SortTexture | SpriteFlags.AlphaBlend);
            //sprite.Draw(_Texture, srcRectangle, Vector3.Empty, new Vector3(nXDest, nYDest, 0), cbAlpha );

            //_Sprite.Transform = Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f);

            _Sprite.Transform = Matrix.RotationZ((float)-fRadian) * Matrix.Scaling((float)nDestWidth / nSourceWidth, (float)nDestHeight / nSourceHeight, 0.0f) * Matrix.Translation(nXDest, nYDest, 0);

            _Sprite.Draw(_Texture, srcRectangle, new Vector3(ptRotationOffset.x, ptRotationOffset.y, 0), new Vector3(0, 0, 0), Color.FromArgb(cbAlpha, Color.White).ToArgb());

            //_Sprite.Draw(_Texture, Vector3.Empty, new Vector3(nXDest, nYDest, 0), Color.White.ToArgb());
            _Sprite.End();

            //sprite.Begin(SpriteFlags.None);
            //sprite.Draw2D(_Texture, Rectangle.Empty, Rectangle.Empty,
            //              new Point(5, 5), Color.White);
            //sprite.End();

            return(true);
        }
 public void WriteScore(D3D.Device device, int score)
 {
     Rectangle nixiePosition = new Rectangle(nixiesTileSet.XOrigin,nixiesTileSet.YOrigin,nixiesTileSet.ExtentX*2,nixiesTileSet.ExtentY*2);
     int digit;
     using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) {
         d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend);
         for (int digitCount = 1; digitCount <= maxScoreDigits; digitCount++) {
             digit = score % 10;
             score /= 10;
             nixiePosition.X = nixiesTileSet.XOrigin + ( digit % nixiesTileSet.NumberFrameColumns ) * nixiesTileSet.ExtentX*2;
             nixiePosition.Y = nixiesTileSet.YOrigin; //we know it's only one row
             Vector3 position = new Vector3((float)this.Width/2 - digitCount*nixiesTileSet.ExtentX*2,
                 (float)this.Height-60f, 0f);
             d3dSprite.Draw(nixiesTileSet.Texture, nixiePosition,
                 new Vector3(), position, Color.FromArgb(255,255,255,255));
         }
         d3dSprite.End();
     }
 }
Ejemplo n.º 8
0
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite Overlay)
        {
            GuiMenu mnu = GameEngine.Instance.GuiMenuModule["factoryMenu"];

            TextureManagerItem it;

            if (BuildQueueIndex != -1 && BuildProgress > -1)
            {
                StoreItem sit = GameEngine.Instance.ItemTemplates[BuildQueue[BuildQueueIndex].ItemId];
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, sit.Title, new Rectangle(mnu.Location.X, mnu.Location.Y + 40, 200, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Green);

                if (GameEngine.Instance.GuiTextures.ContainsKey("placeholder"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["placeholder"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 200, 125), new Vector3(0, 0, 0), new Vector3(mnu.Location.X, mnu.Location.Y + 69, 0), Color.FromArgb(255, 13, 13, 13).ToArgb());
                    }
                }

                if (GameEngine.Instance.GuiTextures.ContainsKey(sit.Picture))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures[sit.Picture].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(sit.TextureArea.Width * ((BuildProgress * 3) / sit.BuildTime + 1), 0, sit.TextureArea.Width, sit.TextureArea.Height), new Vector3(sit.TextureArea.Width, 0, 0), new Vector3(mnu.Location.X + 200, mnu.Location.Y + 69, 0), Color.White.ToArgb());
                    }
                }
            }

            if (HasAOC)
            {
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Production.AOC"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Production.AOC"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(0, 0, 305, 58), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366, mnu.Location.Y + 350, 0), Color.White.ToArgb());
                    }
                }
                // TODO: Render the real AOC blink
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Storage.ItemBlink"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Storage.ItemBlink"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        Overlay.Transform = Matrix.Identity;

                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 22, 0), Color.Red.ToArgb());
                        Overlay.Draw(it.Texture, new Rectangle(8 + 42 * ((Environment.TickCount / 70) % 10), 8, 7, 4), new Vector3(0, 0, 0), new Vector3(mnu.Location.X + 366 + 58, mnu.Location.Y + 350 + 21, 0), Color.Red.ToArgb());
                    }
                }
            }
            else
            {
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "LEADER", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 349, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "RANK", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 369, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "STAFF", new Rectangle(mnu.Location.X + 364, mnu.Location.Y + 389, 90, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.Red);

                if (ProductionTeam == null)
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, "None", new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
                else
                {
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamLeader, new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 349, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.GetTeamRank(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 369, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(Overlay, ProductionTeam.TeamSize.ToString(), new Rectangle(mnu.Location.X + 454, mnu.Location.Y + 389, 218, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                }
            }
        }
Ejemplo n.º 9
0
        void Draw(Device device)
        {
            try
            {
                System.Drawing.Rectangle rect;
                // start drawing commands
                device.BeginScene();


                // Demonstration 1
                // Draw a simple line using DrawText
                // Pass in DrawTextFormat.NoClip so we don't have to calc
                // the bottom/right of the rect

                font1.DrawText(null,
                               "This is a trivial call to Font.DrawText",
                               new System.Drawing.Rectangle(5, 150, 0, 0),
                               DrawTextFormat.NoClip, System.Drawing.Color.Red);


                // Demonstration 2
                // Allow multiple draw calls to sort by texture changes
                // by Sprite When drawing 2D text use flags:
                // SpriteFlags.AlphaBlend | SpriteFlags.SortTexture.

                textDrawerSprite.Begin(SpriteFlags.AlphaBlend |
                                       SpriteFlags.SortTexture);

                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 6, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "These are multiple calls to Font.DrawText()",
                               rect, DrawTextFormat.NoClip, Color.White);
                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 5, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "using the same Sprite. The font now caches",
                               rect, DrawTextFormat.NoClip, Color.White);
                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 4, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "letters on one or more textures. In order",
                               rect, DrawTextFormat.NoClip, Color.White);
                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 3, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "to sort by texturestate changes on multiple",
                               rect, DrawTextFormat.NoClip, Color.White);
                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 2, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "calls to DrawText() pass a Sprite and use flags",
                               rect, DrawTextFormat.NoClip, Color.White);
                rect = new System.Drawing.Rectangle(5, this.screenheight - 15 * 1, 0, 0);
                font2.DrawText(textDrawerSprite,
                               "SpriteFlags.AlphaBlend | SpriteFlags.SortTexture",
                               rect, DrawTextFormat.NoClip, Color.White);

                textDrawerSprite.End();

                // Demonstration 3:
                // Word wrapping and unicode text.
                // Note that not all fonts support dynamic font linking.
                System.Drawing.Rectangle rc =
                    new System.Drawing.Rectangle(10, 35,
                                                 this.screenwidth - 30, this.screenheight - 10);

                font2.DrawText(null, bigText, rc,
                               DrawTextFormat.Left | DrawTextFormat.WordBreak |
                               DrawTextFormat.ExpandTabs,
                               System.Drawing.Color.CornflowerBlue);

                // write the fps
                //fpsTimer.Render();
                OnRender( );
            }

            finally
            {
                // end the drawing commands and copy to screen
                device.EndScene();
                device.Present();
                //fpsTimer.StopFrame();
            }


            sprite.Begin(SpriteFlags.None);
            sprite.Draw(texture,
                        new Rectangle(0, 0, 512, 512),
                                                          //new Vector2( 1.0f, 1.0f ), // scaling
                        new Vector3(256.0f, 256.0f, 0.0f) //rotation center
                                                          //,0.0f // rogateion
                        , new Vector3(0.0f, 0.0f, 0.0f)   // translation
                        , Color.White                     // color
                        );
            sprite.End();
        }
Ejemplo n.º 10
0
 /// <summary>
 ///     Draws a sprite on the screen.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public void DrawSprite(Sprite sprite)
 {
     DxSprite.Transform = sprite.TransformationMatrix;
     DxSprite.Draw(sprite.Bitmap.Texture, sprite.SrcRect, Vector3.Empty, Vector3.Empty, sprite.Color);
 }
Ejemplo n.º 11
0
        public override void OnRenderInterface(Microsoft.DirectX.Direct3D.Sprite overlay)
        {
            if (mineralList)
            {
                isDescriptionShown = false;
            }
            else
            {
                if (GameEngine.Instance.IsMouseDown)
                {
                    isDescriptionShown = false;
                    curItemId          = "";
                }
            }

            int i = 0;

            Dictionary <string, int> pomst = null;

            if (this.mineralList)
            {
                pomst = this.StoreMaterials;
            }
            else
            {
                pomst = this.StoreItems;
            }

            Dictionary <string, int> required = new Dictionary <string, int>();

            if (curItemId != "" && mineralList)
            {
                for (i = 0; i < GameEngine.Instance.ItemTemplates[curItemId].Resources.Count; i++)
                {
                    required.Add(GameEngine.Instance.ItemTemplates[curItemId].Resources[i].itemId, GameEngine.Instance.ItemTemplates[curItemId].Resources[i].amount);
                }
            }

            int maxCanDo = 200;

            i = 0;
            foreach (KeyValuePair <string, int> si in pomst)
            {
                if (GameEngine.Instance.ItemTemplates[si.Key].Researched)
                {
                    Color col = Color.FromArgb(255, 110, 110, 45);
                    if (required.ContainsKey(si.Key))
                    {
                        if (required[si.Key] <= si.Value)
                        {
                            col = Color.Green;
                        }
                        else
                        {
                            col = Color.Red;
                        }

                        int pom = si.Value / required[si.Key];
                        if (maxCanDo > pom)
                        {
                            maxCanDo = pom;
                        }
                    }

                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Value.ToString(), new Rectangle(130, 40 + i * 20, 70, 20), DrawTextFormat.Right | DrawTextFormat.VerticalCenter, col);
                    GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, GameEngine.Instance.ItemTemplates[si.Key].Title, 220, 40 + i * 20, Color.White);
                    Rectangle rct;
                    rct = GameEngine.Instance.GuiFonts["fntGui"].DXFont.MeasureString(overlay, GameEngine.Instance.ItemTemplates[si.Key].Title, DrawTextFormat.None, Color.White);
                    rct.Offset(220, 40 + i * 20);

                    if (rct.Contains(GameEngine.Instance.MouseCoords))
                    {
                        GameEngine.Instance.CurrentTooltip = GameEngine.Instance.ItemTemplates[si.Key].Title;

                        if (!mineralList && GameEngine.Instance.IsMouseDown)
                        {
                            isDescriptionShown = true;
                            curItemId          = si.Key;
                        }
                    }

                    i++;
                }
            }

            GuiMenu mnu = GameEngine.Instance.GuiMenuModule["miningStoreMenu"];

            Point center = new Point(mnu.Location.X + mnu.TextureArea.Width / 2, mnu.Location.Y + mnu.TextureArea.Height / 2);

            if (mineralList && curItemId != "")
            {
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, "Enough Supplies For\r\n" + maxCanDo.ToString() + "x " + GameEngine.Instance.ItemTemplates[curItemId].Title, new Rectangle(mnu.Location.X, mnu.Location.Y, mnu.TextureArea.Width - 140, mnu.TextureArea.Height), DrawTextFormat.Right | DrawTextFormat.Top, Color.Yellow);
            }

            if (isDescriptionShown)
            {
                StoreItem si = GameEngine.Instance.ItemTemplates[curItemId];

                TextureManagerItem it;
                if (GameEngine.Instance.GuiTextures.ContainsKey("gameScreen.Storage.ItemDescription"))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures["gameScreen.Storage.ItemDescription"].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        overlay.Transform = Matrix.Identity;

                        overlay.Draw(it.Texture, new Rectangle(0, 0, 600, 300), new Vector3(300, 150, 0), new Vector3(center.X, center.Y, 0), Color.White.ToArgb());
                    }
                }

                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Title, new Rectangle(center.X - 270, center.Y - 130, 540, 20), DrawTextFormat.Left | DrawTextFormat.VerticalCenter, Color.White);
                GameEngine.Instance.GuiFonts["fntGui"].DXFont.DrawText(overlay, si.Description, new Rectangle(center.X - 270, center.Y - 110, 540, 260), DrawTextFormat.Left | DrawTextFormat.Top, Color.Yellow);

                if (GameEngine.Instance.GuiTextures.ContainsKey(si.Picture))
                {
                    it = GameEngine.Instance.mainTextures.GetTexture(GameEngine.Instance.GuiTextures[si.Picture].textureIdx);
                    if (it != null && it.Texture != null)
                    {
                        overlay.Transform = Matrix.Identity;

                        overlay.Draw(it.Texture, new Rectangle(0, 0, si.TextureArea.Width, si.TextureArea.Height), new Vector3(si.TextureArea.Width, si.TextureArea.Height / 2, 0), new Vector3(center.X + 270, center.Y, 0), Color.White.ToArgb());
                    }
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Renderizar Sprite
 /// </summary>
 /// <param name="sprite">Sprite a dibujar</param>
 public void drawSprite(TgcSprite sprite)
 {
     dxSprite.Transform = sprite.TransformationMatrix;
     dxSprite.Draw(sprite.Texture.D3dTexture, sprite.SrcRect, Vector3.Empty, Vector3.Empty, sprite.Color);
 }
 /// <summary>
 ///     Draws a sprite on the screen.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public void DrawSprite(CustomSprite sprite)
 {
     DxSprite.Transform = sprite.TransformationMatrix.ToMatrix();
     DxSprite.Draw(sprite.Bitmap.D3dTexture, sprite.SrcRect, TGCVector3.Empty, TGCVector3.Empty, sprite.Color);
 }