Пример #1
0
        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++;
                }
            }
        }
Пример #2
0
        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++;
                }
            }
        }