Equipment can be worn by the hero
Exemple #1
0
        /// <summary>
        /// Creates a new Equipment element to display the given Equipment at the given position.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="posX">The top-left x-coordinate of this element.</param>
        /// <param name="posY">The top-left y-coordinate of this element.</param>
        /// <param name="width">The width of this element.</param>
        /// <param name="height">The height of this element.</param>
        /// <param name="slotTitle">The title of this slot, in case the Equipment isn't there (null).</param>
        /// <param name="eq">The Equipment to visualize.</param>
        /// <param name="id">The Id of the given Equipment.</param>
        public EquipmentElement(Game game, int posX, int posY, int width, int height, string slotTitle, Equipment eq, int id)
            : base(game, "item", posX, posY, width, height)
        {
            Equipment = eq;
            Id = id;

            if (Coin == null) Coin = new Image(game.Content.Load<Texture2D>("Images/Other/25gold"));
            if (Hand == null) Hand = game.Content.Load<Texture2D>("Images/Other/hand");

            if (EquipmentFont == null) EquipmentFont = game.Content.Load<SpriteFont>("fontSmall");
            SetFont(EquipmentFont);

            if (Marked == null) Marked = "Images/Other/equipbg-marked";
            if (Border == null)
            {
                Border = new Dictionary<EquipmentRarity, string>();
                Border.Add(EquipmentRarity.Common, "Images/Other/equipbg");
                Border.Add(EquipmentRarity.Copper, "Images/Other/equipbg-bronze");
                Border.Add(EquipmentRarity.Silver, "Images/Other/equipbg-silver");
                Border.Add(EquipmentRarity.Gold, "Images/Other/equipbg-gold");
            }

            if (Equipment == null)
            {
                this.AddText(this.Name, slotTitle.Length > 0 ? slotTitle + " (Empty)" : "(Empty)", new Vector2(0, 0));
            }
            else
            {
                PopulateItem();
            }
            SetBackground(GetBGString());
        }
