public override void Draw(SceneGame scene)
        {
            SpriteReference cursor       = SpriteLoader.Instance.AddSprite("content/cursor");
            SpriteReference textbox      = SpriteLoader.Instance.AddSprite("content/ui_box");
            int             edgeDistance = 50;
            int             width        = scene.Viewport.Width - edgeDistance * 2;
            int             height       = 16 * Actions.Count;
            int             x            = edgeDistance;
            int             y            = (scene.Viewport.Height - height) / 2;
            float           openCoeff    = Math.Min(Ticks / 7f, 1f);
            float           openResize   = MathHelper.Lerp(-0.5f, 0.0f, openCoeff);
            RectangleF      rect         = new RectangleF(x, y, width, height);

            rect.Inflate(rect.Width * openResize, rect.Height * openResize);
            if (openCoeff > 0)
            {
                scene.DrawUI(textbox, rect.ToRectangle(), Color.White);
            }
            int i = 0;

            if (openCoeff >= 1)
            {
                foreach (var menupoint in Actions)
                {
                    if (menupoint == SelectedAction)
                    {
                        scene.SpriteBatch.Draw(cursor.Texture, new Vector2(x + 0, y + i * 16), cursor.GetFrameRect(0), Color.White);
                    }
                    scene.DrawText(menupoint.Name, new Vector2(x + 32, y + i * 16), Alignment.Left, new TextParameters().SetConstraints(width - 32, 16).SetBold(true).SetColor(Color.White, Color.Black));
                    i++;
                }
            }
        }
        public override void Draw(SceneGame scene)
        {
            var             memory  = Player.Memory;
            SpriteReference textbox = SpriteLoader.Instance.AddSprite("content/ui_box");

            if (NearestItem != null)
            {
                int        width      = 256;
                int        height     = 16;
                int        x          = (scene.Viewport.Width - width) / 2;
                int        y          = scene.Viewport.Height - height - 4;
                float      openCoeff  = Math.Min(NearestItemTicks / 7f, 1f);
                float      openResize = MathHelper.Lerp(-0.5f, 0.0f, openCoeff);
                RectangleF rect       = new RectangleF(x, y, width, height);
                rect.Inflate(rect.Width * openResize * 0.5f, rect.Height * openResize);
                if (openCoeff > 0)
                {
                    scene.DrawUI(textbox, rect.ToRectangle(), Color.White);
                }
                if (openCoeff >= 1)
                {
                    scene.DrawText($"Pick up {memory.GetName(NearestItem.Item)}", new Vector2(x, y), Alignment.Center, new TextParameters().SetConstraints(width, height).SetBold(true).SetColor(Color.White, Color.Black));
                }
            }

            DrawMessageHistory(scene, Player.History);
        }
