示例#1
0
        /// <summary>
        /// Creates a new OverlordCardElement to display information about
        /// the given OverlordCard starting from the given position.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="x">The top-left x-coordinate of the hidden mode.</param>
        /// <param name="y">The top-left y-coordinate of the hidden mode.</param>
        /// <param name="card">The OverlordCard to display information for.</param>
        public OverlordCardElement(Game game, int x, int y, OverlordCard card)
            : base(game, "overlord card", x, y, 200, 300)
        {
            if (Font == null) Font = game.Content.Load<SpriteFont>("fontSmall");

            SetBackground("Images/Other/overlordcard");

            // header
            GUIElement header = new GUIElement(game, "overlord header", Bound.X + 48, Bound.Y + 15, 200 - 48 * 2, 100);
            header.AddText(header.Name, card.Name, new Vector2(0, 0));
            header.SetDrawBackground(false);
            header.SetFont(Font);
            AddChild(header);

            // description
            GUIElement description = new GUIElement(game, "overlord desc", Bound.X + 35, Bound.Y + 80, 150, 160);
            description.AddText(description.Name, card.Decription, new Vector2(0, 0));
            description.SetDrawBackground(false);
            description.SetFont(Font);
            AddChild(description);

            // use area
            GUIElement use = new GUIElement(game, "use overlord card", Bound.X + 10, Bound.Y + 250, 50, 40);
            use.SetDrawBackground(false);
            use.SetClickAction(use.Name, (n, g) =>
                                             {
                                                 n.EventManager.QueueEvent(EventType.UseOverlordCard, new OverlordCardEventArgs(card.Id));
                                             });

            string playPrice = "" + card.PlayPrice;
            Vector2 playDisp = GUI.Font.MeasureString(playPrice);
            use.AddText(use.Name, playPrice, new Vector2((use.Bound.Width - playDisp.X) / 2, (use.Bound.Height - playDisp.Y) / 2));
            AddChild(use);

            // sell area
            GUIElement sell = new GUIElement(game, "sell overlord card", Bound.X + 140, Bound.Y + 250, 50, 40);
            sell.SetDrawBackground(false);
            sell.SetClickAction(sell.Name, (n, g) =>
                                               {
                                                   n.EventManager.QueueEvent(EventType.RemoveOverlordCard, new OverlordCardEventArgs(card.Id));
                                               });

            string sellPrice = "" + card.SellPrice;
            Vector2 sellDisp = GUI.Font.MeasureString(sellPrice);
            sell.AddText(sell.Name, sellPrice, new Vector2((sell.Bound.Width - sellDisp.X) / 2, (sell.Bound.Height - sellDisp.Y) / 2));
            AddChild(sell);
        }
示例#2
0
        /// <summary>
        /// Creates a new HeroElement to visualize the given hero.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="hero">The hero to display.</param>
        public HeroElement(Game game, Hero hero)
            : base(game, "hero", 0, 0, (int)(game.GraphicsDevice.Viewport.Width * (3 / 4.0)), game.GraphicsDevice.Viewport.Height)
        {
            this.hero = hero;
            this.SetDrawBackground(false);

            meleeT = game.Content.Load<Texture2D>("Images/Other/training-melee");
            rangedT = game.Content.Load<Texture2D>("Images/Other/training-ranged");
            magicT = game.Content.Load<Texture2D>("Images/Other/training-magic");

            coin25 = game.Content.Load<Texture2D>("Images/Other/25gold");
            coin100 = game.Content.Load<Texture2D>("Images/Other/100gold");
            coin500 = game.Content.Load<Texture2D>("Images/Other/500gold");

            healthRect = new Rectangle(225, this.Bound.Height - 150, 50, 50);
            fatigueRect = new Rectangle(225, this.Bound.Height - 100, 50, 50);
            armorRect = new Rectangle(225, this.Bound.Height - 50, 50, 50);
            movementRect = new Rectangle(275, this.Bound.Height - 100, 50, 50);
            attacksRect = new Rectangle(275, this.Bound.Height - 50, 50, 50);

            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("Images/Other/health-small")), healthRect);

            GUIElement fatigueBox = new GUIElement(game, "fatigue", fatigueRect.X, fatigueRect.Y, fatigueRect.Width, fatigueRect.Height);
            fatigueBox.SetDrawBackground(false);
            fatigueBox.AddDrawable(fatigueBox.Name, new Image(game.Content.Load<Texture2D>("Images/Other/fatigue-small")), fatigueRect);
            fatigueBox.SetClickAction(fatigueBox.Name, (n, g) =>
                                                         {
                                                             n.EventManager.QueueEvent(EventType.FatigueClicked, new GameEventArgs());
                                                         });
            AddChild(fatigueBox);

            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("Images/Other/movement-small")), movementRect);
            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("Images/Other/attacks-small")), attacksRect);
            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("Images/Other/armor-small")), armorRect);

            Vector2 nameV = GUI.Font.MeasureString(hero.Name);
            int nameX = (int)((200 - nameV.X) / 2);
            int nameY = Bound.Height - 30;

            // cost stuff
            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("Images/Other/cost-small")), new Rectangle(0, Bound.Height - 70, 40, 40));

            string cost = "" + hero.Cost;
            Vector2 size = GUI.Font.MeasureString(cost);
            this.AddText(this.Name, cost, new Vector2((40 - size.X) / 2, Bound.Height - 70 + (40 - size.Y) / 2), Color.White);

            this.AddDrawable(this.Name, new Image(game.Content.Load<Texture2D>("heroheader")), new Rectangle(nameX - 10, nameY - 5, (int)nameV.X + 20, (int)nameV.Y + 10));
            this.AddText(this.Name, hero.Name, new Vector2(nameX, nameY));

            // the equipment panels

            List<Equipment> equipment = new List<Equipment>();
            equipment.Add(hero.Inventory.Weapon);
            equipment.Add(hero.Inventory.Shield);
            equipment.Add(hero.Inventory.Armor);
            equipment.AddRange(hero.Inventory.OtherItems);

            AddChild(new EquipmentPanel(game, "Equipped", 350, Bound.Height - 50, hero.Inventory, new int[] { 0, 1, 2, 3, 4 }));

            AddChild(new EquipmentPanel(game, "Backpack", 500, Bound.Height - 50, hero.Inventory, new int[] { 8, 9, 10 }));

            AddChild(new EquipmentPanel(game, "Potions", 650, Bound.Height - 50, hero.Inventory, new int[] { 5, 6, 7 }));
        }