Пример #1
0
 public static void DrawRectangle(SpriteBatch spriteBatch, Rectangle rect, Color color)
 {
     spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y, rect.Width, 1), color);
     spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y, 1, rect.Height), color);
     spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, 1), color);
     spriteBatch.Draw(PixelBlanc, new Rectangle(rect.X + rect.Width, rect.Y, 1, rect.Height), color);
 }
Пример #2
0
 public override void Draw(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
 {
     base.Draw(graphicsDevice, spriteBatch);
     foreach (Projectile p in projectiles)
     {
         p.Draw(graphicsDevice);
     }
     spriteBatch.Draw(loadBarBack, new Vector2(200, 0), Color.White);
     spriteBatch.Draw(loadBar, new RectangleF(205, 5, (timer/3000) * 250, 25), Color.White);
     spriteBatch.Draw(currentSphere, new Vector2(635, 5), Color.White);
 }
Пример #3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            var topRot = MathUtil.Pi * splitRatio;
            var bottomRot = MathUtil.Pi * (1.0f - splitRatio);

            var topPos = origin + new Vector2((float)-Math.Cos(topRot), (float)-Math.Sin(topRot)) * radius;
            var bottomPos = origin + new Vector2((float)-Math.Cos(topRot), (float)Math.Sin(topRot)) * radius;

            // draw "top" separator
            spriteBatch.Draw(separatorTexture, topPos, null, Color.White, topRot, separatorOrigin, scale, SpriteEffects.None, 0);
            // draw "bottom" separator
            spriteBatch.Draw(separatorTexture, bottomPos, null, Color.White, bottomRot, separatorOrigin, scale, SpriteEffects.FlipHorizontally, 0);
        }
Пример #4
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            spriteBatch.Draw(Sprite.Sheet.Texture, DestinationRect, Sprite.SourceRect, Color.White);
            if (List.Count > CurrentIndex)
                spriteBatch.DrawString(font, List[CurrentIndex], new Vector2(DestinationRect.X, DestinationRect.Y), Color.White);
        }
Пример #5
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            spriteBatch.Draw(Sprites[(int)CurrentState].Sheet.Texture, DestinationRect, Sprites[(int)CurrentState].SourceRect, Color.White);
            if (Text != "")
                spriteBatch.DrawString(font, Text, new Vector2(DestinationRect.X, DestinationRect.Y), Color.White);
        }
Пример #6
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            Sprite s = Sprites[IsSelected ? 1 : 0];
            spriteBatch.Draw(s.Sheet.Texture, DestinationRect, s.SourceRect, Color.White);
            if (Text != "")
                spriteBatch.DrawString(font, Text, new Vector2(DestinationRect.X, DestinationRect.Y), Color.White);
        }
Пример #7
0
 public void Draw(Device device, SpriteBatch spriteBatch, Vector2 position, Rectangle? sourceRectangle, float layerDepth)
 {
     ShaderResourceView shaderView = GetShaderResourceView(device);
     spriteBatch.Draw(shaderView,
         position,
         sourceRectangle,
         new Color(0xff, 0xff, 0xff, 0xff),
         0,
         Vector2.Zero,
         Vector2.One,
         SpriteEffects.None, layerDepth);
 }
Пример #8
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Rectangle destinationRect, Color color, float depth = 0.5f, SpriteEffects spriteEffects = SpriteEffects.None)
        {
            if (Animation == null)
                throw new NotSupportedException("No animation is currently playing.");

            SimulateTime(gameTime);

            if (CurrentSprite != null)
                spriteBatch.Draw(CurrentSprite.Sheet.Texture, destinationRect,
                    Animation.Sprites[FrameIndex].SourceRect,
                    color, 0.0f, Vector2.Zero, spriteEffects, depth);
        }
