示例#1
0
        /// <summary>
        /// Creates a new AttackElement for the given parameters.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="attack">The Attack instance to visualize.</param>
        /// <param name="x">The top-left x-coordinate to start the attack box.</param>
        /// <param name="y">The top-left y-coordinate to start the attack box.</param>
        /// <param name="width">The width of the AttackElement.</param>
        /// <param name="height">The height of the AttackElement.</param>
        public AttackElement(Game game, Attack attack, int x, int y, int width, int height)
            : base(game, "attack", x, y, width, height)
        {
            this.attack = attack;

            AddChild(new DicesElement(game, attack.DiceForAttack.ToArray(), Bound.X + (int)(Bound.Width * 0.4), Bound.Y, (int)(Bound.Width * 0.6), Bound.Height / 2));

            List<SurgeAbility> surges = attack.SurgeAbilities;

            int yPos = Bound.Y + Bound.Height / 2;
            int xPos = Bound.X + (int)(Bound.Width * 0.4);
            int surgeHeight = 50;
            int surgeWidth = (int)(Bound.Width * 0.3);
            bool left = true;

            // Surge abilities
            SurgeAbility surge;
            for (int i = 0; i < surges.Count; i++)
            {
                int id = i;
                surge = surges[i];
                GUIElement surgeBox = new GUIElement(game, "surge box", left ? xPos : xPos + surgeWidth, yPos, surgeWidth, surgeHeight);
                surgeBox.SetBackground("boxbg");

                GUIElementFactory.DrawSurgeAbility(surgeBox, surge, 5, 10, false);

                // click event
                surgeBox.SetClickAction(surgeBox.Name, (n, g) =>
                {
                    n.EventManager.QueueEvent(EventType.SurgeAbilityClicked, new SurgeAbilityEventArgs(id));
                });

                AddChild(surgeBox);

                // ready for next ability
                if (!left) yPos += height;
                left = !left;
            }

            // target monster (if any)
            Square square = FullModel.Board[attack.TargetSquare.X, attack.TargetSquare.Y];
            if (square.Figure != null && square.Figure is Monster)
            {
                GUIElement target = new MonsterSummary(game, Bound.X + (int)((Bound.Width * 0.4 - 125) / 2), Bound.Y + Bound.Height / 2 + (int)((Bound.Height / 2 - 175) / 2), (Monster)square.Figure);
                AddChild(target);
            }// target hero
            else if (square.Figure != null && square.Figure is Hero)
            {
                Image picture = new Image(((Hero)square.Figure).Texture);
                AddDrawable(Name, picture, new Vector2(Bound.X + (int)((Bound.Width * 0.4 - picture.Texture.Width) / 2),
                                                       Bound.Y + Bound.Height / 2 + (int)((Bound.Height / 2 - picture.Texture.Height) / 2)));
            }
        }
示例#2
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);
        }
示例#3
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 }));
        }