public void Draw(GameTime gameTime, MySpriteBatch spritebatch)
        {
            if (_scoreUi != null)
            {
                _scoreUi.Draw(gameTime, spritebatch);
            }

            SpriteFont font = FontManager.Instance.GetFont("Arial-16");

            var measuring = font.MeasureString("Rank");

            spritebatch.DrawString(font, "Rank", new Vector2(Settings.ScreenWidth * 0.5f - measuring.X * 0.5f, Settings.ScreenHeight * 0.5f), Color.Yellow);

            var scores = new List <double>()
            {
                _score.Red,
                _score.Blue,
                _score.Green,
                _score.Yellow
            };

            bool redDrawed    = false;
            bool blueDrawed   = false;
            bool greenDrawed  = false;
            bool yellowDrawed = false;

            var orderScores = scores.OrderByDescending(x => x);

            for (int i = 0; i < orderScores.Count(); i++)
            {
                var score = orderScores.ElementAt(i);

                if (score == _score.Red && !redDrawed)
                {
                    spritebatch.DrawString(font, (i + 1) + " : Red : " + _score.Red.ToString("0") + "%",
                                           new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow);
                    redDrawed = true;
                }
                else if (score == _score.Blue && !blueDrawed)
                {
                    spritebatch.DrawString(font, (i + 1) + " : Blue : " + _score.Blue.ToString("0") + "%",
                                           new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow);
                    blueDrawed = true;
                }
                else if (score == _score.Green && !greenDrawed)
                {
                    spritebatch.DrawString(font, (i + 1) + " : Green : " + _score.Green.ToString("0") + "%",
                                           new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow);
                    greenDrawed = true;
                }
                else if (score == _score.Yellow && !yellowDrawed)
                {
                    spritebatch.DrawString(font, (i + 1) + " : Yellow : " + _score.Yellow.ToString("0") + "%",
                                           new Vector2(Settings.ScreenWidth * 0.5f - 50, Settings.ScreenHeight * 0.5f + 50 + i * 20), Color.Yellow);
                    yellowDrawed = true;
                }
            }
        }
        public void Draw(MySpriteBatch spritebatch)
        {
            _mapView.Draw(spritebatch);

            SpriteFont font = FontManager.Instance.GetFont("Arial-16");

            spritebatch.DrawString(font, "Pinch : " + _pinchDistance, new Vector2(10, 90), Color.Yellow);
            spritebatch.DrawString(font, "Zoom : " + Settings.Zoom, new Vector2(10, 130), Color.Yellow);
        }
        protected override void OnDraw(ref DrawParams p)
        {
            base.OnDraw(ref p);

            Vector2 origin = Vector2.Zero; // new Vector2(2f * txt.Length, 0f);
            Vector2 pos    = Motion.PositionAbsZoomedPixels;
            // draw shadow
            Color shadowDrawColor = Color.Black;

            shadowDrawColor.A = DrawInfo.DrawColor.A;

            // scaling with resolutions
            //             descriptionBox.Motion.Scale = ((float)Screen.WidthPixels) / 1440f; // 768f / ((float)Screen.HeightPixels); // +(((float)Screen.WidthPixels) - 1440f) / 1440f;
            float   sc      = Motion.ScaleAbs; // *((float)Screen.WidthPixels) / 1440f; // HACK
            float   scRatio = (float)(Screen.AspectRatio / 1.6f);
            Vector2 vScale  = new Vector2(sc * scRatio, sc);

            try
            {
                MySpriteBatch.DrawString(font, txt, pos + new Vector2(1f, 1f), shadowDrawColor,
                                         Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth + 0.00001f); // TODO the const
                MySpriteBatch.DrawString(font, txt, pos, DrawInfo.DrawColor,
                                         Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth);
            }
            catch (Exception)
            {
                ;  // e.g. if character to draw not available. // TODO
            }
        }