Пример #9
0
 internal void Draw(SpriteBatch sb, Vector2 offset)
 {
     if (_tex != null && _tex.IsLoaded)
     {
         var pos3 = Owner.Transform.Translation;
         var pos = new Vector2(pos3.X, pos3.Y) + offset;
         var scale = Owner.Transform.Scale;
         var rot = Owner.Transform.Rotation;
         var tex = _tex.Texture2D.ShaderResourceView[ViewType.Full, 0, 0];
         sb.Draw(tex, pos, SourceRegion, Color.White, rot, Origin, scale, SpriteEffects.None, pos3.Z);
     }
 }
Пример #10
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, int x, int y, Rectangle destinationRect)
        {
            base.Draw(gameTime, spriteBatch, x, y, destinationRect);

            byte pos = 0;
            if (World.GetTile(x, y + 1) == this) // D
                pos |= 1;
            if (World.GetTile(x, y - 1) == this) // U
                pos |= 2;
            if (World.GetTile(x + 1, y) == this) // R
                pos |= 4;
            if (World.GetTile(x - 1, y) == this) // L
                pos |= 8;
            if (pos >= 0 && pos < 16 && Sprites[pos] != null)
                spriteBatch.Draw(Sprites[pos].Sheet.Texture, destinationRect, Sprites[pos].SourceRect, Color.White, 0f, Vector2.Zero, SpriteEffects.None, GetDepth(x, y));
        }
Пример #11
0
 public static void DrawFilledRectangle(SpriteBatch spriteBatch, Rectangle rect, Color color)
 {
     spriteBatch.Draw(PixelBlanc, rect, color);
 }
Пример #12
0
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            try
            {
                switch (type)
                {
                    case MenuType.MainMenu:
                        spriteBatch.Draw(title, new Vector2(200, 0), Color.White);
                        spriteBatch.Draw(kartSelect.Texture, kartSelect.Position, Color.White);
                        spriteBatch.Draw(highScores.Texture, highScores.Position, Color.White);
                        spriteBatch.Draw(options.Texture, options.Position, Color.White);
                        spriteBatch.Draw(credits.Texture, credits.Position, Color.White);
                        spriteBatch.Draw(exit.Texture, exit.Position, Color.White);
                        break;

                    case MenuType.Options:
                        spriteBatch.Draw(highScores.Texture, highScores.Position, Color.White);
                        spriteBatch.Draw(menu.Texture, menu.Position, Color.White);
                        spriteBatch.Draw(sound.Texture, sound.Position, Color.White);
                        spriteBatch.Draw(fullscreen.Texture, fullscreen.Position, Color.White);
                        spriteBatch.DrawString(font, soundOn, new Vector2(500, 106), Color.White);
                        spriteBatch.DrawString(font, screenOn, new Vector2(500, 206), Color.White);
                        break;

                    case MenuType.HighScores:
                        spriteBatch.Draw(menu.Texture, menu.Position, Color.White);
                        for (int i = 0; i < scores.HighScores.Length; i++)
                        {
                            spriteBatch.DrawString(font, scores.HighScores[i], new Vector2(250, 50 + (50 * i)), Color.White);
                        }
                        break;

                    case MenuType.Pause:
                        spriteBatch.Draw(inGameMenu, new Vector2(250, 150), Color.White);
                        spriteBatch.Draw(menu.Texture, menu.Position, Color.White);
                        spriteBatch.Draw(start.Texture, start.Position, Color.White);
                        break;

                    case MenuType.KartSelect:
                        spriteBatch.Draw(start.Texture, start.Position, Color.White);
                        spriteBatch.Draw(testKart.Texture, testKart.Position, Color.White);
                        spriteBatch.Draw(tieFighter.Texture, tieFighter.Position, Color.White);
                        spriteBatch.Draw(shoppingCart.Texture, shoppingCart.Position, Color.White);
                        spriteBatch.Draw(guminKart.Texture, guminKart.Position, Color.White);
                        spriteBatch.Draw(menu.Texture, menu.Position, Color.White);
                        spriteBatch.Draw(chosenKart, new Vector2(400, 125), Color.White);
                        break;

                    case MenuType.Credits:
                        spriteBatch.Draw(menu.Texture, menu.Position, Color.White);
                        spriteBatch.DrawString(font, "Aaron Hosler", new Vector2(200, 220), Color.White);
                        spriteBatch.DrawString(font, "Josh Glover", new Vector2(300, 270), Color.White);
                        spriteBatch.DrawString(font, "Colin Holmes", new Vector2(400, 320), Color.White);
                        spriteBatch.Draw(Untitled, Vector2.Zero, Color.White);
                        break;

                    case MenuType.Publisher:
                        spriteBatch.Draw(title, new Vector2(200, 0), Color.White);
                        spriteBatch.DrawString(font, "Published by Cognitive Thought Media", new Vector2(54, 500), Color.White);
                        break;

                    default:
                        break;
                }
            }
            catch { }
        }
