// Adds a behavior to the item. public void AddBehavior(IItemBehavior behavior) { if (!behaviors.ContainsKey(behavior.GetBehaviorType())) { behaviors.Add(behavior.GetBehaviorType(), behavior); } }
public Item(int id, string identifier, string name, string description, int price, IItemBehavior behavior) { this.ID = id; this.Identifier = identifier; this.Name = name; this.Description = description; this.Price = price; this.Picture = (Texture)Resources.Load("Items/item_" + id); this.behavior = behavior; }
public Item(int id) { this.ID = id; this.Picture = (Texture)Resources.Load("Items/item_" + id); if (id == 165) { this.isUsable = true; this.isConsumed = true; this.behavior = new ItemHealthBehavior(50); } }
public Item(int id, string name, string identifier, string description) { this.ID = id; this.Name = name; this.Identifier = identifier; this.Description = description; this.Price = 0; this.Picture = (Texture)Resources.Load("Items/item_" + id); this.behavior = null; if (id == 165) { this.isUsable = true; this.isConsumed = true; this.behavior = new ItemHealthBehavior(50); } }
// Duplicate an item. This is a hack to enable managing equipables as // separate items with individual state. // // WARNING: This is intended to be used by equipable items only. public IItem DuplicateItem() { IItem item = new Item(Id); item.Name = Name; item.Description = Description; item.Damage = Damage; item.Durability = Durability; item.BaseDurability = BaseDurability; if (behaviors.ContainsKey(ItemBehaviorType.EQUIPABLE)) { EquipableItemBehavior originalBehavior = (EquipableItemBehavior)behaviors[ItemBehaviorType.EQUIPABLE]; IItemBehavior duplicateBehavior = originalBehavior.DuplicateBehavior(); item.AddBehavior(duplicateBehavior); } return(item); }
public GrScItem(IItemBehavior itemBehavior) { _itemBehavior = itemBehavior; }