Exemple #4
0
        public void Draw(MySpriteBatch spritebatch)
        {
            //Calcul zones visibles
            int xMin = (int)(-Settings.ScreenWidth * 1 / Settings.Zoom);
            int yMin = (int)(-Settings.ScreenHeight * 1 / Settings.Zoom);
            int xMax = (int)(Settings.ScreenWidth + Settings.ScreenWidth * 1 / Settings.Zoom);
            int yMax = (int)(Settings.ScreenHeight + Settings.ScreenHeight * 1 / Settings.Zoom);

            for (var i = _zoneViews.Count - 1; i >= 0; i--)
            {
                var zoneView = _zoneViews.ElementAt(i);
                var position = zoneView.Value.GetPosition();

                if (
                    xMin <= position.X && position.X < xMax &&
                    yMin <= position.Y && position.Y < yMax
                    )
                {
                    zoneView.Value.Draw(spritebatch);
                }
            }

            var font = FontManager.Instance.GetFont("Arial-16");

            spritebatch.DrawString(font, $"Zones : {xMin},{yMin} {xMax},{yMax}", new Vector2(10, 110), Color.Yellow);
        }
        protected override void OnDraw(ref DrawParams p)
        {
            Vector2 pos = DrawInfo.DrawPosition;
            double  progressValuePercent = 100 * progressValue;
            float   drawSc = DrawInfo.DrawScale;
            int     width  = 1 + (int)Math.Round(ToPixels(DrawInfo.WidthAbs) * progressValue * barWidth);
            int     height = (int)Math.Round(ToPixels(DrawInfo.HeightAbs));

            if (width > Texture.Width)
            {
                width = Texture.Width;
            }

            Rectangle srcRect = new Rectangle(0, 0, width, Texture.Height - 2);

            MySpriteBatch.Draw(Texture, pos, srcRect, DrawInfo.DrawColor,
                               Motion.RotateAbs, new Vector2(0f, height / 4), drawSc, SpriteEffects.None, DrawInfo.LayerDepth);

            // plot text percentage
            Color   textColor = DrawInfo.DrawColor;
            Vector2 tpos      = pos + new Vector2(width * drawSc, height / 4); //Texture.Height / 2.0f - 10.0f) ;
            Vector2 origin    = new Vector2(10f, 6f);

            MySpriteBatch.DrawString(spriteFont, String.Format("  {0,3}%", Math.Round(progressValuePercent)), tpos,
                                     textColor, Motion.RotateAbs, origin, textScale * drawSc * 0.72f, SpriteEffects.None, DrawInfo.LayerDepth);
        }
Exemple #6
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();

            _stopwatch.Restart();
            World.Draw(gameTime.ElapsedGameTime.TotalMilliseconds, _spriteBatch);

            _spriteBatch.DrawString(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16), "Draw : " + _stopwatch.Elapsed.TotalMilliseconds.ToString("0.000") + " ms", new Vector2(10, 10), Color.Yellow);
            _spriteBatch.DrawString(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16), "Update : " + _updateTime.ToString("0.000") + " ms", new Vector2(10, 30), Color.Yellow);
            _spriteBatch.DrawString(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16), "Fps : " +
                                    (10000 / ((_updateTime + _stopwatch.Elapsed.TotalMilliseconds) * 10)).ToString("00.00"), new Vector2(10, 50), Color.Yellow);
            _spriteBatch.DrawString(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16), "Draw calls : " + _spriteBatch.DrawCallsCount, new Vector2(10, 70), Color.Yellow);

            _spriteBatch.End();

            //_basicUI.Draw(gameTime.ElapsedGameTime.TotalMilliseconds);

            base.Draw(gameTime);
        }