Пример #13
0
 public static void DrawCross(SpriteBatch spriteBatch, Vector2 position, Rectangle containedIn, Color color)
 {
     spriteBatch.Draw(PixelBlanc, new Rectangle(containedIn.X, (int)position.Y, containedIn.Width, 1), color);
     spriteBatch.Draw(PixelBlanc, new Rectangle((int)position.X, containedIn.Y, 1, containedIn.Height), color);
 }
Пример #14
0
        public override void Draw(GameTime gameTime, bool isInForeground, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, isInForeground, spriteBatch);

            spriteBatch.Draw(background, Manager.Game.Viewport, Color.White);
        }
Пример #15
0
 public void Render(SpriteBatch _sb)
 {
     _sb.Draw(tex, new RectangleF(x, y, 20, 27), Color.White);
 }
Пример #16
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            if (Background != null)
                spriteBatch.Draw(Background.Sheet.Texture, DestinationRect, Background.SourceRect, Color.White);

            foreach (Control control in SubControls.Values)
            {
                if (DestinationRect.Contains(control.DestinationRect))
                    control.Draw(gameTime, spriteBatch);
            }
        }
Пример #17
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            spriteBatch.Draw(background.Sheet.Texture, DestinationRect, background.SourceRect, Color.White);

            searchBar.Draw(gameTime, spriteBatch);

            List<TextBlock> toDraw = list.FindAll(x => x.Text.StartsWith(searchBar.Text));
            stack.Elements = toDraw.ToList<Control>();

            Rectangle itemRectangle = DestinationRect;
            itemRectangle.Height = 30;
            if (toDraw.Count > 0 && SelectedItem != null)
            {
                TextBlock textBlock = list[SelectedIndex];
                if (textBlock != null && toDraw.Contains(textBlock) && stack.IsElementDisplayed(stack.Elements.IndexOf(textBlock)))
                    spriteBatch.Draw(background.Sheet.Texture, textBlock.DestinationRect, background.SourceRect, Color.White);
                else
                    SelectedItem = null;
            }
            stack.Draw(gameTime, spriteBatch);
        }
Пример #18
0
 public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch, int x, int y, Rectangle destinationRect)
 {
     spriteBatch.Draw(GroundSprite.Sheet.Texture, new Rectangle(x * Tile.Width - World.View.X, y * Tile.Height - World.View.Y, Tile.Width, Tile.Height), GroundSprite.SourceRect, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0);
 }