Exemple #2
0
        /// <summary>
        /// Creates an EquipmentElement for visualization of the properties of the given equipment. Using this method
        /// to create the element makes sure that all EquipmentElements in the game has the same dimensions and are
        /// equipped with proper click events.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="x">Will be the top-left coordinate of the EquipmentElement.</param>
        /// <param name="y">Will be the top-left coordinate of the EquipmentElement.</param>
        /// <param name="slotTitle">In case that the equipment is null it will display this title for the missing equipment.</param>
        /// <param name="equipment">The Equipment to visualize. Null here will indicate that the equipment slot is empty.</param>
        /// <param name="id">The game logic ID of this equipment, will be used for the click event.</param>
        /// <returns>A GUIElement that visualizes the given Equipment and keeps up to date if something within it changes.</returns>
        public static EquipmentElement CreateEquipmentElement(Game game, int x, int y, string slotTitle, Equipment equipment, int id)
        {
            Contract.Requires(game != null);
            Contract.Ensures(Contract.Result<EquipmentElement>().Id == id);
            Contract.Ensures(Contract.Result<EquipmentElement>().Equipment == equipment);

            return new EquipmentElement(game, x, y, RelW(game.GraphicsDevice.Viewport, 12), RelH(game.GraphicsDevice.Viewport, 16), slotTitle, equipment, id);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Treasure"/> class.
 /// </summary>
 /// <param name="id">
 /// The id of the treasure
 /// </param>
 /// <param name="name">
 /// The name of the treasure
 /// </param>
 /// <param name="rarity">
 /// The rarity of the treasure
 /// </param>
 /// <param name="equipment">
 /// The equipment equipment in the treasure
 /// </param>
 /// <param name="coins">
 /// The amount of coins in the treasure
 /// </param>
 public Treasure(int id, string name, EquipmentRarity rarity, Equipment equipment, int coins)
 {
     this.id = id;
     this.name = name;
     this.rarity = rarity;
     this.equipment = equipment;
     this.coins = coins;
 }
Exemple #4
0
 public Chest(int id, string name, EquipmentRarity rarity, Equipment equipment, Potion potion, int coin)
 {
     this.id = id;
     this.rarity = rarity;
     this.equipment = equipment;
     this.potion = potion;
     this.coin = coin;
 }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PotionMarker"/> class.
        /// </summary>
        /// <param name="id">
        /// The id of the marker
        /// </param>
        /// <param name="name">
        /// The name of the marker
        /// </param>
        /// <param name="texture">
        /// The texture of the marker
        /// </param>
        /// <param name="movementPoints">
        /// The movement points it costs to pickup the marker
        /// </param>
        /// <param name="potion">
        /// The potion that a hero will gain by picking it up
        /// </param>
        public PotionMarker(int id, string name, Texture2D texture, int movementPoints, Equipment potion)
            : base(id, name, texture, movementPoints)
        {
            Contract.Requires(name != null);
            Contract.Requires(name.Length > 0);
            Contract.Requires(movementPoints >= 0);
            Contract.Requires(potion != null);

            this.potion = potion;
        }
Exemple #6
0
 public PotionMarker Constructor(
     int id,
     string name,
     Texture2D texture,
     int movementPoints,
     Equipment potion
 )
 {
     PotionMarker target = new PotionMarker(id, name, texture, movementPoints, potion);
     return target;
     // TODO: add assertions to method PotionMarkerTest.Constructor(Int32, String, Texture2D, Int32, Equipment)
 }
 public void Constructor27()
 {
     List<SurgeAbility> list;
     List<Ability> list1_;
     Equipment equipment;
     PotionMarker potionMarker;
     SurgeAbility[] surgeAbilitys = new SurgeAbility[0];
     list = new List<SurgeAbility>((IEnumerable<SurgeAbility>)surgeAbilitys);
     Ability[] abilitys = new Ability[0];
     list1_ = new List<Ability>((IEnumerable<Ability>)abilitys);
     equipment = new Equipment(0, (string)null,
                       EquipmentType.Weapon, EAttackType.NONE, EquipmentRarity.Common,
                       0, list, 0, list1_, (List<Dice>)null);
     potionMarker = this.Constructor(0, "\0", (Texture2D)null, 0, equipment);
     Assert.IsNotNull((object)potionMarker);
     Assert.AreEqual<int>
     (0, ((global::Descent.Model.Board.Marker.Marker)potionMarker).Id);
     Assert.AreEqual<string>
     ("\0", ((global::Descent.Model.Board.Marker.Marker)potionMarker).Name);
     Assert.IsNull(((global::Descent.Model.Board.Marker.Marker)potionMarker).Texture);
     Assert.AreEqual<int>
     (0, ((global::Descent.Model.Board.Marker.Marker)potionMarker).MovementPoints);
 }
Exemple #8
0
        /*
        public void RemoveTreasure(int treasureId)
        {
            Contract.Requires(FullModel.GetTreasure(treasureId) != null);
            treasures.Remove(FullModel.GetTreasure(treasureId));
        }
        */
        public void AddToUnequippedEquipment(int playerId, Equipment equipment)
        {
            Contract.Requires(playerId > 0);
            Contract.Ensures(UnequippedEquipment(playerId).Contains(equipment));

            if (!unequippedEquipment.ContainsKey(playerId))
            {
                unequippedEquipment[playerId] = new List<Equipment>();
            }
            unequippedEquipment[playerId].Add(equipment);
        }
Exemple #9
0
        /// <summary>
        /// Equip an armor
        /// </summary>
        /// <param name="armor">
        /// The armor to be equipped
        /// </param>
        public void EquipArmor(Equipment armor)
        {
            Contract.Requires(armor != null);
            Contract.Requires(armor.Type == EquipmentType.Armor);
            Contract.Ensures(this[(int)EquipmentSlot.Armor] == armor);

            inventory[(int)EquipmentSlot.Armor] = armor;
            armor.EquipToHero(hero);
        }
Exemple #10
0
        /// <summary>
        /// Equip an item to potions.
        /// </summary>
        /// <param name="index">The indexwhere the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToPotions(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxPotions);
            Contract.Requires(item != null);
            Contract.Requires(item.Type == EquipmentType.Potion);
            Contract.Requires(this[(int)EquipmentSlot.Potion + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Potion + index] == item);

            inventory[(int)EquipmentSlot.Potion + index] = item;
            item.EquipToHero(hero);
        }