Exemple #7
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();

            _stopwatch.Restart();

            SpriteFont font = FontManager.Instance.GetFont("Arial-10");

            _gameManager.Draw(gameTime, _spriteBatch);

            _drawTime = _stopwatch.ElapsedMilliseconds;

            _spriteBatch.DrawString(font, "Update : " + _updateTime.ToString("0.000") + " ms", new Vector2(10, 10), Color.Yellow);
            _spriteBatch.DrawString(font, "Draw : " + _drawTime.ToString("0.000") + " ms", new Vector2(10, 30), Color.Yellow);

            if (_minFrameCounter != int.MaxValue)
            {
                _spriteBatch.DrawString(font,
                                        "Fps : " + _lastFrameCounter.ToString("00.00") + ", Min : " + _minFrameCounter.ToString("00.00") + ", Max : " + _maxFrameCounter.ToString("00.00"),
                                        new Vector2(10, 50), Color.Yellow);
            }
            else
            {
                _spriteBatch.DrawString(font,
                                        "Fps : " + _lastFrameCounter.ToString("00.00") + ", Max : " + _maxFrameCounter.ToString("00.00"),
                                        new Vector2(10, 50), Color.Yellow);
            }

            _spriteBatch.DrawString(font, "DrawCallCount : " + _spriteBatch.DrawCallsCount, new Vector2(10, 70), Color.Yellow);


            _spriteBatch.End();

            base.Draw(gameTime);
        }
        protected override void OnDraw(ref DrawParams p)
        {
            Vector2 pos     = DrawInfo.DrawPosition;
            String  curText = "";

            if (text.Length > 0 && text[0].Length > 0)
            {
                float t = 0f;
                for (int i = 0; i < text.Length; i++)
                {
                    if (t <= SimTime)
                    {
                        if (doReplace)
                        {
                            curText = text[i];
                        }
                        else
                        {
                            if (curText.Length > 0)
                            {
                                curText += "\n";
                            }
                            curText += text[i];
                        }
                    }
                    t += timings[i];
                }
            }

            if (curText.Length > 0)
            {
                float   sc     = Motion.ScaleAbs;
                Vector2 origin = totalTextSize / 2f; // Vector2.Zero; // new Vector2(((float)curText.Length) / 40f, 0f);
                if (Shadow)
                {
                    MySpriteBatch.DrawString(SubtitleFont, curText, pos + ShadowVector, Color.Black, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth + 0.0001f);
                    MySpriteBatch.DrawString(SubtitleFont, curText, pos - ShadowVector, Color.DarkGray, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth + 0.0002f);
                }
                MySpriteBatch.DrawString(SubtitleFont, curText, pos, DrawInfo.DrawColor, 0f, origin, ScaleVector * sc, SpriteEffects.None, DrawInfo.LayerDepth);
            }
        }
Exemple #9
0
        public void Draw(GameTime gameTime, MySpriteBatch spritebatch)
        {
            _mapManager.Draw(spritebatch);


            //Player Positions
            var texturePlayerPositionWidth  = TextureManager.Instance.GetTexture("Textures/PlayerPosition_Width");
            var texturePlayerPositionHeight = TextureManager.Instance.GetTexture("Textures/PlayerPosition_Height");

            spritebatch.Draw(texturePlayerPositionWidth, _rectRed, Color.White);
            spritebatch.Draw(texturePlayerPositionHeight, _rectBlue, Color.White);
            spritebatch.Draw(texturePlayerPositionWidth, _rectGreen, Color.White);
            spritebatch.Draw(texturePlayerPositionHeight, _rectYellow, Color.White);



            //Draw balls
            var textureBall = TextureManager.Instance.GetTexture("Textures/Paint");

            foreach (var ball in _paintBalls)
            {
                if (!ball.IsDrawed)
                {
                    var position = ball.Position - new Vector2(16, 16);
                    spritebatch.Draw(textureBall, new Rectangle((int)position.X, (int)position.Y, 32, 32), ball.Color);
                }
            }

            SpriteFont font = FontManager.Instance.GetFont("Arial-10");

            spritebatch.DrawString(font, "Pinch : " + _pinchDistance, new Vector2(10, 90), Color.Yellow);

            if (_lastScore != null)
            {
                spritebatch.DrawString(font, "Time : " + TimeSpan.FromSeconds(_timeGame - _timeCurrent),
                                       new Vector2(Settings.ScreenWidth - 200, 10), Color.Yellow);
                spritebatch.DrawString(font, "Red : " + _lastScore.Red.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 30), Color.Yellow);
                spritebatch.DrawString(font, "Blue : " + _lastScore.Blue.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 50), Color.Yellow);
                spritebatch.DrawString(font, "Green : " + _lastScore.Green.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 70), Color.Yellow);
                spritebatch.DrawString(font, "Yellow : " + _lastScore.Yellow.ToString("0") + "%", new Vector2(Settings.ScreenWidth - 200, 90), Color.Yellow);
            }
        }