Пример #19
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            if (Texture != null)
            {
                int texX = SourceRect == null ? 0 : SourceRect.Value.X;
                int texY = SourceRect == null ? 0 : SourceRect.Value.Y;
                int texWidth = SourceRect == null ? Texture.Width : SourceRect.Value.Width;
                int texHeight = SourceRect == null ? Texture.Height : SourceRect.Value.Height;

                RectangleF rect = DestinationRect;
                float rectRatio = rect.Width / (float)rect.Height;
                float textureRatio = texWidth / (float)texHeight;
                if (rectRatio < textureRatio)
                {
                    float ratio = rectRatio / textureRatio;
                    rect.Height = rect.Height * ratio;
                }
                if (rectRatio > textureRatio)
                {
                    float ratio = textureRatio / rectRatio;
                    rect.Width = rect.Width * ratio;
                }
                rect.Width = rect.Width / Zoom;
                rect.Height = rect.Height / Zoom;

                RectangleF final = rect;
                final.Width = Math.Min(DestinationRect.Width, rect.Width);
                final.Height = Math.Min(DestinationRect.Height, rect.Height);

                double wRatio = final.Width / (double)rect.Width;
                double hRatio = final.Height / (double)rect.Height;

                Rectangle sourceRect = new Rectangle((int)Position.X + texX, (int)Position.Y + texY, (int)(texWidth * wRatio), (int)(texHeight * hRatio));

                ratioWPixelScreenPicture = sourceRect.Width / final.Width;
                ratioHPixelScreenPicture = sourceRect.Height / final.Height;

                spriteBatch.Draw(Texture, new Rectangle((int)final.X, (int)final.Y, (int)final.Width, (int)final.Height), sourceRect, Color.White, 0, Vector2.Zero, Effect, 0.5f);

                if (SelectionMode)
                {
                    Vector2 crossPos = new Vector2(Input.X, Input.Y);
                    if (DestinationRect.Contains(crossPos))
                        DrawHelper.DrawCross(spriteBatch, crossPos, DestinationRect, Color.DeepPink);
                }

                if (isSelecting)
                {
                    Rectangle selectionRect = new Rectangle();
                    Vector2 selectPoint = ConvertPictureToScreen(new Vector2(selectionStartPoint.X + 0.4f, selectionStartPoint.Y + 0.4f));
                    selectionRect.Left = Math.Min((int)selectPoint.X, Input.X);
                    selectionRect.Right = Math.Max((int)selectPoint.X, Input.X);
                    selectionRect.Top = Math.Min((int)selectPoint.Y, Input.Y);
                    selectionRect.Bottom = Math.Max((int)selectPoint.Y, Input.Y);
                    DrawHelper.DrawRectangle(spriteBatch, selectionRect, Color.Blue);

                    Color greenA = Color.Green; greenA.A = 100;
                    DrawHelper.DrawFilledRectangle(spriteBatch, DrawHelper.ClampRectangle(MagnetToPicture(selectionRect), DestinationRect), greenA);
                }
                else if (SelectedRectangle != null)
                {
                    Color greenA = Color.Green; greenA.A = 100;
                    Rectangle selected = (Rectangle)SelectedRectangle;
                    selected.Right -= 1; selected.Bottom -= 1;
                    DrawHelper.DrawFilledRectangle(spriteBatch, DrawHelper.ClampRectangle(ConvertPictureToScreen(selected), DestinationRect), greenA);
                }

                if (SelectPointMode && SelectedPoint != null)
                {
                    Color redA = Color.Red; redA.A = 100;
                    Rectangle point = new Rectangle((int)SelectedPoint.Value.X, (int)SelectedPoint.Value.Y, 0, 0);
                    DrawHelper.DrawFilledRectangle(spriteBatch, DrawHelper.ClampRectangle(ConvertPictureToScreen(point), DestinationRect), redA);
                }
            }
        }
Пример #20
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);

            if (Background != null)
                spriteBatch.Draw(Background.Sheet.Texture, DestinationRect, Background.SourceRect, Color.White);

            foreach (TextBlock textBlock in elements.Keys)
                textBlock.Draw(gameTime, spriteBatch);
        }
