AddItem() public method

Add new item to inventory
public AddItem ( Item item ) : void
item Item The item to add to inventory
return void
Ejemplo n.º 1
0
 /// <summary>
 /// Method called when an actor picks up an item from the ground.
 /// Replaces the old owner and deletes the itemtile from the map
 /// </summary>
 /// <param name="actor">The actor which gains the item</param>
 public void Pickup(Actor actor)
 {
     if (_owner != null)
     {
         _owner.inventory.Remove(this);
     }
     _owner = actor;
     int temp = 0;
     if (_itemType != Backend.ItemType.Gold)
     {
         for (int i = 0; i < actor.inventory.Count; ++i)
         {
             temp = Math.Max(id, actor.inventory[i].id);
         }
         _id = temp + 1;
         actor.AddItem(this);
     }
     else
     {
         actor.gold += _value;
     }
     _tile = null;
 }