Exemple #3
0
        public override void Draw(SceneGame scene, DrawPass pass)
        {
            var    calcParams = new TextParameters().SetColor(FontColor, BorderColor).SetConstraints(128, 64);
            string fit        = FontUtil.FitString(Game.ConvertToSmallPixelText(Text), calcParams);
            var    width      = FontUtil.GetStringWidth(fit, calcParams);
            var    height     = FontUtil.GetStringHeight(fit);

            scene.DrawText(fit, Position + Offset - new Vector2(128, height) / 2, Alignment.Center, new TextParameters().SetColor(FontColor, BorderColor).SetConstraints(128, height + 64));
        }
        public void DrawMessageHistory(SceneGame scene, MessageHistory history)
        {
            int offsetY = 150;

            foreach (var message in history.Messages.Reverse <Message>())
            {
                var    parameters = new TextParameters().SetColor(Color.White, Color.Black).SetBold(true).SetConstraints(scene.Viewport.Width, 128).SetIcons(scene, message.Icons);
                string fitString  = FontUtil.FitString(message.RenderText(Player), parameters);
                var    height     = FontUtil.GetStringHeight(fitString);
                offsetY -= height;
                if (offsetY + height < 0)
                {
                    break;
                }
                scene.DrawText(fitString, new Vector2(0, offsetY), Alignment.Right, parameters);
            }
        }
        public override void Draw(SceneGame scene)
        {
            SpriteReference textbox      = SpriteLoader.Instance.AddSprite("content/ui_box");
            int             edgeDistance = 75;
            int             width        = scene.Viewport.Width - edgeDistance * 2;
            int             height       = 16 * 4;
            int             x            = edgeDistance;
            int             y            = (scene.Viewport.Height - height) / 2;
            float           openCoeff    = Math.Min(Ticks / 7f, 1f);
            float           openResize   = MathHelper.Lerp(-0.5f, 0.0f, openCoeff);
            RectangleF      rect         = new RectangleF(x, y, width, height);

            rect.Inflate(rect.Width * openResize, rect.Height * openResize);
            if (openCoeff > 0)
            {
                scene.DrawUI(textbox, rect.ToRectangle(), Color.White);
            }
            if (openCoeff >= 1)
            {
                scene.DrawText(Text, new Vector2(x, y), Alignment.Left, new TextParameters().SetConstraints(width, height).SetBold(true).SetColor(Color.White, Color.Black));
            }
        }
        public override void Draw(SceneGame scene)
        {
            var             memory       = Player.Memory;
            SpriteReference cursor       = SpriteLoader.Instance.AddSprite("content/cursor");
            SpriteReference textbox      = SpriteLoader.Instance.AddSprite("content/ui_box");
            SpriteReference flagEquipped = SpriteLoader.Instance.AddSprite("content/flag_equip");

            int        edgeDistance = 75;
            int        width        = scene.Viewport.Width - edgeDistance * 2;
            int        height       = 16 * Math.Max(Items.Count, 1);
            int        x            = edgeDistance;
            int        y            = (scene.Viewport.Height - height) / 2;
            float      openCoeff    = Math.Min(Ticks / 7f, 1f);
            float      openResize   = MathHelper.Lerp(-0.5f, 0.0f, openCoeff);
            RectangleF rect         = new RectangleF(x, y, width, height);

            rect.Inflate(rect.Width * openResize, rect.Height * openResize);
            if (openCoeff > 0)
            {
                scene.DrawUI(textbox, rect.ToRectangle(), Color.White);
            }
            int i = 0;

            if (openCoeff >= 1)
            {
                if (Items.Count <= 0)
                {
                    scene.DrawText("You haven't anything.", new Vector2(x, y), Alignment.Left, new TextParameters().SetConstraints(width - 32, 16).SetBold(true).SetColor(Color.LightGray, Color.Black));
                }
                foreach (var menupoint in Items)
                {
                    var item = menupoint.Representative;

                    if (CombineSelections.Any(selection => selection.Stack == menupoint))
                    {
                        var combineSelection = CombineSelections.Find(selection => selection.Stack == menupoint);
                        if (Ticks % 2 == 0)
                        {
                            scene.SpriteBatch.Draw(cursor.Texture, new Vector2(x + 6, y + i * 16), cursor.GetFrameRect(0), Color.White);
                        }
                        item = combineSelection.Item;
                    }
                    if (menupoint == Selection.Stack)
                    {
                        scene.SpriteBatch.Draw(cursor.Texture, new Vector2(x + 0, y + i * 16), cursor.GetFrameRect(0), Color.White);
                        item = Selection.Item;
                    }

                    int selectedItems = CombineSelections.Count(selection => selection.Stack == menupoint);

                    item.DrawIcon(scene, new Vector2(x + 16 + 8, y + i * 16 + 8));
                    if (item == Player.Weapon)
                    {
                        scene.DrawSprite(flagEquipped, 0, new Vector2(x + 16, y + i * 16), SpriteEffects.None, 0);
                    }
                    if (selectedItems > 1)
                    {
                        scene.DrawText(Game.ConvertToSmallPixelText(selectedItems.ToString()), new Vector2(x + 32, y + i * 16), Alignment.Right, new TextParameters().SetColor(Color.White, Color.Black));
                    }
                    scene.DrawText($"{memory.GetName(item)} x{menupoint.Count}", new Vector2(x + 32, y + i * 16), Alignment.Left, new TextParameters().SetConstraints(width - 32, 16).SetBold(true).SetColor(Color.White, Color.Black));
                    i++;
                }
            }
        }
 public override void Draw(SceneGame scene)
 {
     scene.SpriteBatch.Draw(scene.Pixel, new Rectangle(scene.Viewport.X, scene.Viewport.Y, scene.Viewport.Width, scene.Viewport.Height), new Color(0, 0, 0, 128));
     scene.DrawText(Game.ConvertToPixelText("PAUSED"), new Vector2(scene.Viewport.Width / 2, scene.Viewport.Height / 2), Alignment.Center, new TextParameters().SetColor(Color.White, Color.Black));
 }