Пример #21
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            RectangleF clip;
            RectangleF destRect = Bounds;
            Rectangle? sourceRect = null;

            if (HasClip(out clip))
            {
                RectangleF inter = RectangleF.Empty;
                inter.Left = Math.Max(clip.Left, destRect.Left);
                inter.Top = Math.Max(clip.Top, destRect.Top);
                inter.Right = Math.Min(clip.Right, destRect.Right);
                inter.Bottom = Math.Min(clip.Bottom, destRect.Bottom);

                float leftClip = inter.Left - DrawPosition.X;
                float rightClip = inter.Right - (DrawPosition.X + Width);
                float topClip = inter.Top - DrawPosition.Y;
                float bottomClip = inter.Bottom - (DrawPosition.Y + Height);
                float clippedWidth = rightClip - leftClip;
                float clippedHeight = bottomClip - topClip;

                Rectangle source = Rectangle.Empty;
                source.X = (int)leftClip;
                source.Y = (int)topClip;
                source.Width = (int)(Width + clippedWidth);
                source.Height = (int)(Height + clippedHeight);
                sourceRect = source;

                destRect.X += leftClip;
                destRect.Y += topClip;
                destRect.Width = Math.Max(destRect.Width + clippedWidth, 0);
                destRect.Height = Math.Max(destRect.Height + clippedHeight, 0);

                if (UIManager.DrawDebug)
                {
                    PRect rect = new PRect(clip, 1);
                    rect.Color = Color.Yellow;
                    rect.Draw();

                    rect = new PRect(inter, 1);
                    rect.Color = Color.Magenta;
                    rect.Draw();
                }

                //int rC = (int)(  inter.Right - ( DrawPosition.X + Width ) - location.X + location.X);
                //int lC = (int)( location.X + inter.Left - DrawPosition.X - location.X );
                //int bC = (int)( location.Y + inter.Bottom - ( DrawPosition.Y + Height ) - location.Y );
                //int tC = (int)( location.Y + inter.Top - DrawPosition.Y - location.Y );
            }

            spriteBatch.Draw(texture, destRect, sourceRect, Color, 0f, Vector2.Zero, SpriteEffect, LayerDepth);
        }
Пример #22
0
        internal void Draw(SpriteBatch sb, Vector2 offset, Vector2 viewArea)
        {
            if (_tex != null && _tex.IsLoaded)
            {
                var pos3d = Owner.Transform.Translation;
                var basePos = new Vector2(pos3d.X + offset.X, pos3d.Y + offset.Y);
                if (Origin == OriginLocation.Center)
                    basePos -= (new Vector2(_tileWidth * MapWidth, _tileHeight * MapHeight) / 2.0f);

                int startX = Math.Max((int)(-offset.X / _tileWidth), 0);
                int startY = Math.Max((int)(-offset.Y / _tileHeight), 0);

                var width = Math.Min((int)(viewArea.X / _tileWidth), MapWidth - startX);
                var height = Math.Min((int)(viewArea.Y / _tileHeight) + 1, MapHeight - startY);

                for (int y = startY; y < startY + height; y++)
                {
                    for (int x = startX; x < startX + width; x++)
                    {
                        int index = (y * MapWidth) + x;
                        if (_map[index] >= 0)
                        {
                            var source = _lookup[_map[index]];
                            var pos = basePos + new Vector2(_tileWidth * x, _tileHeight * y);
                            var dest = new Rectangle((int)pos.X, (int)pos.Y, _tileWidth, _tileHeight);
                            var tex = _tex.Texture2D.ShaderResourceView[ViewType.Full, 0, 0];
                            sb.Draw(tex, dest, source, Color.White, 0, Vector2.Zero, SpriteEffects.None, pos3d.Z);
                        }
                    }
                }
            }
        }
Пример #23
0
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, Rectangle destinationRect)
 {
     spriteBatch.Draw(Sprite.Sheet.Texture, destinationRect, Sprite.SourceRect, Color.White, 0, Vector2.Zero, SpriteEffects.None, GetDepth(x, y));
 }
Пример #24
0
 public override void Render(SpriteBatch _spriteBatch)
 {
     _spriteBatch.Draw(tex, new RectangleF(x, y, 32*Width, 32*Height), Color.White);
 }
Пример #25
0
        public void Draw(GameTime gameTime, SpriteBatch sBatch, Rectangle destRect)
        {
            if (view.Width != destRect.Width || view.Height != destRect.Height)
            {
                view.Width = destRect.Width;
                view.Height = destRect.Height;
                MoveView(view.X, view.Y);
            }
            if (!renderDone)
                ComputeDraw(gameTime, View);
            sBatch.Draw(RenderTarget, destRect, Color.White);

            renderDone = false;
        }