Exemple #11
0
        /// <summary>
        /// Equip a weapon
        /// </summary>
        /// <param name="weapon">
        /// The weapon to be equipped
        /// </param>
        public void EquipWeapon(Equipment weapon)
        {
            Contract.Requires(weapon != null);
            Contract.Requires(weapon.Type == EquipmentType.Weapon);
            Contract.Requires(weapon.Hands <= FreeHands);
            Contract.Ensures(inventory[(int)EquipmentSlot.Weapon] == weapon);
            Contract.Ensures(FreeHands == Contract.OldValue(FreeHands) - weapon.Hands);

            inventory[(int)EquipmentSlot.Weapon] = weapon;
            weapon.EquipToHero(hero);
        }
Exemple #12
0
        /// <summary>
        /// Equip an item to backpack.
        /// </summary>
        /// <param name="index">The index where the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToBackpack(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxInBackpack);
            Contract.Requires(item != null);
            Contract.Requires(this[(int)EquipmentSlot.Backpack + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Backpack + index] == item);

            inventory[(int)EquipmentSlot.Backpack + index] = item;
            item.EquipToHero(hero);
        }
Exemple #13
0
        /// <summary>
        /// Equip an item to 'other'.
        /// </summary>
        /// <param name="index">The index where the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToOther(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxOtherItems);
            Contract.Requires(item != null);
            Contract.Requires(item.Type == EquipmentType.Other);
            Contract.Requires(this[(int)EquipmentSlot.Other + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Other + index] == item);

            inventory[(int)EquipmentSlot.Other + index] = item;
            item.EquipToHero(hero);
        }
Exemple #14
0
        /// <summary>
        /// Equip a shield.
        /// </summary>
        /// <param name="shield">
        /// The shield to be equipped
        /// </param>
        public void EquipShield(Equipment shield)
        {
            Contract.Requires(shield != null);
            Contract.Requires(shield.Type == EquipmentType.Shield);
            Contract.Requires(shield.Hands <= FreeHands);
            Contract.Ensures(this[(int)EquipmentSlot.Shield] == shield);
            Contract.Ensures(FreeHands == Contract.OldValue(FreeHands) - shield.Hands);

            inventory[(int)EquipmentSlot.Shield] = shield;
            shield.EquipToHero(hero);
        }
Exemple #15
0
        /// <summary>
        /// Places a potion in the first 
        /// </summary>
        /// <param name="potion">
        /// The potion to be equipped
        /// </param>
        public void EquipPotion(Equipment potion)
        {
            Contract.Requires(potion != null);
            Contract.Requires(CanEquipPotion);
            Contract.Requires(potion.Type == EquipmentType.Potion);

            for (int n = (int)EquipmentSlot.Potion; n < (int)EquipmentSlot.Potion + 6; n++)
            {
                if (this[n] == null)
                {
                    this[n] = potion;
                    return;
                }
            }
        }
Exemple #16
0
        public void RemoveFromUnequippedEquipment(int playerId, Equipment equipment)
        {
            Contract.Requires(playerId > 0);

            unequippedEquipment[playerId].Remove(equipment);
        }
Exemple #17
0
 /// <summary>
 /// Do you have enough hands left to equip this weapon?
 /// </summary>
 /// <param name="equipment">
 /// A piece of equipment.
 /// </param>
 /// <returns>
 /// Whether there are enough hands to equip this weapon
 /// </returns>
 public bool CanEquipWeapon(Equipment equipment)
 {
     return equipment.Hands <= FreeHands;
 }
Exemple #18
0
 public bool CanEquipAtIndex(int slot, Equipment equipment)
 {
     if (equipment == null) return true;
     return slot == (int)EquipmentSlot.Weapon ?
         equipment.Type == EquipmentType.Weapon && this.CanEquipWeapon(equipment) :
                 slot == (int)EquipmentSlot.Shield ?
                 equipment.Type == EquipmentType.Shield && CanEquipWeapon(equipment) :
                        slot == (int)EquipmentSlot.Armor ?
                        equipment.Type == EquipmentType.Armor :
                             slot >= (int)EquipmentSlot.Other && slot < (int)EquipmentSlot.Potion ?
                             equipment.Type == EquipmentType.Other :
                                 slot >= (int)EquipmentSlot.Potion && slot < (int)EquipmentSlot.Backpack ?
                                 equipment.Type == EquipmentType.Potion :
                                     slot >= (int)EquipmentSlot.Backpack && slot < this.Length;
 }